XSLT 2.0 / HTML: Issue with adding "href" attribute in <a> element
857840Apr 26 2011 — edited Apr 26 2011Hi All,
I'm trying to convert one old XSQL project from XSLT 1.0 to XSLT 2.0 and facing with the strange issue:
If source XSQL file is:
<?xml version="1.0" encoding='UTF-8'?>
<?xml-stylesheet type="text/xsl" href="test1.xsl" ?>
<page xmlns:xsql="urn:oracle-xsql">
<record>
<title>Test</title>
<link>http://my.link/test.html</link>
</record>
</page>
and transformation (test1.xsl file) is like:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8"/>
<!-- Root template -->
<xsl:template match="/">
<html>
<header>
<title>Test 1</title>
</header>
<body>
<xsl:for-each select="/page/record">
<a href="{link}"><xsl:value-of select="title"/></a>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
it does NOT produce any output (serialization).
The output can be archieved ONLY if at least one of following changes is done to the stylesheet:
1. XSLT 1.0 is used:
i.e.: <xsl:stylesheet version="2.0" ... --> <xsl:stylesheet version="1.0" ...
2. Output method is NOT html / xhtml
i.e.: <xsl:output method="html" --> ...<xsl:output method="xml" ...
3. Element <a> is replaces with element of any other name
i.e.: <a href="{link}"><xsl:value-of select="title"/></a> --> <a1 href="{link}"><xsl:value-of select="title"/></a1>
4. Attribute "href" of element <a> is removed or renamed
i.e.: <a href="{link}"><xsl:value-of select="title"/></a> --> <a href1="{link}"><xsl:value-of select="title"/></a>, or <a><xsl:value-of select="title"/></a>
This example was build using Oracle JDeveloper 11.1.1.0.0 and oracle.xdk_11.1.1
Does someone faced with the similar issue and what was the solution? Please share...
BR,
Sergey