xsl-list
[Top] [All Lists]

RE: [xsl] Issue with entities in XML document

2007-08-04 06:12:39
From the XML 1.0 recommendation document 
(http://www.w3.org/TR/2000/REC-xml-20001006):

"The ampersand character (&) and the left angle bracket (<) may appear in their 
literal form only when used as markup delimiters, or within a comment, a 
processing instruction, or a CDATA section. If they are needed elsewhere, they 
must be escaped using either numeric character references or the strings 
"&amp;" and "&lt;" respectively. The right angle bracket (>) may be represented 
using the string "&gt;", and must, for compatibility, be escaped using "&gt;" 
or a character reference when it appears in the string "]]>" in content, when 
that string is not marking the end of a CDATA section."

If your input document is as you described, it is not XML, and your XML parser 
is not behaving correctly in accepting the ampersand character rather than 
rejecting the document because the ampersand is not escaped.

The custom extension function is the piece that is behaving correctly, even if 
its behavior is not what you expect or want.
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Ramkumar Menon <ramkumar(_dot_)menon(_at_)gmail(_dot_)com>
Sent:     Fri, 3 Aug 2007 15:42:24 -0700
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  [xsl] Issue with entities in XML document

Hi gurus,

I have a question on entities.
The input document to my XSLT contains one element <description>Hansel
& Gretel</description>
After the XSLT transformation, it works fine <outputDescription>Hansel
& Gretel</outputDescription> Perfect.
Once I pass this resulting XML to an custom xpath extension function
that converts this xml to string, the output contains
<outputDescription>Handle &amp; Gretel</outputDescription>
Note the extra amp;
The xpath extension function does nothing but write the xml content
onto a java StringWriter object.
Is it an issue with the serializer ? Or is it an acceptable behaviour?
Any clues on how to prevent the second amp; to appear in the string output ?
i.e. once I write it to a string, the value should be
<outputDescription>Hansel & Gretel</outputDescription>


regards,
Ram


-- 
Shift to the left, shift to the right!
Pop up, push down, byte, byte, byte!

-Ramkumar Menon
 A typical Macroprocessor

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>