saxon

namespace-unaware XPath expression fails if Saxon is on the CLASSPATH

坚强是说给别人听的谎言 提交于 2019-12-05 09:23:09
I have the following sample XML file: <a xmlns="http://www.foo.com"> <b> </b> </a> Using the XPath expression /foo:a/foo:b (with 'foo' properly configured in the NamespaceContext ) I can correctly count the number of b nodes and the code works both when Saxon-HE-9.4.jar is on the CLASSPATH and when it's not. When, however, I parse the same file with a namespace- unaware DocumentBuilderFactory , the XPath expression "/a/b" correctly counts the number of b nodes only when Saxon-HE-9.4.jar is not on the CLASSPATH. Code below: import java.io.*; import java.util.*; import javax.xml.xpath.*; import

How can I format a decimal in xquery?

二次信任 提交于 2019-12-05 06:11:35
I'm trying to format decimals in XQuery. The decimals are currency, so the format should be ,###.## . For example: 5573652.23 should be 5,573,652.23 and 352769 should be 352,769 (or 352,769.00 if it's easier/cleaner) Right now I'm using this function from http://www.xqueryhacker.com/2009/09/format-number-in-xquery/ , but I can't use decimals with it: declare function local:format-int($i as xs:int) as xs:string { let $input := if ($i lt 0) then fn:substring(fn:string($i), 2) else fn:string($i) let $rev := fn:reverse(fn:string-to-codepoints(fn:string($input))) let $comma := fn:string-to

Saxon 9 XSLT transformer vs Xalan 2.7

◇◆丶佛笑我妖孽 提交于 2019-12-05 05:25:27
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. 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.0 processor, but it is very actively developed and

How do I get EXSLT support in Saxon-HE?

青春壹個敷衍的年華 提交于 2019-12-05 04:46:15
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 available. Most of the XSLT's work fine, however, some give errors regarding missing functions, specifically month-in-year() and other date/time related functions. According to http://www.saxonica.com/documentation/extensions/exslt.xml regarding EXSLT: These extensions are available in Saxon-PE and Saxon-EE "out of the box". They are not available in

Saxon error with XSLT import statement

狂风中的少年 提交于 2019-12-05 03:52:42
The Saxon processor gives me an error whenever I have an XSLT import statement. Here is the error: XTSE0165: I/O error reported by XML parser processing file: shared/test.xslt (The system cannot find the path specified): Here is how my XSLT document looks like: <?xml version='1.0' encoding='UTF-8'?> <xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:fn='http://www.w3.org/2005/02/xpath-functions' xmlns:xs='http://www.w3.org/2001/XMLSchema' > <xsl:import href="shared/test.xslt"/> ... My java code TransformerFactory transformerFactory = TransformerFactoryImpl

Saxon 9.2 / Java / XSLT: setting transformer parameters using setParameters()

跟風遠走 提交于 2019-12-04 21:16:13
I have the following XSLT 2.0 template: <xsl:template name="t1"> <xsl:variable name="totalpos" as="xsd:double" select="$currentTotal"/> .. I am struggling to programmatticaly provide currentTotal as a parameter to the transformer, like this: transformer.setParameter("currentTotal", new Double("100")) .. but without any positive results: Error at /xsl:transform/xsl:template[3]/xsl:variable[1] XPST0008: XPath syntax error at char 13 on line -1 in {$currentTotal}: Variable $currentTotal has not been declared When calling setParameter() , the currentTotal variable will also get defined, right? How

How can I call jQuery-UI components from a browser side XSL rendering of HTML using Saxon-JS?

那年仲夏 提交于 2019-12-04 20:03:28
All mainstream browsers still support XSLT for rendering HTML from XML using XSLT, although most only support XSLT 1.0. Version 2.0 and some 3.0 can be used via Saxon-JS. The advent of popular Javascript libraries for rendering HTML (I happen to use jQuery-UI), not only produces the visual HTML, but connects the components to event listeners for behavior. I would like the best of both worlds. I would like to send XML to the browser to be rendered via XSL, but for interactive components, I would like to call the jQuery-UI renderer from my XSL. Is this doable from an XSLT extension? Will the

XALAN register Extension Function like in SAXON

[亡魂溺海] 提交于 2019-12-04 19:47:39
i want to transform a XML by XSLT with XALAN. Now i want to use a extension-function, this function have to be added in JAVA source like in SAXON: Method: TransformerFactory tFactory = TransformerFactory.newInstance(); Configuration c = ((net.sf.saxon.TransformerFactoryImpl) tFactory).getConfiguration(); c.registerExtensionFunction(new FooExtension()); FooExtension: public class FooExtension extends ExtensionFunctionDefinition { private static final long serialVersionUID = -8143237239412146617L; @Override public SequenceType[] getArgumentTypes() { return new SequenceType[] { SequenceType.EMPTY

Running custom Java functions within XSLT and SAXON (9.1.8)

一曲冷凌霜 提交于 2019-12-04 19:19:59
Meta Saxon XSLT processor (v. 9.1.8) Java XSLT 2.0 I got a simple example of a java class file and some xsl transformation. My goal is to run my custom java functions from the class file within the XSLT process (via SAXON). How is this possible? When I start the below described batch file the cmd displays an error calling me the function is not known to saxon. So I have to add my class to the Java / or Saxon CLASSPATH? The transformation should copy all XML data and (return &) display the dimension of imagefiles. My XSL Transformation <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL

Apache Camel Xpath 2.0 with Saxon does not look to work in RouteBuilder / Predicates

筅森魡賤 提交于 2019-12-04 17:21:50
I am using ServiceMix 4.5.3 which includes Camel 2.10.7 and I am able to make XSLT 2.0 transformations with the Saxon library using the option endpoint like this: ... to("xslt:stylesheet.xsl?transformerFactoryClass=net.sf.saxon.TransformerFactoryImpl") ... However when I try to use the xpath function like this: private Namespaces ourNS = new Namespaces("myns", "urn:com:company:domain:namespace:myns/1"); // ... some code ... // Make a predicate to filter according a header : // The code attribute looks like: urn:phone:apple:iphone:4s Predicate isNotSamePhoneBrand = PredicateBuilder.isNotEqualTo