A
Anonymous
If I set as output method to HTML, it does what I want.
<html>
<body>
<p>
<a href="mailto:[email protected]">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:john_doe&#64;example.com">John 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>[email protected]</email>
</person>
</people>
people.xsl
----------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="application/xml"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput 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="substring-before(email,'@')"/>
<xsl:variable name="hostname" select="substring-after(email,'@')"/>
<p>
<a>
<xsl:attribute name="href">
<xsl:value-of select="$protocol"/>:<xsl:value-of
select="$username"/>
<!-- original try
<xsl:text>&</xsl:text><xsl:text>#64;</xsl:text>
-->
<xsl:text disable-output-escaping="yes">
<![CDATA[@]]>
</xsl:text>
<xsl:value-of select="$hostname"/>
</xsl:attribute>
<xsl:value-of select="name"/>
</a>
</p>
</xsl:template>
</xsl:stylesheet>
<html>
<body>
<p>
<a href="mailto:[email protected]">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:john_doe&#64;example.com">John 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>[email protected]</email>
</person>
</people>
people.xsl
----------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="application/xml"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput 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="substring-before(email,'@')"/>
<xsl:variable name="hostname" select="substring-after(email,'@')"/>
<p>
<a>
<xsl:attribute name="href">
<xsl:value-of select="$protocol"/>:<xsl:value-of
select="$username"/>
<!-- original try
<xsl:text>&</xsl:text><xsl:text>#64;</xsl:text>
-->
<xsl:text disable-output-escaping="yes">
<![CDATA[@]]>
</xsl:text>
<xsl:value-of select="$hostname"/>
</xsl:attribute>
<xsl:value-of select="name"/>
</a>
</p>
</xsl:template>
</xsl:stylesheet>