Use saxon with python

2019-01-23 21:23发布

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?

3条回答
Animai°情兽
2楼-- · 2019-01-23 21:26

A Python interface for Saxon/C is in development and worth a look:

https://github.com/ajelenak/pysaxon

查看更多
地球回转人心会变
3楼-- · 2019-01-23 21:33

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"])
查看更多
劳资没心,怎么记你
4楼-- · 2019-01-23 21:50

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

查看更多
登录 后发表回答