Use saxon with python

╄→尐↘猪︶ㄣ 提交于 2019-11-27 04:32:32

问题


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?


回答1:


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




回答2:


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

https://github.com/ajelenak/pysaxon




回答3:


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:


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



来源:https://stackoverflow.com/questions/29443364/use-saxon-with-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!