I'm looking for a way to have the XMLNS attribute propagate automatically from one XSL Template to another so I don't have to redeclare it each time.
Here's my situation. I'm trying to transform an XML file into an XHTML file using a XSLT file. My XML file is:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" encoding="UTF-8" href="car.xslt" version="1.0"?>
<vehicle>
<car>
<make>Honda</make>
<color>blue</color>
</car>
<car>
<make>Saab</make>
<color>red</color>
</car>
</vehicle>
My XSLT file is:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<table cellpadding="5" border="1">
<tr><td>make</td><td>color</td></tr>
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="car">
<tr xmlns="http://www.w3.org/1999/xhtml">
<td><xsl:value-of select="make"/></td><td><xsl:value-of select="color"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
In the XSLT file, I would like to just be able to say:
<xsl:template match="car">
<tr>
without having to redeclare the XMLNS. Any suggestions?