You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Thomas Börkel <tb...@ap-ag.com> on 2002/03/04 13:38:10 UTC
Bad bug in handling of extra spaces
HI!
Xerces (tested with current build) handles formatting spaces as elements of type text.
Example 1:
xml = "<root>\r\n <p0><![CDATA[abc]]></p0>\r\n <p1><![CDATA[xyz]]></p1>\r\n</root>";
Example 2:
xml = "<root><p0><![CDATA[abc]]></p0><p1><![CDATA[xyz]]></p1></root>";
The 2 examples produce 2 different DOMs! The first one produces an incorrect DOM.
You can test it with this code:
Document doc;
DocumentBuilderFactory dbf;
DocumentBuilder db;
dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setValidating(true);
dbf.setAttribute("http://apache.org/xml/features/validation/dynamic", new Boolean(true));
dbf.setAttribute("http://apache.org/xml/features/validation/schema", new Boolean(true));
db = dbf.newDocumentBuilder();
doc = db.parse(new InputSource(new StringReader(xml)));
System.out.println(doc.getDocumentElement().getFirstChild().toString());
This should print out the <p0> tag. But in example 1, it prints out a text element.
Is this bug known? Is there a workaround?
Thanks!
Regards,
Thomas
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
RE: Bad bug in handling of extra spaces
Posted by Julian Reschke <ju...@gmx.de>.
It isn't a bug at all.
"formatting spaces" are whitespace and thus are reported as text nodes.
> -----Original Message-----
> From: Thomas Börkel [mailto:tb@ap-ag.com]
> Sent: Monday, March 04, 2002 1:38 PM
> To: Xerces Mailinglist
> Subject: Bad bug in handling of extra spaces
>
>
> HI!
>
> Xerces (tested with current build) handles formatting spaces as
> elements of type text.
>
> Example 1:
> xml = "<root>\r\n <p0><![CDATA[abc]]></p0>\r\n
> <p1><![CDATA[xyz]]></p1>\r\n</root>";
>
> Example 2:
> xml = "<root><p0><![CDATA[abc]]></p0><p1><![CDATA[xyz]]></p1></root>";
>
> The 2 examples produce 2 different DOMs! The first one produces
> an incorrect DOM.
>
>
> You can test it with this code:
> Document doc;
> DocumentBuilderFactory dbf;
> DocumentBuilder db;
>
> dbf = DocumentBuilderFactory.newInstance();
> dbf.setNamespaceAware(true);
> dbf.setValidating(true);
>
> dbf.setAttribute("http://apache.org/xml/features/validation/dynami
> c", new Boolean(true));
>
> dbf.setAttribute("http://apache.org/xml/features/validation/schema
> ", new Boolean(true));
> db = dbf.newDocumentBuilder();
> doc = db.parse(new InputSource(new StringReader(xml)));
>
> System.out.println(doc.getDocumentElement().getFirstChild().toString());
>
>
> This should print out the <p0> tag. But in example 1, it prints
> out a text element.
>
> Is this bug known? Is there a workaround?
>
> Thanks!
>
> Regards,
> Thomas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org