[4suite] problem using xml.xslt.Processor
Calvin Smith
calvins at sims.berkeley.edu
Sun Aug 25 19:25:10 MDT 2002
----- Original Message -----
From: "Uche Ogbuji" <uche.ogbuji at fourthought.com>
To: "Calvin Smith" <calvins at sims.berkeley.edu>
Cc: "4Suite list" <4suite at lists.fourthought.com>
Sent: Sunday, August 25, 2002 7:07 AM
Subject: Re: [4suite] problem using xml.xslt.Processor
<snipped-old-stuff/>
> uogbuji at malatesta:~/devel/4Suite$ grep ERROR
> Ft/Xml/Xslt/StylesheetReader.py
> raise XsltException(Error.STYLESHEET_PARSE_ERROR,
> self._baseUri,
> raise XsltException(Error.STYLESHEET_PARSE_ERROR, src.uri,
>
> Oh. A ha!
>
> I should have looked for the obvious.
>
> Do *not* use xml.xslt. Use Ft.Xml.Xslt.
>
> See
>
> http://uche.ogbuji.net/tech/akara/pyxml/python-xslt/
>
> For a walk-through of how to use XSLT from python
>
> You might want to browse through
>
> http://uche.ogbuji.net/tech/akara/pyxml/
>
> In general.
Thanks for your help. Switching to Ft.Xml.Xslt seems to have eliminated
that problem, but now I get another error. I followed your page on
python-xslt and modeled my code accordingly, but I get the following error
now:
06:02:25 d:/python/src/version5 :: python quotesSearch.py
::: Using minidom
Traceback (most recent call last):
File "quotesSearch.py", line 31, in ?
main(['10', '100', '200', '300', '400', '500'])
File "quotesSearch.py", line 24, in main
print xsltproc.run(source)
File "C:\PYTHON22\Lib\site-packages\Ft\Xml\Xslt\Processor.py", line 119,
in run
src = self._docReader.parse(iSrc)
File "C:\PYTHON22\Lib\site-packages\Ft\Xml\Domlette.py", line 65, in parse
return self.parseMethod(inputSource)
File "C:\PYTHON22\Lib\site-packages\Ft\Xml\FtMiniDom\NonvalReader.py",
line 83, in nonvalParse
return r.fromSrc(src)
File "C:\PYTHON22\Lib\site-packages\Ft\Xml\FtMiniDom\NonvalReader.py",
line 29, in fromSrc
self.parse(source)
File "C:\PYTHON22\Lib\site-packages\Ft\Xml\FtMiniDom\NonvalReader.py",
line 49, in parse
self.parser.ParseFile(source.stream)
File "C:\PYTHON22\Lib\site-packages\Ft\Xml\FtMiniDom\Handler.py", line
186, in startElement
attr = self.Attr(attr_qname, attr_ns, attr_local, attr_prefix)
File "C:\PYTHON22\Lib\site-packages\Ft\Xml\FtMiniDom\Nodes.py", line 95,
in __init__
self.appendChild(Text(''))
TypeError: this constructor takes no arguments
The code that I am using is as follows:
#!/usr/bin/env python
# quotesSearch.py
import sys, cgi
from xml.sax import make_parser
from quoteHandler import QuotationHandler, QuotationErrorHandler
from Ft.Xml.Xslt.Processor import Processor, InputSource
def main(IDNumbers):
ch = QuotationHandler()
ch.setQuoteNumbers(IDNumbers)
erh = QuotationErrorHandler()
saxparser = make_parser()
saxparser.setContentHandler(ch)
saxparser.setErrorHandler(erh)
saxparser.parse("foo3.xml")
xsltproc = Processor()
transform = InputSource.DefaultFactory.fromUri("quoteTransform.xsl",
"http://sims.berkeley.edu/~calvins/quotes")
source =
InputSource.DefaultFactory.fromString(ch.xmlQuotes.encode("UTF-8"),
"http://sims.berkeley.edu/~calvins/quotes")
xsltproc.appendStylesheet(transform)
print xsltproc.run(source)
if __name__ == '__main__':
main([10, 100, 200, 300, 400, 500])
I also get the same error message when I try to run your code from
http://uche.ogbuji.net/tech/akara/pyxml/python-xslt/ (the last example on
the page), so I guess something is still not right with my installation. Is
this error message familiar to anybody?
thanks,
calvin
More information about the 4suite
mailing list