From users-return-55346-apmail-cocoon-users-archive=cocoon.apache.org@cocoon.apache.org Wed Sep 10 18:28:34 2003 Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 16707 invoked from network); 10 Sep 2003 18:28:33 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 10 Sep 2003 18:28:33 -0000 Received: (qmail 23879 invoked by uid 500); 10 Sep 2003 18:28:10 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 23851 invoked by uid 500); 10 Sep 2003 18:28:10 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: users@cocoon.apache.org Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 23793 invoked from network); 10 Sep 2003 18:28:09 -0000 Received: from unknown (HELO infomaniak.ch) (212.23.249.236) by daedalus.apache.org with SMTP; 10 Sep 2003 18:28:09 -0000 Received: from quarko (unverified [80.238.133.111]) by infomaniak.ch (Rockliffe SMTPRA 5.3.4) with ESMTP id for ; Wed, 10 Sep 2003 20:26:33 +0200 From: "Olivier Lange" To: Subject: RE: i18n trouble with nested elements in catalog messages Date: Wed, 10 Sep 2003 20:28:07 +0200 Keywords: list cocoon-user Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: Importance: Normal X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N > Is that normal SAX behavior - and we should replace the null value with an Oh! I should have read the doc. From the Javadocs for the org.w3c.dom.Node interface: http://java.sun.com/j2se/1.4.1/docs/api/org/w3c/dom/Node.html#getNamespaceUR I() " public String getNamespaceURI() The namespace URI of this node, or null if it is unspecified. " Now, should 'MirrorRecord.nodeToEvents()' handle the 'node.getNamespaceURI() == null' case? Is it correct to replace null with an empty string? (Would you expect that this uri==null case crashes Cocoon?) >From the Log transformer, I see that all other elements have an empty string for the uri= when there is no namespace for an attribute. Olivier -----Message d'origine----- De : Olivier Lange [mailto:wire@petit-atelier.ch] Envoyé : mercredi, 10. septembre 2003 19:42 À : users@cocoon.apache.org Objet : RE: i18n trouble with nested elements in catalog messages Bruno, Konstantin, > Oliver, could you try putting the following between those two: > factory.setNamespaceAware(true); Thanks for the tip. I added factory.setNamespaceAware(true); to XMLResourceBundle.loadResourceBundle(). It looks like this: DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); The resulting SAX events look much better, namespaces are there. But any transformation placed after the 18n transformer still throws an NPE. Here are the last line logged by the Log transformer: [startElement] uri=urn:pro-helvetia.ch:phga:docmini:v1.1,local=d:p,raw=d:p [characters] Zu «Alpdurchblick. Filme zur NEAT» ist ein Katalog mit ausführlichen Informationen zum Gesamtprogramm erhältlich. Zu beziehen ist er bei Filmkreis Oberwallis ... [startElement] uri=urn:pro-helvetia.ch:phga:docmini:v1.1,local=d:link,raw=d:link [ ] 1. uri=null,local=href,qname=href,type=CDATA,value=mailto:email@domain.ch uri=null for the attribute, and local=raw for the element d:link. I also changed the code in MirrorRecorder.nodeToEvents() and replaced (lines 229-236): startElement(n.getNamespaceURI(), n.getNodeName(), n.getNodeName(), attrs); ... endElement(n.getNamespaceURI(), n.getNodeName(), n.getNodeName()); with startElement(n.getNamespaceURI(), n.getLocalName(), n.getNodeName(), attrs); ... endElement(n.getNamespaceURI(), n.getLocalName(), n.getNodeName()); which enhances the result for the elements: [characters] Zu «Alpdurchblick. Filme zur NEAT» ist ein Katalog mit ausführlichen Informationen zum Gesamtprogramm erhältlich. Zu beziehen ist er bei Filmkreis Oberwallis ... [startElement] uri=urn:pro-helvetia.ch:phga:docmini:v1.1,local=link,raw=d:link [ ] 1. uri=null,local=href,qname=href,type=CDATA,value=mailto:email@domain.ch but still uri=null for the attributes. I tried to change the message in the catalogue and introduced a 'xlink' prefix before the 'href' attribute. If the attribute's prefix is present, it works, it doesn't throw a NPE anymore: [characters] Zu «Alpdurchblick. Filme zur NEAT» ist ein Katalog mit ausführlichen Informationen zum Gesamtprogramm erhältlich. Zu beziehen ist er bei Filmkreis Oberwallis ... [startElement] uri=urn:pro-helvetia.ch:phga:docmini:v1.1,local=link,raw=d:link [ ] 1. uri=http://www.w3.org/1999/xlink,local=href,qname=xlink:href,type=CDATA,valu e=mailto:email@domain.ch [characters] email @ domain.ch ... [endDocument] So the problem arises only when there is no namespace for an attribute. I modified MirrorRecorder.nodeToEvents(), replacing (line 220): ((AttributesImpl) attrs).addAttribute(node.getNamespaceURI(), ... ); with: String sNamespaceURI = node.getNamespaceURI(); if( sNamespaceURI == null) { sNamespaceURI = ""; } ((AttributesImpl) attrs).addAttribute(sNamespaceURI, ... ); and this fixes the problem. But why would the uri=null when no prefix is present for an attribute of an element in a catalogue's message? Is that normal SAX behavior - and we should replace the null value with an empty string in MirrorRecord.nodeToEvents while recording the attributes, as I did? Or is it a bug? (i.e. node.getNamespaceURI() returns null) Olivier -----Message d'origine----- De : Bruno Dumon [mailto:bruno@outerthought.org] Envoyé : mercredi, 10. septembre 2003 11:36 À : users@cocoon.apache.org Objet : Re: i18n trouble with nested elements in catalog messages On Wed, 2003-09-10 at 11:05, Konstantin Piroumian wrote: > Hi Oliver, > > Sorry, hadn't time to investigate the problem, but from looking through the > code I didn't notice anything that could possibly be related to the problem. > > Your suggestion with the getLocaleName() instead of getName() is correct and > should be fixed, though it doesn't solve the problem. > > As a suggestion, try to add some logging to the XMLResourceBundle which is > in the i18n packet (src/java/org/apache/cocoon/i18n) and see if it parses > the namespace at all and does it give out the URI. > > I'll try to take a look at it myself more closely a little later. > Just had a quick look too, I think the problem is that the files are not parsed namespace-aware: see these lines in the class "XMLResourceBundle" (line 201-202): DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Oliver, could you try putting the following between those two: factory.setNamespaceAware(true); and let us know if it helps? -- Bruno Dumon http://outerthought.org/ Outerthought - Open Source, Java & XML Competence Support Center bruno@outerthought.org bruno@apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org