[4suite] XSL Node-set parameter lost?
nico
nicolas.marsgui at libertysurf.fr
Fri Nov 3 12:10:16 MST 2006
Hello,
I use 4suite XML 1.0 to compile some docbook files, and have some troubles
when using some node-sets in template parameters. The original XSL file is
heavily stripped here to show the problem.
The troublesome is when I do something like this, where the colspec param
passed to the row template is a node-set:
<xsl:template match="row" mode="newtbl">
<xsl:param name="colspec"/>
<xsl:variable name="entries">
<xsl:copy-of select="entry"/>
</xsl:variable>
<i>
<xsl:value-of select="count($colspec/*)"/>
</i>
<xsl:apply-templates select="exsl:node-set($entries)" mode="newtbl">
<xsl:with-param name="colspec" select="$colspec"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="entry|entrytbl" mode="newtbl">
<xsl:param name="colspec"/>
<e>
<xsl:value-of select="count($colspec/*)"/>
</e>
</xsl:template>
It crashes when trying to execute the entry template, meaning that
$colspec is not seen as a node-set:
: Built-in template invoked with params that will be ignored. This message
willonly appear once per transform.
self.warning(MessageSource.BUILTIN_TEMPLATE_WITH_PARAMS)
Traceback (most recent call last):
File "4xslt.py", line 52, in ?
main()
File "4xslt.py", line 49, in main
run(sys.argv[1], sys.argv[2], sys.argv[3])
File "4xslt.py", line 45, in run
rc = proc.run(xml, outputStream=o)
File "/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/Processor.py",
line 393, in run
writer, outputStream)
File "/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/Processor.py",
line 722, in execute
self.applyTemplates(context)
File "/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/Processor.py",
line 754, in applyTemplates
if not self.stylesheet.applyTemplates(context, self, params):
File "/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/Stylesheet.py",
line584, in applyTemplates
template.instantiate(context, processor, params)
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/TemplateElement.py",line
83, in instantiate
child.instantiate(context, processor)
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/LiteralElement.py",
line 99, in instantiate
child.instantiate(context, processor)
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/ApplyTemplatesElement.py",
line 78, in instantiate
processor.applyTemplates(context, with_params)
File "/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/Processor.py",
line 754, in applyTemplates
if not self.stylesheet.applyTemplates(context, self, params):
File "/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/Stylesheet.py",
line584, in applyTemplates
template.instantiate(context, processor, params)
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/TemplateElement.py",line
83, in instantiate
child.instantiate(context, processor)
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/ApplyTemplatesElement.py",
line 78, in instantiate
processor.applyTemplates(context, with_params)
File "/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/Processor.py",
line 754, in applyTemplates
if not self.stylesheet.applyTemplates(context, self, params):
File "/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/Stylesheet.py",
line584, in applyTemplates
template.instantiate(context, processor, params)
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/TemplateElement.py",line
83, in instantiate
child.instantiate(context, processor)
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/ApplyTemplatesElement.py",
line 78, in instantiate
processor.applyTemplates(context, with_params)
File "/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/Processor.py",
line 769, in applyTemplates
self.applyTemplates(context)
File "/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/Processor.py",
line 754, in applyTemplates
if not self.stylesheet.applyTemplates(context, self, params):
File "/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/Stylesheet.py",
line584, in applyTemplates
template.instantiate(context, processor, params)
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/TemplateElement.py",line
83, in instantiate
child.instantiate(context, processor)
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/LiteralElement.py",
line 99, in instantiate
child.instantiate(context, processor)
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/ValueOfElement.py",
line 27, in instantiate
text = Conversions.StringValue(self._select.evaluate(context))
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/AttributeInfo.py",
line 421, in evaluate
raise RuntimeError(MessageSource.EXPRESSION_POSITION_INFO % (
RuntimeError: In stylesheet
file:///usr/home/ben/project/docbook/db2tex/dblatex/entmap/small2.xsl,
line 31, column 4 in "count($colspec/*)":
Lower-level traceback:
Traceback (most recent call last):
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/Xslt/AttributeInfo.py",
line 396, in evaluate
return self.expression.evaluate(context)
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/XPath/ParsedExpr.py", line
242, in evaluate
arg0 = self._arg0.evaluate(context)
File
"/usr/local/lib/python2.4/site-packages/Ft/Xml/XPath/ParsedExpr.py", line
470, in evaluate
type(left).__name__)))
TypeError: $colspec must be a node-set, not a string
If instead of applying templates on a node-set built from the $entries
variable the entry elements are used, it works fine:
<xsl:template match="row" mode="newtbl">
<xsl:param name="colspec"/>
<xsl:variable name="entries">
<xsl:copy-of select="entry"/>
</xsl:variable>
<i>
<xsl:value-of select="count($colspec/*)"/>
</i>
<!--
<xsl:apply-templates select="exsl:node-set($entries)" mode="newtbl">
-->
<xsl:apply-templates select="exsl:node-set(entry)" mode="newtbl">
<xsl:with-param name="colspec" select="$colspec"/>
</xsl:apply-templates>
</xsl:template>
Please find attached the XSL stylesheet and an XML file example that
reproduce the problem. I hope you can help. JFYI it works fine with
xsltproc.
Regards,
BG
-------------- next part --------------
A non-text attachment was scrubbed...
Name: small2.xsl
Type: application/octet-stream
Size: 1308 bytes
Desc: not available
Url : http://lists.fourthought.com/pipermail/4suite/attachments/20061103/c2f1b829/small2.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smalltbl.xml
Type: text/xml
Size: 190 bytes
Desc: not available
Url : http://lists.fourthought.com/pipermail/4suite/attachments/20061103/c2f1b829/smalltbl.bin
More information about the 4suite
mailing list