I was afraid of this – as some of
the developers I am working with are not the brightest in the bunch… some
Yahoo had inexplicably included the ampersand in code that removed “invalid”
characters from our stream I was reading the XML from. I’ve since fixed
it. Thanks!
-----Original Message-----
From: Jesse Pelton
[mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 31, 2004
6:45 AM
To: [EMAIL PROTECTED]
Subject: RE: Less-than reserved
character sanity check...
I think I'm with you now.
I misunderstood the original message. You've got a file that includes a left
angle bracket in character data, which you've encoded as the character entity
"<". You use Xerces to parse the file, and the ampersand gets
lost at some point. I should have suggested the following in the first place:
- Try to reproduce the
problem with DOMPrint and a simple file.
- If you can reproduce
it, send the file to the list as an attachment.
- Tell us your
environment (Xerces version, OS, compiler, etc).
- If you can't reproduce
it, there's a bug somewhere in your code, which we may or may not be able to
help with.
From: Styduhar, Chris
[mailto:[EMAIL PROTECTED]
Sent: Monday, August
30, 2004 5:17 PM
To: [EMAIL PROTECTED]
Subject: RE: Less-than reserved
character sanity check...
I’m not appending a
text node with a “<” in it – I’m reading XML from a
file, putting it into a string (using the membuf) and sending it across a
network connection. Leaving the “<” in the XML causes the
parser to fail on the “parse” call, saying “element
expected” (it thinks I’m starting a new element with the
“<”). Any ideas?
-----Original Message-----
From: Jesse Pelton [mailto:[EMAIL PROTECTED]
Sent: Monday, August 30, 2004 2:50
PM
To: [EMAIL PROTECTED]
Subject: RE: Less-than reserved
character sanity check...
If you
append a text node (or set an attribute, depending on where you're storing you
field data) with a value like "1 < 3" and use DOMWriter to
serialize, what happens? A snippet of your code and a sample of your
output would probably be helpful.
From: Styduhar, Chris
[mailto:[EMAIL PROTECTED]
Sent: Monday, August 30, 2004 3:44
PM
To: [EMAIL PROTECTED]
Subject: RE: Less-than reserved
character sanity check...
Opening
the file in XMLSpy (or any other viewer) generally causes an error
though. I am using the DOMWriter but I can’t save the XML file (and
it won’t validate) with that “<” in the character data.
-----Original Message-----
From: Jesse Pelton
[mailto:[EMAIL PROTECTED]
Sent: Monday, August 30, 2004 2:32
PM
To: [EMAIL PROTECTED]
Subject: RE: Less-than reserved
character sanity check...
Assuming
you're letting Xerces do the serialization (by using DOMWriter, for instance),
just include '<' in your character data. Xerces translates characters into
the corresponding character entities as needed.
From: Styduhar, Chris
[mailto:[EMAIL PROTECTED]
Sent: Monday, August 30, 2004 3:16
PM
To: [EMAIL PROTECTED]
Subject: Less-than reserved
character sanity check...
I have an XML file which needs to
have a “<” (less than) character in a data field. I have
put the less-than character in the XML as “<” which is how
I’ve always done it. However – after Xerces parses the
document, the string is transformed into “lt;”… and the rest
of my software doesn’t handle that. Have I lost my mind? How
am I supposed to encode greater than and less than symbols?
Thanks,
Chris