xsl-list
[Top] [All Lists]

Re: [xsl] Problem with ampersands

2006-09-26 07:17:20
If you have control over the original XML you can use 
<!CDATA[[  &  or &amp;  ]]>



--- andrew welch <andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com> wrote:

On 9/26/06, Jeff Sese <jsese(_at_)asiatype(_dot_)com> wrote:
Hi,

I have this requirement from a client to retain
all the entity
references in their xml files after transformation
so what i did was
collect all the entities in the DTD and then
created a character-map for
single-character entities. For multi-character
ones, i created a used a
function to search and replace all occurrences in
a text node. My
problem is when i use the function and return the
value, xslt escapes
the ampersand symbol as &amp; and i don't know how
i can unescape it
without unescaping the real ampersand character.

The client shouldn't care whether the characters are
entities or not
unless they plan on hand editing the files - once
the client parses
the XML you give them using an XML parser they won't
know whether the
characteres were represented on disk as entities,
character references
or the characters themselves - the information isn't
contained in the
infoset.  XSLT deals with infosets, which is why
what you are trying
to isn't possible without resorting to d-o-e or
extensions.

If you really must deliver XML with the entities in
place I would
suggest using a placeholder element (eg <entityA/>)
to represent it in
the output and the post process the result with a
suitable language to
replace the placeholder elements with the entity
references.

cheers
andrew


--~------------------------------------------------------------------
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>
--~--




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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>