I'm doing the parsing through JDom which uses the Xerces parser. By the
result I mean that after the parsing job, I get an XML element in memory,
named STTM, that contains the text "&" instead of just an ampersand &.
The strange thing is that if I use any other name than STTM for the
element I get the correct result, namely only the ampersand. So, assume I
would like to parse the following XML:
<ROOT>
<STTM>&</STTM>
<sttm>&</sttm>
</ROOT>
When I parse this XML and print the output I get something like this:
Element='ROOT'
Element='STTM', Text='&'
Element='sttm', Text='&'
This is no normal behaviour according to me!?! The same goes for < and
>, ' and " are handled correctly:
<ROOT>
<STTM>&'"<></STTM>
<sttm>&'"<></sttm>
</ROOT>
results in:
Element='ROOT'
Element='STTM', Text='&'"<>'
Element='sttm', Text='&'"<>'
I already changed to using the latest version of Xerces (2.5.0) but it
made no changes. Any ideas, suggestions, ... ??
Thanks,
Steven.
Elena Litani <[EMAIL PROTECTED]>
25/09/2003 17:06
Please respond to xerces-j-user
To: [EMAIL PROTECTED]
cc:
Subject: Re: Element <STTM> weird behaviour ...
[EMAIL PROTECTED] wrote:
> I get some strange things when I try to parse the next XML with the
Xerces
> parser:
>
> <STTM>&</STTM>
>
> The result is <STTM>&</STTM> (just the same) instead of
<STTM>&</STTM>.
The '<' and '&' characters must be escaped in character data using
predefined entities [1].
What do you mean by "the result"? Are you parsing using DOM/SAX and
looking at the document in memory? Are you using serializer (which one?)
and this is what you see in the output?
By definition, serializer must escape '<' and '&' characters. However,
other predefined entities (>, ', and ") maybe be used by
the serializer.
[1] http://www.w3.org/TR/REC-xml#character-data
Thank you,
--
Elena Litani / IBM Toronto
---------------------------------------------------------------------
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]