468,549 Members | 2,323 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,549 developers. It's quick & easy.

4Suite and XSLT problems

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
Jul 18 '05 #1
1 1727
uc**@ogbuji.net (Uche Ogbuji) wrote in message news:<d1**************************@posting.google. com>...

Your answers are here:

http://uche.ogbuji.net/tech/akara/no...-01/basic-xslt
http://www.xml.com/pub/a/2002/12/11/py-xml.html

--Uche
http://uche.ogbuji.net


Uche,

Thank you very much for the response, that is a big help to me and
I'll try and implement your suggestions. I'll post back here to let
you know of my success.

Again, thanks!
Doug
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Sergio del Amo | last post: by
2 posts views Thread by Doug Farrell | last post: by
8 posts views Thread by Ola Natvig | last post: by
4 posts views Thread by Ringo Langly | last post: by
2 posts views Thread by Elmo Mäntynen | last post: by
4 posts views Thread by Asbjørn Ulsberg | last post: by
10 posts views Thread by daz_oldham | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.