RE: how to translate entities with XSL

Subject: RE: how to translate entities with XSL
From: Chris Purvis <ChrisP@xxxxxxx>
Date: Thu, 8 Jun 2000 11:19:11 -0700
Mike Brown wrote:

>> I have an XML document with HTML embedded within the element attributes.
>>  An example of one of the elements would be:
>> 
>> <row html="example output&lt;BR&gt;">

>Bad form. Use XHTML in the element content.

><row>
>  <xhtml>example output<br/></xhtml>
></row>

I know this is probably bad form, but this is the way I get the xml.  There
isn't an easy way to change this.


Kay Michael wrote:

>> I am trying to use XSL to insert these chunks of HTML into an 
>> HTML document, however, I cannot figure out how to get the entities 
>> translated back into "<" and ">".  Any ideas on how to do this? 

>disable-output-escaping. And if your XSL processor doesn't support it,
>switch to one that does.

disable-output-escaping works if the symbols aren't already escaped in the
xml itself.  For instance, if I use the following xml and xsl, I get: 

output test <br/> this should be on the next line 

instead of: 

output test 
this should be on the next line 


xml: 

<?xml version="1.0"?> 
<xml> 
    <data1> 
         <row detail="output test &lt;br/&gt; this should be on the next
line"/> 
    </data1> 
</xml> 


xsl: 

<?xml version="1.0"?>  
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl";>; 

 <xsl:template match="/"> 
   <xsl:value-of select="xml/data1/row/@detail"
disable-output-escaping="yes"/> 
 </xsl:template> 

</xsl:stylesheet> 


Thanks!

ChrisP

---------------
Chris Purvis
Programmer
415 Productions
chrisp@xxxxxxx


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


Current Thread