Hi Mike,

(for the benefit of others please reply to the mailing list when you
respond)

... so you have a method which builds a DOM and returns its root element.
Surely there's some other code which does some processing with this Node,
possibly mutating the subtree before serializing it. You should take a look
at what that code does.

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

"Mike Gardiner" <[EMAIL PROTECTED]> wrote on 10/04/2007 09:21:01 AM:

> I'm using a Document Builder. In the following section of code, the
> variable 'xml' is a string containing the xml to be transformed to a
> document / document element
>
>         org.w3c.dom.Document   document = null;
>         try {
>             DocumentBuilderFactory factory = org.apache.xerces.jaxp.
> DocumentBuilderFactoryImpl.newInstance();
>             factory.setNamespaceAware(false);
>             factory.setValidating(false);
>
>             DocumentBuilder builder;
>
>              builder = factory.newDocumentBuilder();
>             document = builder.parse(new InputSource(new
StringReader(xml)));
>
>
>
>         return document.getDocumentElement();
>         }
>

> On 10/3/07, Michael Glavassevich < [EMAIL PROTECTED]> wrote:
> Hi Mike,
>
> Xerces doesn't magically add new namespace declarations to documents. In
> each place you mention what "Java" is doing what are you referring to? A
> transformer?
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: [EMAIL PROTECTED]
> E-mail: [EMAIL PROTECTED]
>
> "Mike Gardiner" <[EMAIL PROTECTED]> wrote on 10/03/2007 02:44:13 PM:
>
> >  Hello,
> >
> >  I'm trying to load some XML without it being modified but from what I
> > see, no matter which way I load it (.setNamespaceAware = true|false)
> > java is making modifications to my XML.
> >
> >  Eg:
> >
> >  If I have source XML
> >
> >  <root xmlns:ns="http://someURI.net";>
> >  <ns:tag1>some value</ns:tag1>
> >  <ns:tag2>
> >  <tag3>some value for tag 3</tag3>
> >  </ns:tag2>
> >  </root>
> >
> >  And I load it using a DocumentBuilderFactory with
> > .setNamespaceAware=true I get:
> >
> >  <root xmlns:ns="http://someURI.net";>
> >  <ns:tag1>some value</ns:tag1>
> >  <ns:tag2>
> >  <ns5:tag3 xmlns=" http://test.net"; xmlns:ns5="http://test.net";>some
> > value for tag 3</ns5:tag3>
> >  </ns:tag2>
> >  </root>
> >
> >  And if I load it using .setNamespaceAware=false I get:
> >
> >  <root xmlns:ns="http://someURI.net";>
> >  <ns:tag1 xmlns:ns="">some value</ns:tag1>
> >  <ns:tag2 xmlns:ns="">
> >  <tag3>some value for tag 3</tag3>
> >  </ns:tag2>
> >  </root>
> >
> >
> >  So basically what I'm asking is how do I load my source XML as it is
> > without having Java modify it?
> >
> > I have tags that don't have namespace information, and that is by
> > design, but if I load the XML and let java assign a random namespace
> > to it, it's no longer the same XML. And if I tell the document builder
> > to not be namespace aware then it starts redefining namespaces to "".
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to