[quoted text, click to view] BLechmann wrote:
> Yes, we're using .NET 1.1.
>
> I think the problem is, that the .NET XSL processor doesn't accept the
> use of variables/params, if they are declared later in the file.
No, it's way more convolute. Looks like XslTransform doesn't like
vars/params defined later when they are used in attribute context.
That's definitely a nasty bug.
Here is a repro:
<xsl:stylesheet version="1.0"
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"> <xsl:param name="bar">
<blah attr="{$foo}"/>
</xsl:param>
<xsl:param name="foo" select="'foo'"/>
<xsl:template match="/">
<xsl:copy-of select="$bar"/>
</xsl:template>
</xsl:stylesheet>
The same:
<xsl:stylesheet version="1.0"
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"> <xsl:param name="bar">
<blah>
<xsl:attribute name="attr">
<xsl:value-of select="$foo"/>
</xsl:attribute>
</blah>
</xsl:param>
<xsl:param name="foo" select="'foo'"/>
<xsl:template match="/">
<xsl:copy-of select="$bar"/>
</xsl:template>
</xsl:stylesheet>
The result of loading:
System.Xml.XPath.XPathException: The variable or param 'foo' is either
not defined or it is out of scope.
at System.Xml.XPath.VariableQuery.SetXsltContext(XsltContext context)
at System.Xml.XPath.StringFunctions.SetXsltContext(XsltContext context)
at System.Xml.XPath.CompiledXpathExpr.SetContext(XmlNamespaceManager
nsManager)
at System.Xml.Xsl.Processor.GetValueQuery(Int32 key)
at System.Xml.Xsl.AvtEvent.Output(Processor processor, ActionFrame
frame)
at System.Xml.Xsl.CopyCodeAction.Execute(Processor processor,
ActionFrame frame)
at System.Xml.Xsl.ActionFrame.Execute(Processor processor)
at System.Xml.Xsl.Processor.Execute()
at System.Xml.Xsl.XslTransform.Transform(IXPathNavigable input,
XsltArgumentList args, Stream output)
at GotDotNet.Exslt.ExsltTransform.Transform(IXPathNavigable ixn,
XsltArgumentList arglist, Stream stream)
at NXslt.NXslt.Process()
--
Oleg Tkachenko [XML MVP]