Anybody using 4suite for xslt processing?

Wade Leftwich wade at lightlink.com
Mon Jul 22 17:46:53 EDT 2002


"Marko Faldix" <mf at mrinfo.de> wrote in message news:<ah98hv$rfsrm$1 at ID-108329.news.dfncis.de>...
> Hi,
> 
> sometimes I think I am first man on earth want to process xslt.
> 
> I got python on windows 2000 Server with iis and 4suite, I could change to
> linux if necessary.
> 
> 
> The following script:
> 
> ###############################################
> 
> from Ft.Xml.Xslt import Processor
> 
> xslfilename = "abc.xsl"
> xmlfilename = "abc.xml"
> 
> path = "C:\\serverdirectory\\me\\python\\"
> 
> 
> xslfile = path+xslfilename
> xmlfile = path+xmlfilename
> 
> 
> processor = Processor.Processor()
> 
> processor.appendStylesheetUri(xslfile)
> 
> result = processor.runUri(xmlfile)
> 
> 
> print 'Content-type: text/html\n'
> print result
> 
> ###############################################
> 
> throws this in browser:
> 
> 
> ::: Using minidom
> Traceback (most recent call last):
>   File "C:\home\marko\python\bxslt.py", line 15, in ?
>     processor.appendStylesheetUri(xslfile)
> AttributeError: Processor instance has no attribute 'appendStylesheetUri'
> 
> 
> But documentation contains method 'appendStylesheetUri'. Somebody any idea?
> I am at the point that installation is ready and try to process our first
> xslt to see that it can be used for it.

I'm using 4xslt on win2k and it works well. However, the documentation
is lagging way behind the code, and it took me some groveling through
the 4suite mailing list before I could do this:

-----------
from Ft.Xml.Xslt import Processor
from Ft.Xml import InputSource

TRANSFORM = """<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template
  match="*|@*|comment()|processing-instruction()|text()">
  <xsl:copy>
    <xsl:apply-templates
     select="*|@*|comment()|processing-instruction()|text()"/>
  </xsl:copy>
</xsl:template>"""

processor = Processor.Processor()
transform = InputSource.DefaultFactory.fromString(TRANSFORM,
"http://okaynetwork.com/identity.xslt")
processor.appendStylesheet(transform)

def xform(s):
    source = InputSource.DefaultFactory.fromString(s,
"http://okaynetwork.com/doc.xml")
    return processor.run(source)

-------------------------

I believe Uche Ogbuji (Mr. 4Suite) has been updating the docs
recently, but I haven't had a chance to check out the changes.

However, if you are going to stay with Microsoft, their parser is
fast, fast, fast, and you can use it via Mark Hammond's extremely
excellent win32com module.

-- Wade Leftwich
Ithaca, NY



More information about the Python-list mailing list