[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xerces-j-dev
Subject:    Re: Bundled Xalan serializer fails on attributes with '<' (left angle bracket)
From:       "Kristian Spangsege" <kristian.spangsege () gmail ! com>
Date:       2008-01-22 9:58:04
Message-ID: 19c077830801220158m677682d3s8579a9bba72173b3 () mail ! gmail ! com
[Download RAW message or body]

Aha - that is a good reason! But that still leaves us with the "<"
problem. Also, I would expect then that the following addition to the
code should eliminate the '0xb' error:

> document.setXmlVersion("1.1");

But it dosn't! The resulting document states version="1.1" but the
serializer still reports the same fatal error for the '0xb' character.

Regards,
Kristian Spangsege


On Jan 21, 2008 10:42 PM, Michael Glavassevich <mrglavas@ca.ibm.com> wrote:
> I assume you're attempting to write an XML 1.0 document. 0xb isn't a legal
> character [1] in an XML 1.0 document.
>
> [1] http://www.w3.org/TR/2006/REC-xml-20060816/#NT-Char
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> "Kristian Spangsege" <kristian.spangsege@gmail.com> wrote on 01/21/2008
> 04:14:06 PM:
>
>
> > One more problem "from the same drawer":
> >
> > > String s = ""+(char)0xb;
> > > document.getDocumentElement().setAttributeNS(null, "bar", s);
> >
> > Otherwise same as previous test case.
> >
> > With the bundled Xalan serializer I get:
> >
> > > An invalid XML character (Unicode: 0xffffffff) was found in the
> > node's character data content.
> >
> > With the native deprecated serializer I get:
> >
> > > InvalidXMLCharInDOM: An invalid XML character (Unicode: 0xb) was
> > found in the DOM during normalization.
> >
> > Since this is a plain old vertical tab in both ASCII and Unicode, I
> > really don't see why there should be any problems in serializing it as
> > "&#11;". Please help understand this issue.
> >
> > Regards,
> > Kristian Spangsege
> >
> >
> > On Jan 21, 2008 5:11 PM, Kristian Spangsege
> > <kristian.spangsege@gmail.com> wrote:
> > > Hi,
> > >
> > > When using the Xalan serializer bundled with Xerces 2.9.1 I get a
> > > fatal error whenever an attribute value contains '<' (left angle
> > > bracket):
> > >
> > > > The value of attribute "bar" associated with an element type "foo"
> > > > must not contain the '<' character.
> > >
> > > I believe this is a bug since if I instead use the now deprecated
> > > native serializer of Xerces, I don't get the error. Also, the the "DOM
> > > Level 3 Core" specification under "setAttributeNS" says this:
> > >
> > > > So any markup (such as syntax to be recognized as an entity
> > > > reference) is treated as literal text, and needs to be appropriately
> > > > escaped by the implementation when it is written out.
> > >
> > >
> > > Here is my code:
> > >
> > > > DOMImplementationRegistry registry = DOMImplementationRegistry.
> > newInstance();
> > > >
> > > > DOMImplementation core = (DOMImplementation)registry.
> > getDOMImplementation("Core 3.0");
> > > > Document document = core.createDocument(null, "foo", null);
> > > > document.getDocumentElement().setAttributeNS(null, "bar", "<");
> > > >
> > > > DOMImplementationLS ls = (DOMImplementationLS)registry.
> > getDOMImplementation("LS 3.0");
> > > > LSSerializer serializer = ls.createLSSerializer();
> > > > serializer.getDomConfig().setParameter("error-handler", new
> > DOMErrorHandler()
> > > > {
> > > >   public boolean handleError(DOMError e)
> > > >   {
> > > >     System.err.println("Error: "+e.getMessage());
> > > >     return false;
> > > >   }
> > > > });
> > > > serializer.writeToString(document);
> > >
> > >
> > > Please let me know if this is required behaviour rather than a bug.
> > >
> > > Regards,
> > > Kristian Spangsege
> > >
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic