[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSLT and python

Subject: XSLT and python
From: Alessandro Maraschini <alessandro.maraschini@xxxxxxxxxx>
Date: Tue, 03 Oct 2006 16:36:57 +0200
xslt python
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 

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.