I'm transforming a document from one XML schema to another using MSXML 4.0. One of the elements in the stylesheet has a namespace reference in the element node. The value of this node is populated with <xsl:value-of >. When executing the transform, I get a parse error: "value-of not allowed in this context".
Source document (investments.xml)
<?xml version="1.0"?>
<investments>
<item type="stock" exch="nyse" symbol="ZCXM" company="zacx corp"
price="28.875"/>
<item type="stock" exch="nasdaq" symbol="ZFFX" company="zaffymat inc"
price="92.250"/>
<item type="stock" exch="nasdaq" symbol="ZYSZ" company="zysmergy inc"
price="20.313"/>
</investments>
Stylesheet(portfolio.xsl)
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=" version="1.0">
<xsl
utput method="xml" indent="yes"/>
<xsl:template match="/">
<portfolio xmlns:dt="urn:schemas-microsoft-com:datatypes">
<xsl:for-each select="investments/item[@type='stock']">
<stock>
<xsl:attribute name="exchange">
<xsl:value-of select="@exch"/>
</xsl:attribute>
<name><xsl:value-of select="@company"/></name>
<symbol><xsl:value-of select="@symbol"/></symbol>
<price><xsl:value-of select="@price"/></price>
<!--
This line is from the original MSXML 4.0 SDK docs,
but causes an error: "value-of not allowed in this context".
Removing the namespace declaration resolves the problem.
<price dt:dt="number"><xsl:value-of select="@price"/></price>
-->
</stock>
</xsl:for-each>
</portfolio>
</xsl:template>
</xsl:stylesheet>
Why would the "dt" namespace have any effect on the transform? It's in the static text of the template!
BTW - This came from the MSXML 4.0 SDK docs. Search for 'Translating from One XML Schema to Another'.
Source document (investments.xml)
<?xml version="1.0"?>
<investments>
<item type="stock" exch="nyse" symbol="ZCXM" company="zacx corp"
price="28.875"/>
<item type="stock" exch="nasdaq" symbol="ZFFX" company="zaffymat inc"
price="92.250"/>
<item type="stock" exch="nasdaq" symbol="ZYSZ" company="zysmergy inc"
price="20.313"/>
</investments>
Stylesheet(portfolio.xsl)
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=" version="1.0">
<xsl
<xsl:template match="/">
<portfolio xmlns:dt="urn:schemas-microsoft-com:datatypes">
<xsl:for-each select="investments/item[@type='stock']">
<stock>
<xsl:attribute name="exchange">
<xsl:value-of select="@exch"/>
</xsl:attribute>
<name><xsl:value-of select="@company"/></name>
<symbol><xsl:value-of select="@symbol"/></symbol>
<price><xsl:value-of select="@price"/></price>
<!--
This line is from the original MSXML 4.0 SDK docs,
but causes an error: "value-of not allowed in this context".
Removing the namespace declaration resolves the problem.
<price dt:dt="number"><xsl:value-of select="@price"/></price>
-->
</stock>
</xsl:for-each>
</portfolio>
</xsl:template>
</xsl:stylesheet>
Why would the "dt" namespace have any effect on the transform? It's in the static text of the template!
BTW - This came from the MSXML 4.0 SDK docs. Search for 'Translating from One XML Schema to Another'.