Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use saxon with python

I need to process XSLT using python, currently I'm using lxml which only support XSLT 1, now I need to process XSLT 2 is there any way to use saxon XSLT processor with python?

like image 793
Maliq Avatar asked Apr 04 '15 06:04

Maliq


3 Answers

There are two possible approaches:

  1. set up an HTTP service that accepts tranformation requests and implements them by invoking Saxon from Java; you can then send the transformation requests from Python over HTTP

  2. use the Saxon/C product, currently available on prerelease: details here: http://www.saxonica.com/saxon-c/index.xml

like image 192
Michael Kay Avatar answered Nov 15 '22 08:11

Michael Kay


Saxon/C release 1.2.0 is now out with XSLT 3.0 support for Python3 see details:

http://www.saxonica.com/saxon-c/index.xml

like image 36
ond1 Avatar answered Nov 15 '22 06:11

ond1


At the moment there is not, but you could use the subprocess module to use the Saxon processor:

import subprocess

subprocess.call(["saxon", "-o:output.xml", "-s:file.xml", "file.xslt"])
like image 5
Bruno Avatar answered Nov 15 '22 06:11

Bruno