First, I've been through Dave Pawson's excellent collection of namespace related information. If the answer to my question is in there.. I missed it.
I'm using Saxon9.0.06J, although I have OxygenXML 11, so there is a newer Saxon in there if I can figure out how to use from the command line.
I am writing a stylesheet to transform one XML file into another with a different schema. I need namespaces, including a default namespace, on the result XML file, so I've added them to the stylesheet so they will be declared in the result file. But, this is causing me problems.
I've boiled down the problem to as simple form as I can get it.
The Stylesheet:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
xmlns="http://MyDefaultNS"
>
<!--
xmlns="http://MyDefaultNS">
We need the default namespace decl in the stylesheet element
so it will appear on the root element decl of the result file and put the default NS in scope for the result document. This is needed so it will pass validation against the schema.
-->
<xsl:template match="/">
<xsl:text>
Test of Subtree
</xsl:text>
<xsl:variable name="testST">
<SubElem1>
Value for Sub Element 1
</SubElem1>
<SubElem2>
Value for Sub Element 2
</SubElem2>
</xsl:variable>
<xsl:value-of select="$testST/SubElem1"></xsl:value-of>
</xsl:template>
</xsl:stylesheet>
The problem is, value of $testST/SubElem1 is not returning anything.
I use these subtrees throughout my stylesheet to pre-process things and
none of it works since I added the default 'xmlns' statement to the stylesheet declaration.
If I remove the default NS decl, then I get "Value for Sub Element 1" as expected from the 'value-of' statement.
What did adding this default NS statement do to my stylesheet?
Thanks!