Re: [xsl] Converting markup to non-markup

Subject: Re: [xsl] Converting markup to non-markup
From: Mike Brown <mike@xxxxxxxx>
Date: Thu, 12 Sep 2002 07:50:08 -0600 (MDT)
Lars Eskildsen wrote:
> I want to be able to convert an XML snippet like:
> 
> <CONV_TAG>
>     <TAG1 ATTR1="VAL1">Statement: 4 &lt; 5</TAG1>
> <CONV_TAG>
> 
> to this XML code:
> 
> <CONVERTED_TAG>
>    &lt;TAG1 ATTR1=&quot;VAL1&quot;&gt;Statement: 4 &amp;lt; 5&lt;/TAG1&gt;
> </CONVERTED_TAG>

Have a look at http://www.xmlportfolio.com/xml-to-string/

Note that it is a FAQ on this list that converting the output back into
a node-set or copying it to output without escaping, can be quite difficult.

> The problem is i want to convert standard entities inside non-markup content. 
> 
> &lt;	to 	&lt;lt;
> &gt;	to 	&gt;gt;
> &amp;	to	&amp;amp; 

I don't think that's really what you meant. (&lt;lt; should be &amp;lt;, 
right?)  Regardless, you must understand that this in your XML, in the content
of an element...

  Statement: 4 &lt; 5

...is reported by an XML parser (to the XSLT processor) as the character data

  Statement: 4 < 5

You have no access to the lexical details like entity references and character 
references, just like you have no access to the fact that attribute values 
might be quoted with " in some cases and ' in others. (Another FAQ)


   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

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


Current Thread