I am trying to use XSL to transform two XML files into HTML. I have everything working, but I have a problem. One of the XML files contains assorted bits of information that I am pulling from. There are no namespace declarations anywhere in the file, but nodes that I need to access are namespace prefixed. My original fix was to add the namespaces to the root node, but I found out I can't do that as the files can't be modified.
If I leave the namespaces off, I get the following in Firefox:
XML Parsing Error: prefix not bound to a namespace
The namespaces should be (but don't exist in the source XML):
xmlns:prop="http://www.blank.com/prop"
xmlns:item="http://www.blank.com/item"
How do I solve this?
XML:
<?xml version="1.0" encoding="UTF-8"?>
<collection>
<prop:id>123</prop:id>
<document>
<item:name>Document</item:name>
</document>
</collection>
XSL: (neither of the value-of elements work)
<?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"/>
<xsl:variable name="propsPath" select="test_Props.xml"/>
<xsl:variable name="props" select="document($propsPath)" />
<xsl:template match="/">
<html><body><div>
<xsl:value-of select="$props/collection/*[local-name() = 'id']"/>
<xsl:value-of select="$props/collection/prop:id"/>
</div></body></html>
</xsl:template>
</xsl:stylesheet>