FW: [jdom-interest] & in namespace

Tatu Saloranta cowtowncoder at yahoo.com
Wed May 3 09:37:51 PDT 2006



--- "Deshpande, Aniruddha"
<Aniruddha.Deshpande at softwareag.com> wrote:

...
> I tried same with Xerces's XMLSerializer and it
> works fine.
> 
> What do you feel? Is this a bug in JDOM? How should
> we proceed?

Yes, it does sound like a bug. And since I earlier in
fact fixed similar bug for another serializer, it's
not  an uncommon one, even. ;-)

I think offering a patch for this should be the best
way to proceed (as usual): I haven't lately looked at
serialization side, but it should be quite
straight-forward to add call to quoting method from
the method writes out namespace declarations, same as
regular attribute values are quoted. If not, I'm sure
someone on the list can help in locating it?

Hope this helps,

-+ Tatu +-

> 
> With Regards,
> Aniruddha Deshpande
> 
> -----Original Message-----
> From: jdom-interest-bounces at jdom.org
> [mailto:jdom-interest-bounces at jdom.org] On Behalf Of
> Tatu Saloranta
> Sent: Wednesday, May 03, 2006 11:42 AM
> To: jdom-interest at jdom.org
> Subject: Re: FW: [jdom-interest] &amp; in namespace
> 
> Please re-read Elliotte's response: it was 100%
> accurate. It is possible that JDom's serializer
> (outputter) does not quote values of namespace URIs,
> and if so, it could and should be fixed.
> 
> I would also comment that using namespace URIs with
> ampersands is a bad idea.
> 
> -+ Tatu +-
> 
> --- "Deshpande, Aniruddha"
> <Aniruddha.Deshpande at softwareag.com> wrote:
> 
> > Hello,
> > 
> > In my code I need to parse a WSDL file. Since WSDL
> > file is an XML file the contents of namespace URI
> > indeed has "&amp;" and not "&".
> > 
> > I have a test case wherein I have written a small
> > XML file which is parsed and printed with
> outputter.
> > 
> > Please find attached XML and Java source file.
> > Please change the code according to your settings.
> > 
> > If you look into the output of the program "&" is
> > converted back to "&amp;" in every case except for
> > namespaces.
> > 
> > The code just reads a file, creates a JDOM
> Document
> > object and passes that to XMLOutputter. I think
> this
> > basic flow should always lead the same XML file
> and
> > not an invalid XML file!
> > 
> > With Regards,
> > Aniruddha Deshpande
> > 
> > -----Original Message-----
> > From: Elliotte Harold
> > [mailto:elharo at metalab.unc.edu] 
> > Sent: Tuesday, May 02, 2006 5:10 PM
> > To: Deshpande, Aniruddha
> > Cc: jdom-interest at jdom.org
> > Subject: Re: [jdom-interest] &amp; in namespace
> > 
> > Deshpande, Aniruddha wrote:
> > > Hello,
> > > 
> > >  
> > > 
> > > I use SAXBuilder to parse and add an extra
> element
> > to an existing WSDL 
> > > file. I am facing problem for WSDLs which have
> > &amp; in their namespace 
> > > declaration. When I use XMLOutputter to write
> back
> > the changed WSDL 
> > > “&amp;” gets replaced with
> “&”.
> > > 
> > >  
> > 
> > I don't believe the namespace URI contains &amp;.
> I
> > suspect it contains 
> > & which is escaped as &amp; in XML contexts. The
> > distinction is 
> > critical. However it does sound like you may have
> > uncovered a serious 
> > bug in JDOM if indeed JDOM does not escape such
> > ampersands when 
> > reserializing. Do you have a reproducible test
> case?
> > 
> > -- 
> > Elliotte Rusty Harold 
> elharo at metalab.unc.edu
> > XML in a Nutshell 3rd Edition Just Published!
> > http://www.cafeconleche.org/books/xian3/
> >
>
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim
> > > <?xml version="1.0" encoding="UTF-8"?>
> > <name xmlns:a="http://abc.com?a=b&amp;b=c"
> > first="http://abc.com?a=b&amp;b=c">Aniruddha &amp;
> Deshpande</name>>
> _______________________________________________
> > To control your jdom-interest membership:
> >
>
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> _______________________________________________
> To control your jdom-interest membership:
>
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
> 
> _______________________________________________
> To control your jdom-interest membership:
>
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the jdom-interest mailing list