If I set as output method to HTML, it does what I want.
<html>
<body>
<p>
<a href="mailto:jo hn_doe@exam ple.com">John Doe</a>
</p>
</body>
</html>
If I set it to XHTML, it doesn't but I need to generate XHTML.
<?xml version="1.0" encoding="UTF-8"?>
<html>
<body>
<p>
<a href="mailto:jo hn_doe&#64; example.com">Jo hn Doe</a>
</p>
</body>
</html>
Using Xalan/J 2.5.2 for transformation if it matters...
people.xml
---------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<people>
<person id="john">
<name>John Doe</name>
<email>john_doe @example.com</email>
</person>
</people>
people.xsl
----------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="applicati on/xml"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xhtml"/> <!-- CHANGE HERE TO HTML -->
<xsl:template match="people">
<html>
<body>
<xsl:apply-templates select="person"/>
</body>
</html>
</xsl:template>
<xsl:template match="person">
<xsl:variable name="protocol" select="'mailto '"/>
<xsl:variable name="username" select="substri ng-before(email,'@ ')"/>
<xsl:variable name="hostname" select="substri ng-after(email,'@' )"/>
<p>
<a>
<xsl:attribut e name="href">
<xsl:value-of select="$protoc ol"/>:<xsl:value-of
select="$userna me"/>
<!-- original try
<xsl:text>& </xsl:text><xsl:t ext>#64;</xsl:text>
-->
<xsl:text disable-output-escaping="yes">
<![CDATA[@]]>
</xsl:text>
<xsl:value-of select="$hostna me"/>
</xsl:attribute>
<xsl:value-of select="name"/>
</a>
</p>
</xsl:template>
</xsl:stylesheet>
<html>
<body>
<p>
<a href="mailto:jo hn_doe@exam ple.com">John Doe</a>
</p>
</body>
</html>
If I set it to XHTML, it doesn't but I need to generate XHTML.
<?xml version="1.0" encoding="UTF-8"?>
<html>
<body>
<p>
<a href="mailto:jo hn_doe&#64; example.com">Jo hn Doe</a>
</p>
</body>
</html>
Using Xalan/J 2.5.2 for transformation if it matters...
people.xml
---------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<people>
<person id="john">
<name>John Doe</name>
<email>john_doe @example.com</email>
</person>
</people>
people.xsl
----------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="applicati on/xml"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xhtml"/> <!-- CHANGE HERE TO HTML -->
<xsl:template match="people">
<html>
<body>
<xsl:apply-templates select="person"/>
</body>
</html>
</xsl:template>
<xsl:template match="person">
<xsl:variable name="protocol" select="'mailto '"/>
<xsl:variable name="username" select="substri ng-before(email,'@ ')"/>
<xsl:variable name="hostname" select="substri ng-after(email,'@' )"/>
<p>
<a>
<xsl:attribut e name="href">
<xsl:value-of select="$protoc ol"/>:<xsl:value-of
select="$userna me"/>
<!-- original try
<xsl:text>& </xsl:text><xsl:t ext>#64;</xsl:text>
-->
<xsl:text disable-output-escaping="yes">
<![CDATA[@]]>
</xsl:text>
<xsl:value-of select="$hostna me"/>
</xsl:attribute>
<xsl:value-of select="name"/>
</a>
</p>
</xsl:template>
</xsl:stylesheet>
Comment