[XML-SIG] using xslt with python

Jed Parsons jedp at ilm.com
Thu Jun 12 16:09:12 EDT 2003


Hi, Paul,

You can do something like this:

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

    document = InputSource.DefaultFactory.fromUri(xmlfile)
    stylesheet = InputSource.DefaultFactory.fromUri(xsltfile)
    # there's also a fromString() method
    
    processor = Processor()
    processor.appendStylesheet(stylesheet)
    result = processor.run(document)
    
Cheers,

j

Paul Tremblay writes:
> Can someone give me some instructins on how to process and xslt
> stylesheet with python?
> 
> I have written a script that translates plain text to docbook. Much of
> the script depends on xslt transformations.
> 
> Right now I use a bit of a hack:
> 
> command = 'xsltproc --param indent-amount %s %s %s > %s' % \
>                 (indent_amount, xsl_file, file, output)
>         os.system(command)
> 
> This only works on unix, and it only works if the user has xsltproc. I
> want to make the script useable for different platforms, and ideally for
> different xslt processors. For example, if the user wants to use xalan,
> then the script uses xalan to process the document.
> 
> thanks
> 
> Paul
> 
> -- 
> 
> ************************
> *Paul Tremblay         *
> *phthenry at earthlink.net*
> ************************
> 
> _______________________________________________
> XML-SIG maillist  -  XML-SIG at python.org
> http://mail.python.org/mailman/listinfo/xml-sig

-- 
    Jed Parsons | Industrial Light and Magic                    (415) 448-2974

                  use Curses;initscr;for(;;){$f=($f+10)%360;clear;grep(do{$i=$
                  _;for(($m,$n)=qw(cos sin)){s|.*|"int(($i-13)*$&($f*(atan2(1,
                  1)*4)/180))"|ee}addstr$m+11,$n+31,substr$s,$i,1},0..(length(
                  $s=unpack(qq'u',':2F5D)W, at 86YO=&AE<B!P97)L(&AA8VME<@')))-1);
                  CONFUSING: study each word & character; sleep 1 and refresh}



More information about the XML-SIG mailing list