Saxonica Developer Community: Issueshttps://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2024-02-27T09:32:05ZSaxonica Developer Community
Planio Saxon - Bug #6361 (In Progress): XPath parser continously looping to find Xpath function library ...https://saxonica.plan.io/issues/63612024-02-27T09:32:05ZManikandan S
<ul>
<li>I am trying to load a custom library of XPath functions in my project using a custom build jar. However when the function is called to load the XPath functions i get redirected to XPathParser.java class which is present in the package net.sf.saxon.expr.parser, where a function is called - reportMissingFunction which consist of the following loop and it never exits this loop even though it could not find the a particular XPath function.</li>
<li>Jar file is located in classpath under JVM_PARAMS, Xpath function is able to find that jar from classPath.</li>
</ul>
<pre><code class="java syntaxhl" data-language="java"> <span class="k">if</span> <span class="o">(</span><span class="n">config</span><span class="o">.</span><span class="na">getBooleanProperty</span><span class="o">(</span><span class="nc">Feature</span><span class="o">.</span><span class="na">ALLOW_EXTERNAL_FUNCTIONS</span><span class="o">))</span> <span class="o">{</span>
<span class="kt">boolean</span> <span class="n">existsWithDifferentArity</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="k">for</span><span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">arguments</span><span class="o">.</span><span class="na">length</span> <span class="o">+</span> <span class="mi">5</span><span class="o">;</span> <span class="o">++</span><span class="n">i</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="n">i</span> <span class="o">!=</span> <span class="n">arguments</span><span class="o">.</span><span class="na">length</span><span class="o">)</span> <span class="o">{</span>
<span class="nc">SymbolicName</span><span class="o">.</span><span class="na">F</span> <span class="n">sn</span> <span class="o">=</span> <span class="k">new</span> <span class="nc">SymbolicName</span><span class="o">.</span><span class="na">F</span><span class="o">(</span><span class="n">functionName</span><span class="o">,</span> <span class="n">i</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="na">env</span><span class="o">.</span><span class="na">getFunctionLibrary</span><span class="o">().</span><span class="na">isAvailable</span><span class="o">(</span><span class="n">sn</span><span class="o">))</span> <span class="o">{</span>
<span class="n">existsWithDifferentArity</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">break</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="n">existsWithDifferentArity</span><span class="o">)</span> <span class="o">{</span>
<span class="n">sb</span><span class="o">.</span><span class="na">append</span><span class="o">(</span><span class="s">". The namespace URI and local name are recognized, but the number of arguments is wrong"</span><span class="o">);</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="n">supplementary</span> <span class="o">=</span> <span class="n">getMissingFunctionExplanation</span><span class="o">(</span><span class="n">functionName</span><span class="o">,</span> <span class="n">config</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="n">supplementary</span> <span class="o">!=</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
<span class="n">sb</span><span class="o">.</span><span class="na">append</span><span class="o">(</span><span class="s">". "</span><span class="o">).</span><span class="na">append</span><span class="o">(</span><span class="n">supplementary</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="n">sb</span><span class="o">.</span><span class="na">append</span><span class="o">(</span><span class="s">". External function calls have been disabled"</span><span class="o">);</span>
<span class="o">}</span>
</code></pre>
<ul>
<li>I do not understand whats going on and my application freezes since it is always stuck in the for-loop.</li>
<li>I am expecting either the function to be found and exit the for-loop and continue the normal behavior of my application or some timeout to be set or an error message to be thrown if the XPath functions are not found in that loop.</li>
<li>Please let me know your suggestion on how to proceed.</li>
<li>I'm using Saxon 10.6 and Xpath 3.0</li>
</ul>
<p><strong>Note:</strong> Here I'm using custom library(External Jar file) which inside the class path contains some Xpath functions, not modified anything on Saxon FunctionLibrary interface.</p>
<p><strong>Stack overflow ticket :</strong> <a href="https://stackoverflow.com/questions/78001210/xpath-parser-continously-looping-to-find-xpath-function-library-in-a-given-custo?noredirect=1#comment137514388_78001210" class="external">https://stackoverflow.com/questions/78001210/xpath-parser-continously-looping-to-find-xpath-function-library-in-a-given-custo?noredirect=1#comment137514388_78001210</a></p> Saxon - Bug #6343 (New): Function Coercion is not always appliedhttps://saxonica.plan.io/issues/63432024-02-11T23:27:14ZMichael Kaymike@saxonica.com
<p>I have created the following test case FunctionCall-058:</p>
<pre><code> declare function local:f($callback as function(xs:integer) as xs:boolean) as xs:boolean {
$callback(year-from-date(current-date()) div 1900)
};
local:f(function($d as xs:decimal) as xs:boolean { $d lt 0 })
</code></pre>
<p>This should fail because the <code>$callback</code> function requires an xs:integer but the supplied value (the result of the integer division) is an xs:decimal.</p>
<p>What is supposed to happen according to the spec is that the supplied function (which accepts an x:decimal) is coerced to the required type (which does not). The means that the function actually supplied to the $callback parameter is effectively:</p>
<pre><code>function($d1 as xs:integer) as xs:boolean {
function($d2 as xs:decimal) as xs:boolean { $d2 lt 0 } ($d1)
}
</code></pre>
<p>which should fail with a type error when called supplying an <code>xs:decimal</code>.</p>
<p>However, because the value supplied to the <code>$callback</code> parameter is an instance of the required type, Saxon skips the process of function coercion wrongly believing it to be unnecessary; his has the effect that the type error is not detected.</p> Saxon - Bug #6263 (New): Test case try-031 fails under Saxon-HE (try/catch with lazy evaluation)https://saxonica.plan.io/issues/62632023-11-28T11:01:55ZMichael Kaymike@saxonica.com
<p>The XSLT 3.0 test case try-031 is failing under Saxon-HE. The essence of the failure is that in the construct</p>
<pre><code><xsl:variable name="p" select="...."/>
<xsl:try>
<xsl:value-of select="$p"/>
<xsl:catch>
<caught/>
</xsl:catch>
</xsl:try>
</code></pre>
<p>an error occurring during lazy evaluation of $p is caught by the try/catch when it should not be.</p>
<p>The test is failing in the candidate 12.4 release but also fails in earlier releases.</p> Saxon - Bug #6191 (New): Released SaxonCS artefact is a debug buildhttps://saxonica.plan.io/issues/61912023-09-01T15:54:06ZMichael Kaymike@saxonica.com
<p>Email from Nick Trevor:</p>
<p>Sorry to reach out directly, but was wondering if you could help. I'm test the performance of SaxonCS and when running the benchmarks I am getting warned that the nuget package is a debug build which could impact performance. Is it possible to get a release package published to nuget?</p>
<pre><code>// * Assembly Benchmarks which defines benchmarks references non-optimized SaxonCS
If you own this dependency, please, build it in RELEASE.
If you don't, you can disable this policy by using 'config.WithOptions(ConfigOptions.DisableOptimizationsValidator)'
</code></pre> Saxon - Bug #6183 (In Progress): "fallback=no" on UCA collation not working in EE editionhttps://saxonica.plan.io/issues/61832023-08-23T01:29:51ZTrevor Lawrence
<p>We are using a licensed (as of 05/04/23) edition of SaxonJ-EE 11.5.</p>
<p>We're using the <code><xsl:sort></code> instruction within an <code><xsl:for-each-group></code> with a custom-defined UCA collation URI. While debugging an issue with it we decided to add the <code>fallback=no</code> parameter to see if we were misusing one of the options, and instead got a message saying it's not supported in Saxon-HE.</p>
<p>Attached to this issue is a minimal stylesheet that reproduces the issue. Invoking it with this command:</p>
<pre><code class="shell syntaxhl" data-language="shell">java <span class="nt">-cp</span> <path_to_xml_resolver_4.6.4>:<path_to_saxon_EE_11.5> <span class="se">\</span>
net.sf.saxon.Transform <span class="se">\</span>
<span class="nt">-xsl</span>:transform-with-EE-feature.xsl <span class="se">\</span>
<span class="nt">-o</span>:file.xml <span class="se">\</span>
<span class="nt">-it</span> <span class="se">\</span>
<span class="nt">-config</span>:<path_to_our_config_and_license>
</code></pre>
<p>gives:</p>
<pre><code>Error at xsl:sort on line 9 column 141 of transform-with-EE-feature.xsl:
XTDE1035 Failed to load collation
http://www.w3.org/2013/collation/UCA?lang=en;maxVariable=symbol;strength=4;alternate=shifted;fallback=no: Error in UCA Collation URI http://www.w3.org/2013/collation/UCA?lang=en;maxVariable=symbol;strength=4;alternate=shifted;fallback=no: fallback=no is not supported in Saxon-HE
Errors were reported during stylesheet compilation
</code></pre>
<p>We currently pull down Saxon-EE from your new Maven repo and XML Resolver from Maven central.</p> Saxon - Bug #6172 (New): In 4.0, keywords in function calls are sometimes ignoredhttps://saxonica.plan.io/issues/61722023-08-15T22:10:05ZMichael Kaymike@saxonica.com
<p>XPath 4.0 allows function calls to provide argument values by keyword as well as positionally.</p>
<p>Some function libraries simply ignore any supplied keywords and interpret all arguments as positional. These include:</p>
<ul>
<li>constructor functions</li>
<li>Java extension functions (both reflexive and integrated)</li>
<li>The xsl:original pseudo-function</li>
<li>Some libraries implemented as Java extension functions,</li>
</ul>
<p>Some function libraries such as EXPath File and Binary are implemented as BuiltInFunctionSets, so keywords should work in principle, but no keyword data has been created, so using keywords will likely fail in unpredictable ways. It's not actually clear what we should do here: should we implement the parameter keywords defined in the spec, even though they were never intended to be used in this way?</p> Saxon - Bug #6127 (New): Documentation: argument keywords in function libraryhttps://saxonica.plan.io/issues/61272023-07-10T07:56:11ZMichael Kaymike@saxonica.com
<p>The documentation of the function library has not kept up to date with changes in argument keywords in the 4.0 specification. For example</p>
<p><a href="https://www.saxonica.com/documentation12/index.html#!functions/fn/reverse" class="external">https://www.saxonica.com/documentation12/index.html#!functions/fn/reverse</a></p>
<p>lists the signature as</p>
<pre><code>reverse($arg as item()*) ➔ item()*
</code></pre>
<p>but the argument keyword has changed from <code>arg</code> to <code>input</code>. The argument keywords are relevant in 4.0 because arguments can be identified by name in a function call.</p> Saxon - Bug #5877 (New): Java-CustomGUID generator is producing the same result when used inside ...https://saxonica.plan.io/issues/58772023-02-10T05:42:35ZThirupathi Molugoori
<p><strong>InputXml:</strong></p>
<pre><code><?xml version=\"1.0\"?>
<Guids>
<serialNum>1</serialNum>
</Guids>
<Guids>
<serialNum>2</serialNum>
</Guids>
</code></pre>
<p><strong>Case1:Using functions inside xslt</strong></p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:func="http://www.xsltfunctions.com"
xmlns:helper="com.test.xslt.function" extension-element-prefixes="helper" version="2.0">
<xsl:template match="TestXML">
<xsl:element name="TestElement">
<xsl:for-each select="./Guids">
<xsl:element name="serialNum">
<xsl:value-of select="serialNum"/>
</xsl:element>
<xsl:element name="TestGuid">
<xsl:value-of select="func:genGuid()"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:function name="func:genGuid">
<xsl:value-of select="helper:genGUID()"/>
</xsl:function>
</xsl:stylesheet>
**Output **
<?xml version="1.0" encoding="UTF-8"?>
<TestElement>
<serialNum>1</serialNum>
<TestGuid>D5CAF5D4-8C05-408A-B56A-A277A8F33975</TestGuid>
<serialNum>2</serialNum>
<TestGuid>D5CAF5D4-8C05-408A-B56A-A277A8F33975</TestGuid>
</TestElement>
</code></pre>
<p><strong>Case2:If I use the custom function directly inside the for-each(instead of template/function) then also it is producing the same guid as above which is not expected.</strong></p>
<p><strong>Case3:Using template inside Xslt is producing the correct result</strong></p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:helper="com.test.xslt.function" extension-element-prefixes="helper" version="2.0">
<xsl:template match="TestXML">
<xsl:element name="TestElement">
<xsl:for-each select="./Guids">
<xsl:element name="serialNum">
<xsl:value-of select="serialNum"/>
</xsl:element>
<xsl:element name="TestGuid">
<xsl:call-template name="genGUID"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template name="genGUID">
<xsl:value-of select="helper:genGUID()"/>
</xsl:template>
</xsl:stylesheet>
</code></pre>
<p><strong>Output:</strong></p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<TestElement>
<serialNum>1</serialNum>
<TestGuid>E75AE452-4B7F-4CF8-A6CE-64DE81687384</TestGuid>
<serialNum>2</serialNum>
<TestGuid>771D2C44-8216-4CA7-B43A-2CBEB03AF7F3</TestGuid>
</TestElement>
</code></pre>
<p><strong>Customer function implementation:</strong></p>
<pre><code>package com.test.xslt.function;
import java.util.UUID;
import net.sf.saxon.s9api.ExtensionFunction;
import net.sf.saxon.s9api.QName;
import net.sf.saxon.s9api.SaxonApiException;
import net.sf.saxon.s9api.SequenceType;
import net.sf.saxon.s9api.XdmAtomicValue;
import net.sf.saxon.s9api.XdmValue;
public class GUIDGenFunction implements ExtensionFunction {
@Override
public QName getName() {
return new QName( "com.test.xslt.function", "genGUID" );
}
@Override
public SequenceType[] getArgumentTypes() {
return new SequenceType[]{};
}
@Override
public SequenceType getResultType() {
return SequenceType.ANY;
}
@Override
public XdmValue call( XdmValue[] arguments ) throws SaxonApiException {
String result = UUID.randomUUID().toString().toUpperCase();
System.out.println( "GUID Result " + result );
return new XdmAtomicValue( result );
}
}
ExtensionFunction genGUIDFunction = new GUIDGenFunction();
processor.registerExtensionFunction( genGUIDFunction );
</code></pre>
<p>Please let me know why it is not working as expected in case1&2.</p> Saxon - Bug #5651 (New): Garbage collection of xsl:key indexeshttps://saxonica.plan.io/issues/56512022-08-18T14:24:21ZMichael Kaymike@saxonica.com
<p>When Saxon builds an index in support of an xsl:key definition, or an implicit xsl:key generated by the XSLT/XQuery optimizer, the intent is that the key remains in memory so long as BOTH the source document AND the compiled stylesheet or query remain in memory.</p>
<p>This appears not to be working. If we run the same query 1000 times against the same source document, we're seeing the index built 95 times. This suggests the garbage collector is destroying it and we're having to rebuild it the next time it's used.</p>
<p>We use WeakReferences to support this policy, and it looks as if we're getting it wrong.</p>
<p>Note: we also need to check how this works on Saxon-CS, as it's probably different.</p> Saxon - Bug #5615 (New): Saxon 11 - Cannot have two different documents with the same document-urihttps://saxonica.plan.io/issues/56152022-07-26T11:03:55ZRadu Coravuradu_coravu@sync.ro
<p>I'm getting this unhandled error which comes probably from reusing a transformer, the code we use is quite complex in those parts:</p>
<pre><code>7065 ERROR [ main ] ro.sync.quickfix.QuickFixExecutor - Cannot generate late quick fixes: net.sf.saxon.trans.XPathException: Cannot have two different documents with the same document-uri file:/D:/projects/../SchematronQF/add/element/selectAttrValue/topic.dita
net.sf.saxon.trans.XPathException: Cannot have two different documents with the same document-uri file:/D:/projects/../SchematronQF/add/element/selectAttrValue/topic.dita
at net.sf.saxon.om.DocumentPool.add(DocumentPool.java:69)
at net.sf.saxon.Controller.registerDocument(Controller.java:1004)
at net.sf.saxon.Controller.makeSourceTree(Controller.java:1359)
at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:343)
at net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:75)
</code></pre>
<p>would it be a good idea in the Controller.registerDocument to check if the document is already in the pool before adding it?</p>
<pre><code> if (getDocumentPool().find(uri) == null) {
sourceDocumentPool.add(doc, uri);
}
</code></pre> Saxon - Bug #5578 (New): Feature: tracing on .NEThttps://saxonica.plan.io/issues/55782022-06-23T08:38:47ZMichael Kaymike@saxonica.com
<p>See <a href="https://saxonica.plan.io/boards/3/topics/8829" class="external">https://saxonica.plan.io/boards/3/topics/8829</a></p>
<p>The basic tracing infrastructure is present in SaxonCS (the -T option on the command line works), but the APIs to control it are largely missing, and the -TP option (with the underlying TimingTraceListener class) is absent.</p>
<p>The restrictions are not well documented, for example the page "Using XSLT from the command line" does not mark the -TP option as Java-only.</p> Saxon - Bug #5549 (New): Function caching is not applied to tail callshttps://saxonica.plan.io/issues/55492022-05-30T08:11:02ZMichael Kaymike@saxonica.com
<p>If a function f contains a tail-call to a function g, and g is defined with cache="yes", then the cache is ignored and g is executed normally.</p>
<p>See <code>TailCallLoop.tailCallDifferentFunction()</code></p>
<p>(Test case function-1035. I modified the test to make the call not be a tail call; undo this change to demonstrate the problem)</p> Saxon - Bug #4664 (In Progress): Xerces bug: Wrong value of xml:base attribute after resolving XI...https://saxonica.plan.io/issues/46642020-08-03T10:48:44ZO'Neil Delprattoneil@saxonica.com
<p>The following Xerces bug is affecting several users: <a href="https://issues.apache.org/jira/browse/XERCESJ-1102" class="external">https://issues.apache.org/jira/browse/XERCESJ-1102</a></p>
<p>This bug causes the wrong value of xml:base attribute after resolving XInclude references. One user applies a the patch in a jar file that is included on the Java classpath when Saxon is invoked. It would be good to apply this patch internally with Saxon as part of the issued product.</p>
<p>This affects: Saxon-J, Saxon.NET and Saxon/C</p> Non-Conformances - Bug #4220 (New): Exposed visibility of xsl:paramhttps://saxonica.plan.io/issues/42202019-05-15T10:39:14ZMichael Kaymike@saxonica.com
<p>Unit test <code>s9apitests/TestPackage/testPackageRenamingExported</code> is failing with an error saying it cannot accept xsl:param elements with private visibility as hidden.</p>
<p>The spec says (a) that xsl:param elements are always public, and (b) that their visibility cannot be changed by <code>xsl:expose</code> or <code>xsl:accept</code>.</p>
<p>What this test is trying to do is to compile a single package three times with different settings of a static parameter, and then import all three exported packages into a single top-level package (using package aliases to achieve this). It might be that we won't be able to get this to work, but we need to investigate why it's failing the way that it is. The spec says that xsl:param is public, but we're reporting it as private.</p> Non-Conformances - Bug #3531 (New): Substitution groups are not mergedhttps://saxonica.plan.io/issues/35312017-11-16T07:07:38ZMichael Kaymike@saxonica.com
<p>Taking this over as a sub-problem of bug <a class="issue tracker-1 status-3 priority-2 priority-default closed" title="Bug: --multipleSchemaImports has no effect when processing a cycle of schema documents (Closed)" href="https://saxonica.plan.io/issues/3202">#3202</a>.</p>
<p>MHK IntelliJ project Saxon9.8/XBRLTest</p>
<p>When there are several independent calls on SchemaManager.load(), each call on load() results in a new PreparedSchema being built; and if the schema is then found to be valid, its components are merged into the global schema for the Configuration. (We carefully avoid making any changes to the global schema until the new local schema has been verified as being valid.)</p>
<p>If two of these calls on load() specify two different schemas which both import some common schema, it's possible that either or both may declare elements to be in the substitution group of some element declaration in the common schema. When this happens then the process of merging the local schema into the global schema should form the union of the two substitution groups (and in turn, this should trigger recompilation of any affected types). This is not happening: we use one element declaration or the other, but we never merge them in this way.</p>
<p>The logic is complicated by xs:redefine, but let's focus on getting it right in the absence of xs:redefine.</p>