p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

xslt thread: disable-output for special characters


Message #1 by "BrianL" <BrianLeary@h...> on Wed, 11 Jul 2001 21:35:51
> Hi,
> I am having trouble diabling output for special characters 

I looked into this briefly and I found that you have to be careful with 
the value of <xsl:output method="xml|text|html"> when dealing with how 
encoded characters are treated. 

Annette.

Example: same input XML, but different output methods, produce different 
results:

XML input:
----------
<?xml version="1.0"?>
<test>
&
</test>

STYLESHEET 1 (output=xml):
--------------------------
<?xml version="1.0"?>
<xsl:stylesheet	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.0">
<xsl:output method="xml" />   
   <xsl:template match="test">
   <xsl:copy-of select="." />
   </xsl:template>
</xsl:stylesheet>

Output:
-------
<?xml version="1.0" encoding="UTF-8"?><test>
&
</test>

STYLESHEET 2 (output=text):
---------------------------
<?xml version="1.0"?>
<xsl:stylesheet	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.0">
<xsl:output method="text" />   
   <xsl:template match="test">
   <xsl:copy-of select="." />
   </xsl:template>
</xsl:stylesheet>

Output:
-------
<test>
&
</test>

  Return to Index