[Newbie] A problem while trying Xsl transformation with 4Suite

David dsoulayrol at free.fr
Tue Apr 22 16:01:47 CEST 2003


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

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')
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"?>
  <title>Accès non autorisé</title>
      Vous n'êtes pas le bienvenue sur cette page. Ouste ! Du balai !

... whereas this one :

<?xml version="1.0" encoding="ISO-8859-15"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"

 <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',
  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 ?

More information about the Python-list mailing list