[XML-SIG] python and XSLT
Alessandro Maraschini
alessandro.maraschini at datamat.it
Tue Oct 3 16:53:23 CEST 2006
Hi all,
I am using python2.2 and trying to convert an xml document into a plain
text using a stylesheet and using python standard xmlplus package.
While the stylesheet perfectly works with a similar approach in cpp, I'm
facing a problem in python when parsing some "range" values:
here follows the piece of code inside the stylesheet regarding range
values:
[...]
<!-- LowerBoundedRange types -->
<xsl:template match="jsdl:LowerBoundedRange">
<xsl:param name="VARNAME"/>
<xsl:value-of select="$VARNAME"/>
<xsl:choose>
<xsl:when test="@jsdl:exclusiveBound='true'">
<xsl:text> > </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> >= </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="."/>
</xsl:template>
[...]
and here the piece of code where the exception arises:
[...]
processor = Processor()
processor.appendStylesheetUri(xsltFile)
processor.runUri(jsdlFile)
here the exception I get:
[grid] /home/maraska/Jsdl/python > ./jsdl.py jsdl2jdl.xslt
jsdl_rask.xml
Traceback (most recent call last):
File "./jsdl.py", line 58, in ?
print jsdl.applyXSLT()
File "./jsdl.py", line 45, in applyXSLT
return self.processor.runUri(self.jsdlFile)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Processor.py",
line 175, in runUri
writer, uri, outputStream)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Processor.py",
line 283, in execute
self.applyTemplates(context, None)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Processor.py",
line 304, in applyTemplates
found = sty.applyTemplates(context, mode, self, params)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Stylesheet.py",
line 452, in applyTemplates
template.instantiate(context, processor, params)
File
"/usr/lib/python2.2/site-packages/_xmlplus/xslt/TemplateElement.py",
line 117, in instantiate
context = child.instantiate(context, processor)[0]
File
"/usr/lib/python2.2/site-packages/_xmlplus/xslt/ApplyTemplatesElement.py", line 86, in instantiate
processor.applyTemplates(context, mode, params)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Processor.py",
line 304, in applyTemplates
found = sty.applyTemplates(context, mode, self, params)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Stylesheet.py",
line 452, in applyTemplates
template.instantiate(context, processor, params)
File
"/usr/lib/python2.2/site-packages/_xmlplus/xslt/TemplateElement.py",
line 117, in instantiate
context = child.instantiate(context, processor)[0]
File
"/usr/lib/python2.2/site-packages/_xmlplus/xslt/ForEachElement.py", line
64, in instantiate
child.instantiate(context, processor)[0]
File
"/usr/lib/python2.2/site-packages/_xmlplus/xslt/ApplyTemplatesElement.py", line 86, in instantiate
processor.applyTemplates(context, mode, params)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Processor.py",
line 304, in applyTemplates
found = sty.applyTemplates(context, mode, self, params)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Stylesheet.py",
line 452, in applyTemplates
template.instantiate(context, processor, params)
File
"/usr/lib/python2.2/site-packages/_xmlplus/xslt/TemplateElement.py",
line 117, in instantiate
context = child.instantiate(context, processor)[0]
File
"/usr/lib/python2.2/site-packages/_xmlplus/xslt/ApplyTemplatesElement.py", line 86, in instantiate
processor.applyTemplates(context, mode, params)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Processor.py",
line 304, in applyTemplates
found = sty.applyTemplates(context, mode, self, params)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Stylesheet.py",
line 452, in applyTemplates
template.instantiate(context, processor, params)
File
"/usr/lib/python2.2/site-packages/_xmlplus/xslt/TemplateElement.py",
line 117, in instantiate
context = child.instantiate(context, processor)[0]
File
"/usr/lib/python2.2/site-packages/_xmlplus/xslt/ValueOfElement.py", line
40, in instantiate
result = self._expr.evaluate(context)
File "/usr/lib/python2.2/site-packages/_xmlplus/xpath/ParsedExpr.py",
line 95, in evaluate
expanded[0], expanded[1])
xml.xpath.RuntimeException: Variable undefined: ("None", "VARNAME").
Any chance you have got an idea? Thank you in advance for your support!
cheers,
Alessandro
--
-----
Alessandro Maraschini
Grid R&D Group
Government and Institutions Division
DATAMAT S.p.A. - a Finmeccanica company
Via Laurentina, 760  I - 00143 Rome  Italy
http://www.datamat.it
mailto: alessandro.maraschini at datamat.it
phone: +39 06 5027 4501 (direct)
+39 06 5027 2211 (secretary)
fax: +39 06 5027 4330
More information about the XML-SIG
mailing list