python and xslt problems

christof hoeke csad7 at yahoo.com
Sat Dec 28 08:23:00 EST 2002


hi,
thanks for all the help, i did not expect so much reactions...
(by the way, i did not want to hack on everyone's lack in documentation, i
know that this is sometimes the least important thing after something works
or is in development, sorry for this.)

i was mainly interested in information about maybe more and more up to date
books or tutorials, i read the ones on oreillynet by which are really good,
also the pages on uche.ogbuji.net.

that is also the reason i did not post any details of my problems because
they are partly due to the fact that i started my first project with python
only last week (i read books and did some tests but had no real project to
do).
the project i am working on is a xsldoc app in python, to generate something
similar to javadoc for xslt stylesheets. i know the xsldoc java app which is
really good, but to learn more about python and its xml/xsl processing i
want to rewrite this in python.



well my problem is with the example from
http://uche.ogbuji.net:8080/uche.ogbuji.net/tech/akara/pyxml/ :

#The identity transform: duplicates the input to output
TRANSFORM = """<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>
</xsl:stylesheet>
"""
#And I don't even like Monty Python, folks
SOURCE1 = """<spam id="eggs">What do you mean "bleah"</spam>"""
SOURCE2 = """<spam id="eggs">I don't like spam</spam>"""

from Ft.Xml.Xslt import Processor
processor = Processor.Processor()
from Ft.Xml import InputSource
transform = InputSource.DefaultFactory.fromString(TRANSFORM,
"http://spam.com/identity.xslt")
processor.appendStylesheet(transform)

#Now the processor is prepped with a transform and ccan be used
#over and over for the same transform
source = InputSource.DefaultFactory.fromString(SOURCE1,
"http://spam.com/doc1.xml")
result1 = processor.run(source)
source = InputSource.DefaultFactory.fromString(SOURCE2,
"http://spam.com/doc2.xml")
result2 = processor.run(source)
--------------------
what does the second arg in InputSource.DefaultFactory.fromString do? as i
understand the method it takes the first string arg and sets it as a source
for the following transformation.

--------------------
running on python 2.2.2 with installed Foursuite 0.12.0a2 (and pyXML 0.8.1)
yields these error messages:

python xsltest.py
::: Using minidom
Traceback (most recent call last):
  File "xsltest.py", line 29, in ?
    result1 = processor.run(source)
  File "I:\python\lib\site-packages\Ft\Xml\Xslt\Processor.py", line 119, in
run
    src = self._docReader.parse(iSrc)
  File "I:\python\lib\site-packages\Ft\Xml\Domlette.py", line 65, in parse
    return self.parseMethod(inputSource)
  File "I:\python\lib\site-packages\Ft\Xml\FtMiniDom\NonvalReader.py", line
83,
in nonvalParse
    return r.fromSrc(src)
  File "I:\python\lib\site-packages\Ft\Xml\FtMiniDom\NonvalReader.py", line
29,
in fromSrc
    self.parse(source)
  File "I:\python\lib\site-packages\Ft\Xml\FtMiniDom\NonvalReader.py", line
49,
in parse
    self.parser.ParseFile(source.stream)
  File "I:\python\lib\site-packages\Ft\Xml\FtMiniDom\Handler.py", line 186,
in s
tartElement
    attr = self.Attr(attr_qname, attr_ns, attr_local, attr_prefix)
  File "I:\python\lib\site-packages\Ft\Xml\FtMiniDom\Nodes.py", line 95, in
__in
it__
    self.appendChild(Text(''))
TypeError: this constructor takes no arguments


Do i have a type anywhere, or the wrong packages installed that maybe are
not working together?
thanks for any hint!

chris





More information about the Python-list mailing list