I've been tinkering with this for too long and can't seem to find the answer anywhere -- or perhaps I don't know how to word the questions.
I have an XML file that represents a sitemap.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://...</loc>
<pagetitle>English</pagetitle>
<children>
<url>
<loc>http://...</loc>
<pagetitle>page title</pagetitle>
</url>
<children>
...
This XML represents a site map. I have written an XSLT to turn this into a hierarchical list.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" version="4.0"/>
<xsl:template match="/">
<ul><xsl:apply-templates /></ul>
</xsl:template>
<xsl:template match="url">
<li><a href="{loc}"><xsl:value-of select="pagetitle"/></a></li>
<xsl:apply-templates select="children"/>
</xsl:template>
<xsl:template match="children">
<ul><xsl:apply-templates select="url"/></ul>
</xsl:template>
</xsl:stylesheet>
This style sheet doesn't work when I have <urlset xmlns="..>
, but if I change the node to use just <xmlns>
(without the attribute) it works.
I am far from an XSLT guru. Anyone have a suggestion?