[Newbie] A problem while trying Xsl transformation with 4Suite
David
dsoulayrol at free.fr
Tue Apr 22 10:01:47 EDT 2003
Hi,
I'm quite new to Python, and I'd like to use it to apply some XSL
transformations to XML Documents. I first had a look at PyXML, but I
had problems, and I read here some messages suggesting the use of
4XSLT.
Then I installed it. I wrote this little program to test it :
-----
from Ft.Xml.InputSource import DefaultFactory
from Ft.Xml.Domlette import ValidatingReader
from Ft.Xml.Xslt.Processor import Processor
lProc = Processor()
lSheet = DefaultFactory.fromUri('file:../../xsl/page.xsl')
lDoc = DefaultFactory.fromUri('file:file.xml')
lProc.appendStylesheet(lSheet)
result = lProc.run(iSrc = lDoc, outputStream = open('out.html', 'w'))
-----
It works very well... but not at all when I have a <!DOCTYPE ... >
declaration in the header of my XML documents. For example, this
document is correctly transformed :
------
<?xml version="1.0" encoding="ISO-8859-15"?>
<article>
<title>Accès non autorisé</title>
<section>
<para>
Vous n'êtes pas le bienvenue sur cette page. Ouste ! Du balai !
...
</para>
</section>
</article>
------
... whereas this one :
------
<?xml version="1.0" encoding="ISO-8859-15"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<the rest is the same>
------
... will fail with this error :
Traceback (most recent call last):
File "tXslt.py", line 13, in ?
result = lProc.run(iSrc = lDoc, outputStream = open('out.html',
'w'))
File "/usr/lib/python2.2/site-packages/Ft/Xml/Xslt/Processor.py",
line 150, in run
raise XsltException(Error.SOURCE_PARSE_ERROR, iSrc.uri or '<Python
string>', e)
Ft.Xml.Xslt.XsltException: Source document (file:error404.xml): cannot
concatenate 'str' and 'NoneType' objects
Can someone please help ?
David.
More information about the Python-list
mailing list