D
Doug Farrell
Hi all,
I'm trying to use the 4Suite xml/xsl tools to transform some XML data
into HTML. I'm using some examples from the O'Reilly book "Python and
XML" and things are blowing up. Here is the little piece of code I'm
working on:
from xml.xslt.Processor import Processor
proc = Processor()
xsl = """<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html><body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Title</th>
<th align="left">Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body></html>
</xsl:template>
</xsl:stylesheet>
"""
# here comes the problem
proc.appendStylesheetString(xsl)
I'm not even getting to the transformation part, just trying to load
the xsl stylesheet. I've run the above xsl code, along with my xml
data though the command line 4xslt and it works fine. When I run the
line of Python code immediately above, I get a tracedump from Python
that looks like this:
Traceback (most recent call last):
File "/var/www/html/python/xslttest.py", line 44, in ?
proc.appendStylesheetString(xsl)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Processor.py",
line 124, in appendStylesheetString
sty = self._styReader.fromString(text, baseUri)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/StylesheetReader.py",
line 570, in fromString
return pDomletteReader.PyExpatReader.fromString(self,st,
refUri='', ownerDoc=None, stripElements=None)
File "/usr/lib/python2.2/site-packages/Ft/Lib/ReaderBase.py", line
67, in fromString
rt = self.fromStream(stream, refUri, ownerDoc, stripElements)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/StylesheetReader.py",
line 622, in fromStream
sheet.setup()
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Stylesheet.py",
line 140, in setup
self._setupChildNodes()
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Stylesheet.py",
line 183, in _setupChildNodes
curr_node.setup()
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/TemplateElement.py",
line 46, in setup
namespaces=self._nss
File "/usr/lib/python2.2/site-packages/_xmlplus/xpath/Util.py", line
83, in ExpandQName
split_name = (nss[prefix], local)
KeyError
I'm at a loss as to what to do and where to go from here. I'm running
Python 2.2.2 on a RedHat 9.0 system and I downloaded and installed
4Suite 1.0.* from www.4suite.org (though I don't think that was
necessary).
If anyone has some suggestions what I'm doing wrong, I'd very very
glad to hear them. Thanks in advance,
Doug Farrell
I'm trying to use the 4Suite xml/xsl tools to transform some XML data
into HTML. I'm using some examples from the O'Reilly book "Python and
XML" and things are blowing up. Here is the little piece of code I'm
working on:
from xml.xslt.Processor import Processor
proc = Processor()
xsl = """<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html><body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Title</th>
<th align="left">Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body></html>
</xsl:template>
</xsl:stylesheet>
"""
# here comes the problem
proc.appendStylesheetString(xsl)
I'm not even getting to the transformation part, just trying to load
the xsl stylesheet. I've run the above xsl code, along with my xml
data though the command line 4xslt and it works fine. When I run the
line of Python code immediately above, I get a tracedump from Python
that looks like this:
Traceback (most recent call last):
File "/var/www/html/python/xslttest.py", line 44, in ?
proc.appendStylesheetString(xsl)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Processor.py",
line 124, in appendStylesheetString
sty = self._styReader.fromString(text, baseUri)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/StylesheetReader.py",
line 570, in fromString
return pDomletteReader.PyExpatReader.fromString(self,st,
refUri='', ownerDoc=None, stripElements=None)
File "/usr/lib/python2.2/site-packages/Ft/Lib/ReaderBase.py", line
67, in fromString
rt = self.fromStream(stream, refUri, ownerDoc, stripElements)
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/StylesheetReader.py",
line 622, in fromStream
sheet.setup()
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Stylesheet.py",
line 140, in setup
self._setupChildNodes()
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/Stylesheet.py",
line 183, in _setupChildNodes
curr_node.setup()
File "/usr/lib/python2.2/site-packages/_xmlplus/xslt/TemplateElement.py",
line 46, in setup
namespaces=self._nss
File "/usr/lib/python2.2/site-packages/_xmlplus/xpath/Util.py", line
83, in ExpandQName
split_name = (nss[prefix], local)
KeyError
I'm at a loss as to what to do and where to go from here. I'm running
Python 2.2.2 on a RedHat 9.0 system and I downloaded and installed
4Suite 1.0.* from www.4suite.org (though I don't think that was
necessary).
If anyone has some suggestions what I'm doing wrong, I'd very very
glad to hear them. Thanks in advance,
Doug Farrell