Questions tagged [saxon]

Saxon is an implementation of XSLT, XQuery, XPath, and XSD. In supports the latest W3C standards including XSLT 3.0, XQuery 3.1, XPath 3.1, and XSD 1.1. There are versions for Java, .NET, and C, in both open source and commercial editions. The latest addition to the product set is Saxon-JS, an XSLT runtime which will run in most browsers.

Saxon is a processor for the W3C languages XSLT, XPath, XQuery and XSD (XML Schema). It was originally created by Michael Kay and is now developed and maintained by Saxonica. There are open-source and commercial versions. Standards supported include XSLT 2.0/3.0, XPath 2.0/3.0/3.1, XQuery 1.0/3.0/3.1, XSD 1.0/1.1, and XQuery Update 1.0. (XSD based validation and XQuery Update as well as optional XSLT 3 features like streaming require a commercial version of the product, like the EE Enterprise edition for streaming in XSLT 3.0). The latest releases 11.6 and 12.3 with the commercial PE and EE editions also supports some experimental XPath 4, XSLT 4 and XQuery 4 extensions.

The product is developed in Java and runs on all standard Java platforms. In addition it has been cross-compiled to .NET, and to a native library with APIs for C/C++ as well as PHP and, in the Saxon/C 1.2 release and the recent SaxonC 11.6 release, a Cython based Python module implementation saxonc (https://www.saxonica.com/saxon-c/doc/html/saxonc.html), as well as with the new SaxonC 12 release directly as a Python wheel on PyPi: https://pypi.org/project/saxonche/. The latest release in the Saxon family is Saxon 12.3, developed on Java and transpiled to C# as SaxonCS 12.3 EE, a pure C# implementation of XSLT 3, XPath 3.1 and XQuery 3.1 for .NET 6, integrating it with new code to interface with the .NET 6 platform then compiled and built for .NET 6 using dotnet.

The Saxon-CE version was compiled to Javascript using GWT and runs in any browser. Saxon-CE is now obsolete; its replacement is Saxon-JS, which in its 1.x releases was only a native Javascript XSLT runtime, relying on the stylesheet first being prepared for execution using Saxon Enterprise Edition but since its 2.x releases supports XSLT 3.0 and XPath 3.1 both client-side in the browser as well as with Node.js, not requiring Saxon Enterprise Edition anymore to precompile an XSLT file to an SEF file but being able to do that on the fly calling the fn:transform XPath 3.1 function or in a pre-processing step using xslt3 on Node.js.

Please use this tag only if your question directly relates to the Saxon processor. If you enquire about XSLT, XQuery, XPath, or XSD in general (i.e. if your question is independent of a specific implementation), use tags XSLT, XQuery, XPath or XSD respectively, with a version number where appropriate.

Saxonica staff monitor this forum, but this is not an official way of requesting product support, and many excellent answers (and a few bad ones) come from users who have no connection with Saxonica. The fact that an answer is ticked means that the original poster found it helpful, it does not mean that the answer is endorsed by Saxonica. If you want to raise a support issue with Saxonica, use http://saxonica.plan.io/

External links:

1825 questions
8
votes
2 answers

Handling infinite recursion XSL in Saxon

I understand this question might be beyond Saxon and more related to the architecture of the application using it for transformations, but just wanted to give a try. Consider the following files- XML
Vinit
  • 1,815
  • 17
  • 38
8
votes
5 answers

Saxon XPath API returns TinyElementImpl instead of org.w3c.dom.Node

I have the following code: // xpath evaluates to net.sf.saxon.xpath.XPathEvaluator XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression expression = xpath.compile("/foo/bar"); Object evaluate = expression.evaluate(someXML,…
Eran Medan
  • 44,555
  • 61
  • 184
  • 276
8
votes
4 answers

Call Java instance methods in XSLT

I am using Saxon (I could use Xalan if necessary) XSLT processor to do some transformation. I want to pass the instance of below object to the XSLT template as parameter. public class Test { private String value; public Test(String v) { …
Zyga
  • 2,367
  • 3
  • 22
  • 32
8
votes
2 answers

Using Xalan alongside Saxon

I use Xalan in my application, but need to use Saxon with a reference implementation to generate test output to compare with. I want to use them both during unit tests. However, as soon as I add an dependency on Saxon in the project .pom, the…
Danik
  • 404
  • 3
  • 14
8
votes
4 answers

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

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…
james.garriss
  • 12,959
  • 7
  • 83
  • 96
7
votes
1 answer

How to convert text to date, then get year value?

Need to convert a text value `2012-03-19' into a date type, then extract the year component. I'm using Saxon 2.0, but it's…
raffian
  • 31,267
  • 26
  • 103
  • 174
7
votes
2 answers

Making saxon-c available in Python

I have just read that Saxon is now available for Python, and that's just great fun and good, but can anyone write a tutorial on how to make it available for Python/Anaconda/WingIDE or similar? I am used to installing with pip or conda, and pointing…
Zug_Bug
  • 186
  • 10
7
votes
3 answers

How do I get EXSLT support in Saxon-HE?

I have a bunch of XSLT files that I need to process against some XML files. I cannot change the XSLT files as they come from a 3rd party. The XSLT's are version 2.0. I'm on Mac OS X 10.6 and it looks like Saxon-HE is the only XSLT 2.0 processor…
jordelver
  • 8,292
  • 2
  • 32
  • 40
7
votes
1 answer

"Content is not allowed in prolog" error yet nothing before XML declaration

First of all I have already exhaustively checked the following questions and this issue does not seem to be the same thing: SAXParseException: Content is not allowed in prolog org.xml.sax.SAXParseException: Content is not allowed in prolog “Content…
user9645
  • 6,286
  • 6
  • 29
  • 43
7
votes
1 answer

base-uri function in schematron for validating xml probatron + saxon

We used probatron and saxon to validate a test xml using a given sch file in our java application. Recently, a new rule has been added to the sch file such as and some rules use that value, but $foo contains…
benchpresser
  • 2,171
  • 2
  • 23
  • 41
7
votes
4 answers

XSLT: moving a grouping html elements into section levels

I'm trying to write an XSLT that organizes an HTML file into different section levels depending on the header level. Here is my input:

HEADER 1 CONTENT

Level 1 para

Level 1…

Jeff
  • 877
  • 2
  • 11
  • 17
7
votes
2 answers

Howto refer dynamically to an XML file in XQuery in Saxon

I am using the XQuery processor Saxon. Now we write our XQuery in a ".xqy" file where we refer to the XML file on which we will perform our XQuery. Please see the example below: for $x in doc("books.xml")/books/book where $x/price>30 return…
Rahul ray
  • 191
  • 1
  • 4
  • 12
7
votes
1 answer

xslt:message in Saxon - where is the message?

I use Saxon XSLT version 9.6.0.1. A stylesheet contains this code: ... errormessage ... My application terminates as expected with this exception: net.sf.saxon.expr.instruct.TerminationException:…
Queeg
  • 7,748
  • 1
  • 16
  • 42
7
votes
0 answers

(Limited) Java extension function support in XSLT

I've long made do with the default XML libraries provided by Java (Xerces2-J and Xalan-J) - occasionally and directly using the latest versions of those libraries when needed. It appears I'm running up against some of the limits of these libraries…
ziesemer
  • 27,712
  • 8
  • 86
  • 94
7
votes
6 answers

XSLT 2.0 PHP support. When?

What are the chances to see XSLT 2.0 processors like saxon for php in the nearest future?
Dziamid
  • 11,225
  • 12
  • 69
  • 104