Groups | Blog | Home
all groups > dotnet xml > july 2004 >

dotnet xml : DocBook XSL and .NET XslTransform


specialagent.mulder NO[at]SPAM gmx.net
7/29/2004 11:27:37 PM
Hello *,

I'm trying to transform my DocBook document with the FO stylesheet
from the DocBook XSL distribution (the transformation with the XHTML
stylesheet works).

I changed "$years[1] + 1" to "number($years[1]) + 1" two times in
common.xsl. But the transformation doesn't work anyway. The funny
thing is, that if I use the msxsl command line utility there is no
problem. But when I use nxslt (or my own code) then I get the
following error.


<snip>
Error occurred while executing stylesheet
'c:\docbook\xsl\fo\docbook.xsl'.

System.Xml.XPath.XPathException: The variable or param
'monospace.font.family' 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()
</snip>


I googled for a solution but unlike with the number(...) thing I had
no luck - so any help is appreciated.

Best regards,
specialagent.mulder NO[at]SPAM gmx.net
8/1/2004 7:32:14 AM
[quoted text, click to view]

Hello Oleg,

thanks for your reply.

I'm not at work right now, but I think it is .NET 1.1 (we're using
VS.NET 2003). Just now I tried a transformation at home with nxslt
under .NET 1.1 with the same error.

Bye,
Oleg Tkachenko [MVP]
8/1/2004 12:22:32 PM
[quoted text, click to view]


[quoted text, click to view]

This is ole well-known bug. I though it's fixed in .NET 1.1? Which .NET
version you are using?

--
Oleg Tkachenko [XML MVP]
specialagent.mulder NO[at]SPAM gmx.net
8/2/2004 1:10:21 AM
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.

Is there a patch that fixes this behaviour?

Regards,
specialagent.mulder NO[at]SPAM gmx.net
8/2/2004 6:57:14 AM
[quoted text, click to view]

Is there a solution for this problem (a bug fix would be the best :-)?
I can't believe that we are the only persons who want to generate FO's
with .NET-XslTransform and DocBook-XSL.

Thanks,
Oleg Tkachenko [MVP]
8/2/2004 1:57:41 PM
[quoted text, click to view]

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]
Guest
5/3/2005 2:58:00 AM
This problem is fixed. The patch is available here:
http://alt-soft.com/support_kb_docbook_and_net_xsltransform.jsp

Best Regards,
Altsoft Xml2PDF
http://alt-soft.com/


[quoted text, click to view]

AddThis Social Bookmark Button