Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] XSLT and python

From: Alessandro Maraschini <alessandro.maraschini@---------->
To:
Date: 10/3/2006 2:37:00 PM
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> &gt; </xsl:text>
    </xsl:when>
    <xsl:otherwise>
       <xsl:text> &gt;= </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 B- I - 00143 Rome B- Italy
http://www.datamat.it

mailto: alessandro.maraschini@xxxxxxxxxx
phone:    +39 06 5027 4501 (direct)  
          +39 06 5027 2211 (secretary)
fax:      +39 06 5027 4330


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent