[jdom-interest] DOMBuilder, DOM2JDom again.

philip.nelson at omniresources.com philip.nelson at omniresources.com
Tue Sep 25 21:27:48 PDT 2001


Yes, it's a bug.  I see the problem in DOMBuilder but don't quite understand
why.  Dom implementation is not passing the uri so the element is created in
the no namespace namespace.  Then we can't add the default namespace.

Soon....

> -----Original Message-----
> From: Xuemin Guan [mailto:xuemin at appresso.com]
> Sent: Friday, September 21, 2001 7:11 AM
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] DOMBuilder, DOM2JDom again.
> 
> 
> Hi, all,
> 
> Actually, I posted this problem last week. Sorry to crop up 
> it again. But
> I haven't got some certain answers back.
> 
> I think there is a bug in the DOMBuilder when it converts a DOM tree
> to a JDOM tree. I need to convert between a JDom treen and a DOM
> tree forth and back a few times. Error happens after the 
> first conversion,
> here is the error message:
> 
> Exception in thread "main" org.jdom.IllegalAddException: The 
> namespace xmlns:="u
> rn:biztalk-org:biztalk:biztalk_1" could not be added as 
> content to "biztalk_1":
> The namespace prefix "" collides with the element namespace prefix
>          at org.jdom.Element.addNamespaceDeclaration(Element.java:367)
>          at org.jdom.input.DOMBuilder.buildTree(DOMBuilder.java:417)
>          at org.jdom.input.DOMBuilder.buildTree(DOMBuilder.java:377)
>          at org.jdom.input.DOMBuilder.build(DOMBuilder.java:338)
>          at test.main(test.java:20)
> 
> Currently, I serialize the XML file to harddisk to work 
> around this problem.
> 
> The below is a testing source code, you can try it out yourself:
> 
> import org.w3c.dom.*;
> 
> import org.jdom.*;
> import org.jdom.input.*;
> import org.jdom.output.*;
> 
> import java.io.File;
> 
> class test{
> 	public static void main(String args[] )
> 		throws Exception
> 	{
> 	  if(args.length != 1){
> 	   System.out.println("Usage: java test{"+
> 		"[XML Document filename]");
> 	   return;
> 	  }
> 	 SAXBuilder saxBuilder = new SAXBuilder();
> 	 org.jdom.Document jdomDoc = saxBuilder.build(new 
> File(args[0]));
> 
>          DOMOutputter outputer = new DOMOutputter();
> 
> 		org.w3c.dom.Document domDoc =outputer.output(jdomDoc);
>          DOMBuilder domBuilder = new DOMBuilder();
>          jdomDoc = domBuilder.build(domDoc);
> 
>         domDoc = outputer.output(jdomDoc);
> 
>         jdomDoc = domBuilder.build(domDoc);
>       }
>   }
> 
> If you try it, you would fine the first conversion is just 
> fine, but when 
> the program
> tries to convert between a JDom tree and DOM tree again, the 
> test.class throw
> the above exception. I had a look at the JDom source, I 
> believe it is caused by
> a bug.
> 
> The follows is the XML document I used with the above java code.
> 
> <?xml version="1.0" encoding="Shift_JIS"?>
> <biztalk_1 xmlns="urn:biztalk-org:biztalk:biztalk_1">
>      <header>
>          <delivery>
>              <to>
>                  <address>urn:sap-com:logical-system:SAP</address>
>              </to>
>              <from>
>                  
> <address>urn:sap-com:logical-system:EXTERNAL</address>
>              </from>
>          </delivery>
>      </header>
>      <body xmlns="">
>          <doc:Customer.Search.Response 
> xmlns:doc="urn:sap-com:document:sap:business">
>              <Multiple>
>                  <item>
>                      <CUSTOMER>10001</CUSTOMER>
>                  </item>
>                  <item>
>                      <CUSTOMER>10002</CUSTOMER>
>                  </item>
>                  <item>
>                      <CUSTOMER>10003</CUSTOMER>
>                  </item>
>                  <item>
>                      <CUSTOMER>10004</CUSTOMER>
>                  </item>
>                  <item>
>                      <CUSTOMER>10005</CUSTOMER>
>                  </item>
>                  <item>
>                      <CUSTOMER>10006</CUSTOMER>
>                  </item>
>              </Multiple>
>              <PeCustomer>aaa</PeCustomer>
>              <Return>
>                  <MESSAGE>Looks good.</MESSAGE>
>              </Return>
>          </doc:Customer.Search.Response>
>      </body>
> </biztalk_1>
> 
> Thanks for your time.
> -------
> Xuemin Guan
> Software Engineer
> Appresso SpA (www.appresso.com)
> Tel:  +81-3-4412-7790(Direct)
>         +81-3-4412-7700(Represent)
> Email: xuemin at appresso.com 
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com



More information about the jdom-interest mailing list