Are you creating the problem elements with code or are they in your
loaded document?
Jon Brisbin wrote:
> Searched in the archives and didn't find what I was looking for (but not
> really sure what I'm looking for, so don't throw things at me if this
> has been asked before).
>
> I have an XML template that I read into a DOM4J (using 1.6) document
> when I begin processing. The default namespace is set in the document
> and I set it again, just for good measure:
>
> SAXParser p = SAXParserFactory.newInstance().newSAXParser();
>
> DocumentFactory df = DocumentFactory.getInstance();
> df.setXPathNamespaceURIs( namespaces );
>
> SAXContentHandler ch = new SAXContentHandler();
> p.parse( ClassLoader.getSystemResourceAsStream( TEMPLATE_FILE ), ch );
>
> Document doc = ch.getDocument();
> doc.getRootElement().addNamespace( "", EFILE_NS );
>
>
> When I process the raw data, I do XPath lookups on nodes in the template
> and set them like so:
>
> XPath xp = root.createXPath( xpath );
> xp.setNamespaceURIs( namespaces );
> Element e = (Element) xp.selectSingleNode( root );
> if ( e != null ) {
> e.setText( value );
> return e;
> } else {
> return root;
> }
>
> But when the file is generated, some of the elements below the root
> element (but not all of them) have namespaces set to '' (blank). This
> causes the other party's XML processing to blow up with the error that
> the element with the blank namespace isn't in the E-file namespace, like
> it's supposed to be.
>
> If the namespace is set in the template, then I would expect it work
> correctly when I've read that document in and set the namespaces
> accordingly. That's not happening and some elements in the DOM are being
> "taken out" of the default namespace.
>
> Can someone shed some light on why this is happening?
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
dom4j-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dom4j-user