saxon

Saxon in Java: XSLT for CSV to XML

别说谁变了你拦得住时间么 提交于 2019-12-04 01:49:08
问题 Mostly continued from this question: XSLT: CSV (or Flat File, or Plain Text) to XML So, I have an XSLT from here: http://andrewjwelch.com/code/xslt/csv/csv-to-xml_v2.html And it converts a CSV file to an XML document. It does this when used with the following command on the command line: java -jar saxon9he.jar -xsl:csv-to-xml.csv -it:main -o:output.xml So now the question becomes: How do I do I do this in my Java code? Right now I have code that looks like this: TransformerFactory

Find all namespace declarations in an XML document - xPath 1.0 vs xPath 2.0

孤街醉人 提交于 2019-12-03 08:46:20
问题 As part of a Java 6 application, I want to find all namespace declarations in an XML document, including any duplicates. Edit : Per Martin's request, here's the Java code I am using: XPathFactory xPathFactory = XPathFactory.newInstance(); XPath xPath = xPathFactory.newXPath(); XPathExpression xPathExpression = xPathExpression = xPath.compile("//namespace::*"); NodeList nodeList = (NodeList) xPathExpression.evaluate(xmlDomDocument, XPathConstants.NODESET); Suppose I have this XML document: <

Saxon 9 XSLT transformer vs Xalan 2.7

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am currently using Xalan 2.7.0 for XSLT transformations over XML, but thinking over to switch to Saxon 9 version for XSLT transformations. So could someone list me the major cons and prons of using Saxon over Xalan . Although i know that Saxon supports XSLT 2.0 and other major changes but instead i would like to know more about personal experiences with Saxon 9 and its prons and cons and other benefits. 回答1: I used Xalan 10 years ago. I have been using Saxon almost exclusively for the last 10 years. Not only is Saxon an XSLT 2.0 and XSLT 3

How to use saxon built-in catalog feature

匿名 (未验证) 提交于 2019-12-03 02:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I downloaded SaxonHE9-4-0-6J and want to process XHTML on CLI. However Saxon tries to load DTD from W3C and it takes too much time for every simple command. I have xml catalog, which I use successfully with xmllint by set env variable pointing to catalog file, but I have no idea how to make Saxon use it. Google reveals whole history of changes (thus confusion) in regards of using catalogs with Saxon, and none made me happy. I downloaded resolver.jar and set it in my CLASSPATH, but I can't make Saxon use it. After various combinations, I

Use saxon with python

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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: 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 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

How to select saxon TransformerFactory in Java

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my web application I need to use Saxon TransformerFactory in order to use XSLT 2.0 but I can't use setProperty method because I don't have this right on the web server and there is a Security Manager. So I have read that it should be possible to do this: Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The Services API will look for a classname in the file META-INF/services/javax.xml.transform.TransformerFactory in jars available to the runtime. I found this file in WEB-INF/lib/saxon9

Using Saxon .NET XSLT processor does not work with intellisense in Visual Studio

匿名 (未验证) 提交于 2019-12-03 01:21:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using the open source Saxon XSLT processor for .NET to execute some 2.0 transforms. I reference the saxon9api.dll as I would any other dll, and can compile code against this. However Visual Studio does not show any intellisense making the IDE as useful as notepad. The saxon9api.dll is using the IKVM Java for .NET platform, and I wonder if this is the causing VS a problem. Reflector can inspect the DLL without issue, but I suspect VS is not happy for some reason. Any ideas? EDIT: Surprised that no one else has encountered this behaviour

Why does Saxon evaluate the result-document URI to be the same?

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My XSL source document looks like this <Topology> <Environment> <Id>test</Id> <Machines> <Machine> <Id>machine1</Id> <modules> <module>m1</module> <module>m2</module> </modules> </Machine> </Machines> </Environment> <Environment> <Id>production</Id> <Machines> <Machine> <Id>machine1</Id> <modules> <module>m1</module> <module>m2</module> </modules> </Machine> <Machine> <Id>machine2</Id> <modules> <module>m3</module> <module>m4</module> </modules> </Machine> </Machines> </Environment> </Topology> I want to create one result-document per

Parse an XML fragment stored in a string into nodes in XSLT with SAXON for Java

匿名 (未验证) 提交于 2019-12-03 00:59:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my XSLT, I have a variable which contains a string. This string contains a fragment of XML. This is coming in programmatically, but its the equivalent of this: <xsl:variable name="xmlfrag" select="'<foo>this <bar>is</bar> it</foo>'"/> Is there a way to parse this XML and add it to the output? We're using SAXON for Java. 回答1: Use the saxon:parse() extension function . 回答2: The Dimitre solution requires a licensed version of Saxon. Here is another solution that works also with the free version of Saxon. I've tried it successfully with Saxon

Trying to sort a node set from Saxon

↘锁芯ラ 提交于 2019-12-02 09:55:25
To sort a query in Saxon we first run the query: XPathExecutable exe = xPath.compile(query); XPathSelector selector = exe.load(); selector.setContextItem(xmlDocument); XdmValue nodeSet = selector.evaluate(); // put the results in an array ArrayList<XdmItem> nodes = new ArrayList<XdmItem>(); for (int i = 0; i < nodeSet.size(); i++) nodes.add(nodeSet.itemAt(i)); // Sort the results sortNodes(nodes, "RiskLevel", false, false); private void sortNodes(ArrayList<XdmItem> nodes, final String sortKey, final boolean sortIsAttr, boolean descending) { Comparator comparator = new Comparator() { public int