Re: How to preserve a node's value containing escaped text (' an d " in particular)?

Subject: Re: How to preserve a node's value containing escaped text (' an d " in particular)?
From: Mike Brown <mike@xxxxxxxx>
Date: Fri, 26 May 2000 16:33:53 -0600 (MDT)
> Given the following input XML:
> 
> <InputText>&lt; &gt; &amp; &apos; &quot;</InputText>

The entity references will be resolved by the XML parser before the XSLT
processor sees them. The source tree will look something like:

root
  |___element: InputText
         |___text: < > & ' "

> I was hoping to get the following output:
> 
> <OutputText>&lt; &gt; &amp; &apos; &quot;</OutputText>
>
> Instead, I get:
> 
> <OutputText>&lt; &gt; &amp; ' "</OutputText>

Why were you hoping to get the entity references? It makes no difference.
The document you are producing, if XML or HTML, is a stream of bytes that
represent a physical sequence of UCS characters that in turn represent an
underlying sequence of abstract UCS characters. It is the underlying
sequence that is the essence of your document; parsed general entity
references are part of the physical layer and do not change the meaning of
the document as far as an XML or HTML application is concerned.

When you copy the text node containing markup characters to the result
tree with your stylesheet, and the XSLT processor serializes it with an
output method, the XSLT processor will decide how to escape the markup
characters for the chosen output method. You do not have any control over
this process, nor should you need to, for a case like this. I think the
only place where &quot; and &apos; need to be used in XML and HTML is when
' or " appear in an attribute value that is also delimited by those
characters.

   - Mike
___________________________________________________________
Mike J. Brown, software engineer, Webb Interactive Services
XML/XSL stuff: http://www.skew.org/    http://www.webb.net/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread