Saxonica Developer Community: Issueshttps://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2024-03-27T11:18:36ZSaxonica Developer Community
Planio Saxon - Bug #6379 (New): Default implementation of fn:deep-equalhttps://saxonica.plan.io/issues/63792024-03-27T11:18:36ZNorm Tovey-Walsh
<p>I happened to trace my way through a call to deep equal in Saxon HE 12.4 and I was a little bit surprised to find that it's using the <code>DeepEqual40</code> implementation. I wonder if that was intentional...</p> SaxonJS - Bug #6374 (New): saxon.compile removed in 2.6+?https://saxonica.plan.io/issues/63742024-03-19T09:54:05ZJai B
<p>Hi,</p>
<p>I've always used the <code>saxon.compile</code> function to generate sef files in code. I know it's undocumented but IIRC it was shown in the command line docs or something.</p>
<p>Basically I cache the compiled sef so I don't have to recompile everytime I want to do a transform and I don't want to pre-transform my XSLT files on the command line, nor do I have any desire to use the Java version for that part, the JS compiler has worked amazingly!</p>
<p>My web app does server side transformations with node; anytime it sees the XSLT change, it runs a compile to generate and cache a new sef to use for subsequent transformations. I can't cache the result of the transformation either since the data is dynamic, of course.</p>
<p>Perhaps I'm missing something or missing some changes, but this has worked awesome for years and only just noticed things breaking when redeploying some stuff and npm updating to 2.6.0 and getting an error that the function doesn't exist.</p>
<p>When I was initially implementing this, I know I spent a fair bit of time trying to figure this part out and ensure I was doing things right; I think I scoped the code that generates the sef on command line to find the function in the first place and was surprised it wasn't actually documented/available anyway.</p>
<p>Thanks again for SaxonJS!</p> SaxonJS - Bug #6346 (New): NPE with replace() on SaxonJS2.6 when exported under 4.0-support condi...https://saxonica.plan.io/issues/63462024-02-14T14:05:50ZJohn Lumleyjohn@saxonica.com
<p>When exporting a stylesheet (either 3.0 or 4.0) for SaxonJS 2.6, using SaxonEE 12.4 running under <code> --allowSyntaxExtensions:on</code>,
a three-argument call on <code>replace()</code> (that is with the fourth <code>$flags</code> argument to default to the empty string), at runtime a null pointer expection is thrown when attempting to retrieve the flags:</p>
<pre><code class="javascript syntaxhl" data-language="javascript"><span class="kd">const</span> <span class="nx">flags</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="p">?</span> <span class="nx">args</span><span class="p">[</span><span class="mi">3</span><span class="p">].</span><span class="nx">next</span><span class="p">().</span><span class="nx">toString</span><span class="p">()</span> <span class="p">:</span> <span class="dl">""</span><span class="p">;</span>
</code></pre>
<p>The <code>next()</code> returns a null.</p>
<p>Without <code>allowSyntaxExtensions</code> or with the fourth argument supplied, the function behaves as expected.</p>
<p>Sample stylesheet, compiled SEF and web page attached</p> Saxon - Bug #6307 (New): Saxon (HE; Java) trace missing xsl:accumulator and xsl:accumulator-rule,...https://saxonica.plan.io/issues/63072023-12-27T21:52:00ZA Galtman
<ul>
<li>Is the trace supposed to mark xsl:accumulator as hit?</li>
<li>Is the trace supposed to mark xsl:accumulator-rule as hit?</li>
<li>I definitely expect descendant elements of xsl:accumulator-rule to be marked as hit, and I'm not seeing them in Saxon 12.4. Saxon 9.9.1.8 correctly lists the descendants of xsl:accumulator-rule.</li>
</ul>
<p>I'm attaching a file that includes the code, the Saxon arguments I used, and the traces I got from Saxon 9.9.1.8 and 12.4.</p> Saxon - Bug #6305 (New): XPathException "The stylesheet module includes/imports itself directly o...https://saxonica.plan.io/issues/63052023-12-22T15:02:48ZGerben Abbinkgerben.abbink@gmail.com
<p>I use an ErrorReporter with XsltCompiler, like this:</p>
<pre><code>XsltCompiler compiler = processor.newXsltCompiler();
compiler.setErrorReporter(...);
</code></pre>
<p>Usually, XPathExceptions have a Location to identify the error in the file.</p>
<p>But, when I use this template, there is no location information:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href=""/>
</xsl:stylesheet>
</code></pre> Saxon - Bug #6302 (New): Saxon (HE; Java) trace not well-formed when XSLT uses transform functionhttps://saxonica.plan.io/issues/63022023-12-21T19:56:45ZA Galtman
<p>(I alluded to this in my 12/21/23 comment in <a href="https://saxonica.plan.io/issues/6295" class="external">https://saxonica.plan.io/issues/6295</a> but it seems different enough that I'm making a separate issue for it rather than assume that the fix for 6295 is enough.)</p>
<p>The <code>transform()</code> function seems to cause the Saxon trace not to be well-formed.</p>
<a name="Sample-XSLT-1-transform-functionxsl"></a>
<h3 >Sample XSLT 1, transform-function.xsl<a href="#Sample-XSLT-1-transform-functionxsl" class="wiki-anchor">¶</a></h3>
<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:my="my-ns"
exclude-result-prefixes="#all"
version="3.0">
<xsl:template name="xsl:initial-template">
<xsl:variable name="transform-options" as="map(xs:string, item()*)">
<xsl:map>
<xsl:map-entry key="'delivery-format'" select="'raw'"/>
<xsl:map-entry key="'stylesheet-location'">target-stylesheet-small.xsl</xsl:map-entry>
<xsl:map-entry key="'function-params'" select="[()]"/>
<xsl:map-entry key="'initial-function'" select="QName('my-ns', 'my:fcn')"/>
</xsl:map>
</xsl:variable>
<xsl:sequence select="transform($transform-options)?output"/>
</xsl:template>
</xsl:stylesheet>
</code></pre>
<a name="Sample-XSLT-2-target-stylesheet-smallxsl"></a>
<h3 >Sample XSLT 2, target-stylesheet-small.xsl<a href="#Sample-XSLT-2-target-stylesheet-smallxsl" class="wiki-anchor">¶</a></h3>
<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:fn="http://www.w3.org/2005/xpath-functions"
xmlns:my="my-ns"
exclude-result-prefixes="#all"
version="3.0">
<xsl:function name="my:fcn" visibility="public" as="xs:string">
<xsl:param name="p" as="empty-sequence()"/>
<xsl:sequence select="'output'"/>
</xsl:function>
</xsl:stylesheet>
</code></pre>
<a name="Saxon-command"></a>
<h3 >Saxon command<a href="#Saxon-command" class="wiki-anchor">¶</a></h3>
<pre><code>java -cp "%SAXON_CP%" net.sf.saxon.Transform -opt:0 -T -Tlevel:high -it -xsl:transform-function.xsl 2>transform-function-traceresult.xml
</code></pre>
<p>I'm using Saxon-HE 12.4.</p>
<a name="Trace-Result"></a>
<h3 >Trace Result<a href="#Trace-Result" class="wiki-anchor">¶</a></h3>
<pre><code><trace saxon-version="12.4" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="xsl:initial-template" line="9" column="45" module="transform-function.xsl">
<xsl:variable name="transform-options" line="10" column="73" module="transform-function.xsl">
<trace text="target-stylesheet-small.xsl" line="13" column="52" module="transform-function.xsl">
</trace>
<trace saxon-version="12.4" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:function arity="1" name="my:fcn" line="9" column="66" module="target-stylesheet-small.xsl">
</xsl:function>
</xsl:variable>
</xsl:template>
</trace>
</code></pre> SaxonJS - Bug #6298 (New): base-uri() value does not update together with DOMhttps://saxonica.plan.io/issues/62982023-12-19T23:34:51ZMartynas Jusevicius
<p>My SaxonJS code replaces large chunks of DOM with content loaded from different documents. DOM's baseURI property returns the source document's URL, but <code>base-uri()</code> does not always seem to do that. Which can lead to a stale value, probably because the DOM is updated?</p>
<p>This is my observation of the discrepancy:</p>
<pre><code>ixsl:get(., 'baseURI'): https://localhost:4443/7b386331-5a82-46ab-820b-38df78a91456/ SaxonJS2.rt.js:785:84
base-uri(): https://localhost:4443/ SaxonJS2.rt.js:785:84
ixsl:location(): https://localhost:4443/7b386331-5a82-46ab-820b-38df78a91456/
</code></pre> SaxonJS - Bug #6250 (New): SyntaxError: Unexpected token '='https://saxonica.plan.io/issues/62502023-11-11T13:53:59ZPrasad Kuppa
<p>Hi Team,
Getting below error while running xslt3 from command line.</p>
<p>/usr/local/lib/node_modules/xslt3/node_modules/saxon-js/SaxonJS2N.js:4290
q("not a node"),Error.tg&&Error.tg(),q("wrong node kind "+p.nodeType)}const k=fc;a(E,"indent","boolean",!1);return d(u)}}}();const Td=function(){function a(r,g,e,n,y){e="xml"===e?g.fixed.gb:g.fixed.$b;g=g.fixed.hd;var u=e[r];if(!u||u instanceof H){u=g[r];if(!u){try{u=n()}catch(E){u=E}g[r]=u}u=y(u);e[r]=u}if(u instanceof H)throw u;return u}function b(r,g){g||="utf-8";r=void 0===r.Ob?r:r.Ob;if(g.startsWith("utf")&&0<=r.indexOf("\ufffd"))throw new H("External file contains non-Unicode characters","FOUT1190");return r}function h(r){if(0<=r.indexOf("\x00"))throw new H("External file contains non-XML characters","FOUT1190");
^</p>
<p>SyntaxError: Unexpected token '='
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/usr/local/lib/node_modules/xslt3/xslt3.js:43:357)
at Object. (/usr/local/lib/node_modules/xslt3/xslt3.js:93:95)
at Module._compile (internal/modules/cjs/loader.js:999:30)</p>
<p>OS: Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-70-generic x86_64)
Node Version: v12.22.9
NPM Version: 8.5.1
SaxonJS Versions tried: 2.3.0, 2.4.0, 2.5.0 & 2.6.0</p>
<p>Thank you for your support.</p> SaxonJS - Bug #6245 (New): broken links in SaxonJS documentation https://saxonica.plan.io/issues/62452023-11-08T14:13:28ZMartin Honnenmartin.honnen@gmx.de
<p><a href="https://www.saxonica.com/saxon-js/documentation2/index.html#!conformance/xslt30" class="external">https://www.saxonica.com/saxon-js/documentation2/index.html#!conformance/xslt30</a> has (at least) two not working links, in the row for <code>vendor-options</code> it says</p>
<blockquote>
<p>Enables syntax extensions for XSLT and XPath, specifically the conditional XSLT extensions described here and the XPath otherwise operator</p>
</blockquote>
<p>where</p>
<ol>
<li>"conditional XSLT extensions described here" links to <a href="https://www.saxonica.com/documentation12/index.html#!extensions/xslt-syntax-extensions" class="external">https://www.saxonica.com/documentation12/index.html#!extensions/xslt-syntax-extensions</a> which gives the error "Error in URI hash-path: Section 'xslt-syntax-extensions' not found in path: extensions/xslt-syntax-extensions"</li>
<li>"otherwise" links to <a href="https://www.saxonica.com/documentation12/index.html#!extensions/syntax-extensions/otherwise" class="external">https://www.saxonica.com/documentation12/index.html#!extensions/syntax-extensions/otherwise</a> which gives a similar error "Error in URI hash-path: Section 'syntax-extensions' not found in path: extensions/syntax-extensions/otherwise"</li>
</ol> SaxonJS - Bug #6234 (New): map call with sequence of more than one item as argument doesn't give ...https://saxonica.plan.io/issues/62342023-10-28T21:38:53ZMartin Honnenmartin.honnen@gmx.de
<p>In a test I tried to call an XPath 3.1 map as a function, passing in a sequence of two items as the argument; SaxonJ gives an error but SaxonJS happily runs the code e.g.</p>
<pre><code class="xml syntaxhl" data-language="xml"><span class="cp"><?xml version="1.0" encoding="utf-8"?></span>
<span class="nt"><xsl:stylesheet</span> <span class="na">xmlns:xsl=</span><span class="s">"http://www.w3.org/1999/XSL/Transform"</span>
<span class="na">version=</span><span class="s">"3.0"</span>
<span class="na">xmlns:xs=</span><span class="s">"http://www.w3.org/2001/XMLSchema"</span>
<span class="na">exclude-result-prefixes=</span><span class="s">"#all"</span>
<span class="na">expand-text=</span><span class="s">"yes"</span><span class="nt">></span>
<span class="nt"><xsl:param</span> <span class="na">name=</span><span class="s">"id-map"</span> <span class="na">select=</span><span class="s">"map { 1 : 2, 2 : (), 3 : 2, 4 : 3 }"</span><span class="nt">/></span>
<span class="nt"><xsl:template</span> <span class="na">match=</span><span class="s">"/"</span> <span class="na">name=</span><span class="s">"xsl:initial-template"</span><span class="nt">></span>
<span class="nt"><test></span>{$id-map((3, 4))}<span class="nt"></test></span>
<span class="nt"><xsl:comment></span>Run with {system-property('xsl:product-name')} {system-property('xsl:product-version')} {system-property('Q{http://saxon.sf.net/}platform')}<span class="nt"></xsl:comment></span>
<span class="nt"></xsl:template></span>
<span class="nt"></xsl:stylesheet></span>
</code></pre>
<p>when run with <code>xslt3 -it -xsl:test1.xsl</code> outputs</p>
<pre><code class="xml syntaxhl" data-language="xml"><span class="cp"><?xml version="1.0" encoding="UTF-8"?></span><span class="nt"><test></span>2<span class="nt"></test></span><span class="c"><!--Run with SaxonJS 2.6 Node.js--></span>
</code></pre>
<p>As <a href="https://www.w3.org/TR/xpath-31/#id-maps" class="external">https://www.w3.org/TR/xpath-31/#id-maps</a> defines calling a map as doing <code>map:get</code> with the signature (<a href="https://www.w3.org/TR/xpath-functions-31/#func-map-get" class="external">https://www.w3.org/TR/xpath-functions-31/#func-map-get</a>) <code>map:get($map as map(*), $key as xs:anyAtomicType) as item()*</code> the code should give an error "XPTY0004 A sequence of more than one item is not allowed as the first argument of map".</p>
<p>Interestingly enough, for a direct call <code>map:get($id-map, (3, 4))</code> SaxonJS gives the error "Required cardinality of second argument of map:get() is exactly one; supplied value contains 2 items (xs:integer('3'), xs:integer('4'))".</p> SaxonJS - Bug #6233 (New): ReferenceError: abstractNode is not definedhttps://saxonica.plan.io/issues/62332023-10-26T09:24:04ZThomas Barnekow
<p>I am trying to use SaxonJS 2.6.0 within a Next.js 13 project. I am using code that works on the Node.js runtime in Azure Functions. However, the same code leads to the following exception in Next.js:</p>
<p>⨯ node_modules/.pnpm/saxon-js@2.6.0/node_modules/saxon-js/SaxonJS2N.js (4640:147) @ abstractNode
⨯ ReferenceError: abstractNode is not defined
at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/saxon-js@2.6.0/node_modules/saxon-js/SaxonJS2N.js:277426:14)
at (rsc)/./node_modules/.pnpm/saxon-js@2.6.0/node_modules/saxon-js/SaxonJS2N.js (/Users/thomas/Source/Repos/platforms-starter-kit/.next/server/vendor-chunks/<a href="mailto:saxon-js@2.6.0.js" class="email">saxon-js@2.6.0.js</a>:20:1)
at <strong>webpack_require</strong> (/Users/thomas/Source/Repos/platforms-starter-kit/.next/server/webpack-runtime.js:33:43)
at eval (webpack-internal:///(rsc)/./app/api/render-service-levels/route.ts:5:66)</p> SaxonJS - Bug #6132 (New): documentPool passed to SaxonJS.transform doesn't seem to be used if th...https://saxonica.plan.io/issues/61322023-07-18T16:53:41ZMartin Honnenmartin.honnen@gmx.de
<p>For SaxonJS.transform, I can pass a <code>documentPool</code>, mapping URLs to resources, to allow preloading resources or loading resources from a string.</p>
<p>An example of that is e.g. a stylesheet (shown here as XSLT, for SaxonJS it will be compiled to sef.json)</p>
<pre><code class="xml syntaxhl" data-language="xml"><span class="cp"><?xml version="1.0" encoding="utf-8"?></span>
<span class="nt"><xsl:stylesheet</span> <span class="na">xmlns:xsl=</span><span class="s">"http://www.w3.org/1999/XSL/Transform"</span>
<span class="na">version=</span><span class="s">"3.0"</span>
<span class="na">xmlns:xs=</span><span class="s">"http://www.w3.org/2001/XMLSchema"</span>
<span class="na">exclude-result-prefixes=</span><span class="s">"#all"</span>
<span class="na">expand-text=</span><span class="s">"yes"</span><span class="nt">></span>
<span class="nt"><xsl:template</span> <span class="na">name=</span><span class="s">"xsl:initial-template"</span><span class="nt">></span>
<span class="nt"><xsl:sequence</span> <span class="na">select=</span><span class="s">"doc('doc1.xml') => serialize(map{'method':'xml'})"</span><span class="nt">/></span>
<span class="nt"></xsl:template></span>
<span class="nt"></xsl:stylesheet></span>
</code></pre>
<p>and (for Node.js) Javascript code like</p>
<pre><code class="javascript syntaxhl" data-language="javascript"><span class="kd">const</span> <span class="nx">path</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">'</span><span class="s1">path</span><span class="dl">'</span><span class="p">);</span>
<span class="kd">const</span> <span class="nx">url</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">'</span><span class="s1">url</span><span class="dl">'</span><span class="p">);</span>
<span class="kd">const</span> <span class="nx">SaxonJS</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">'</span><span class="s1">saxon-js</span><span class="dl">'</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">xmlResource1</span> <span class="o">=</span> <span class="nx">SaxonJS</span><span class="p">.</span><span class="nx">getResource</span><span class="p">({</span><span class="dl">'</span><span class="s1">type</span><span class="dl">'</span><span class="p">:</span> <span class="dl">'</span><span class="s1">xml</span><span class="dl">'</span><span class="p">,</span> <span class="dl">'</span><span class="s1">text</span><span class="dl">'</span> <span class="p">:</span> <span class="dl">'</span><span class="s1"><root>foo</root></span><span class="dl">'</span> <span class="p">});</span>
<span class="kd">var</span> <span class="nx">doc1Uri</span> <span class="o">=</span> <span class="dl">'</span><span class="s1">doc1.xml</span><span class="dl">'</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">docPool</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">xmlResource1</span><span class="p">.</span><span class="nx">then</span><span class="p">(</span><span class="nx">doc</span> <span class="o">=></span> <span class="p">{</span> <span class="nx">docPool</span><span class="p">[</span><span class="nx">url</span><span class="p">.</span><span class="nx">pathToFileURL</span><span class="p">(</span><span class="nx">path</span><span class="p">.</span><span class="nx">resolve</span><span class="p">(</span><span class="dl">'</span><span class="s1">.</span><span class="dl">'</span><span class="p">,</span> <span class="nx">doc1Uri</span><span class="p">))]</span> <span class="o">=</span> <span class="nx">doc</span><span class="p">;</span> <span class="p">})</span>
<span class="p">.</span><span class="nx">then</span><span class="p">(()</span> <span class="o">=></span> <span class="p">{</span>
<span class="c1">//console.log(docPool);</span>
<span class="nx">SaxonJS</span><span class="p">.</span><span class="nx">transform</span><span class="p">({</span> <span class="na">documentPool</span><span class="p">:</span> <span class="nx">docPool</span><span class="p">,</span> <span class="na">stylesheetLocation</span><span class="p">:</span> <span class="dl">'</span><span class="s1">documentPoolTest1.xsl.sef.json</span><span class="dl">'</span> <span class="p">},</span> <span class="dl">'</span><span class="s1">async</span><span class="dl">'</span><span class="p">).</span><span class="nx">then</span><span class="p">(</span><span class="nx">result</span> <span class="o">=></span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">SaxonJS</span><span class="p">.</span><span class="nx">serialize</span><span class="p">(</span><span class="nx">result</span><span class="p">.</span><span class="nx">principalResult</span><span class="p">));</span>
<span class="p">});</span>
<span class="p">});</span>
</code></pre>
<p>When I run that with Node I get e.g.</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>&lt;root&gt;foo&lt;/root&gt;
</code></pre>
<p>so the <code>doc1.xml</code> is resolved from my passed in <code>documentPool</code> property.</p>
<p>However, when I do the same with an XSLT stylesheet having a function exposing <code>xsl:evaluate</code> with a public function and then call that function with <code>SaxonJS.transform</code> to pass in e.g. a string doing <code>doc("doc1.xml")</code> it seems the documentPool is not taken into account and instead I get an error that the file <code>doc1.xml</code> is not found:</p>
<pre><code>Transformation failure: Error FODC0002 at exposeXslEvaluate.xsl#17
Cannot read file file:///C:/Users/marti/OneDrive/Documents/xslt/saxonjs-documentPool/doc1.xml - ENOENT: no such file or directory, open 'C:\Users\marti\OneDrive\Documents\xslt\saxonjs-documentPool\doc1.xml'
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
Error
at new L (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4109:549)
at Object.readFile (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4713:171)
at Object.readFile (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4108:74)
at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4340:316
at a (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4338:294)
at Object.Ec (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4340:280)
at doc (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4513:298)
at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4632:444
at Object.I [as evaluate] (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4600:203)
at Object.evaluateXDM (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4933:464)
at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4630:290
at Object.push (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4390:245)
at e (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4987:320)
at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:5015:342 {
message: "Cannot read file file:///C:/Users/marti/OneDrive/Documents/xslt/saxonjs-documentPool/doc1.xml - ENOENT: no such file or directory, open 'C:\\Users\\marti\\OneDrive\\Documents\\xslt\\saxonjs-documentPool\\doc1.xml'",
name: 'XError',
code: 'FODC0002',
xsltLineNr: '17',
xsltModule: 'exposeXslEvaluate.xsl'
}
</code></pre>
<p>A sample XSLT is e.g.</p>
<pre><code class="xml syntaxhl" data-language="xml"><span class="nt"><xsl:stylesheet</span>
<span class="na">xmlns:xsl=</span><span class="s">"http://www.w3.org/1999/XSL/Transform"</span>
<span class="na">version=</span><span class="s">"3.0"</span>
<span class="na">xmlns:mf=</span><span class="s">"http://example.com/mf"</span>
<span class="na">xmlns:xs=</span><span class="s">"http://www.w3.org/2001/XMLSchema"</span>
<span class="na">exclude-result-prefixes=</span><span class="s">"#all"</span><span class="nt">></span>
<span class="nt"><xsl:function</span> <span class="na">name=</span><span class="s">"mf:eval"</span> <span class="na">as=</span><span class="s">"item()*"</span> <span class="na">visibility=</span><span class="s">"public"</span><span class="nt">></span>
<span class="nt"><xsl:param</span> <span class="na">name=</span><span class="s">"expression"</span> <span class="na">as=</span><span class="s">"xs:string"</span><span class="nt">/></span>
<span class="nt"><xsl:param</span> <span class="na">name=</span><span class="s">"context-item"</span> <span class="na">as=</span><span class="s">"item()?"</span><span class="nt">/></span>
<span class="nt"><xsl:param</span> <span class="na">name=</span><span class="s">"params"</span> <span class="na">as=</span><span class="s">"map(xs:QName, item()*)"</span><span class="nt">/></span>
<span class="nt"><xsl:evaluate</span> <span class="na">xpath=</span><span class="s">"$expression"</span> <span class="na">context-item=</span><span class="s">"$context-item"</span> <span class="na">with-params=</span><span class="s">"$params"</span><span class="nt">/></span>
<span class="nt"></xsl:function></span>
<span class="nt"><xsl:function</span> <span class="na">name=</span><span class="s">"mf:eval"</span> <span class="na">as=</span><span class="s">"item()*"</span> <span class="na">visibility=</span><span class="s">"public"</span><span class="nt">></span>
<span class="nt"><xsl:param</span> <span class="na">name=</span><span class="s">"expression"</span> <span class="na">as=</span><span class="s">"xs:string"</span><span class="nt">/></span>
<span class="nt"><xsl:evaluate</span> <span class="na">xpath=</span><span class="s">"$expression"</span> <span class="na">context-item=</span><span class="s">"()"</span> <span class="na">with-params=</span><span class="s">"map{}"</span><span class="nt">/></span>
<span class="nt"></xsl:function></span>
<span class="nt"><xsl:function</span> <span class="na">name=</span><span class="s">"mf:eval"</span> <span class="na">as=</span><span class="s">"item()*"</span> <span class="na">visibility=</span><span class="s">"public"</span><span class="nt">></span>
<span class="nt"><xsl:param</span> <span class="na">name=</span><span class="s">"expression"</span> <span class="na">as=</span><span class="s">"xs:string"</span><span class="nt">/></span>
<span class="nt"><xsl:param</span> <span class="na">name=</span><span class="s">"context-item"</span> <span class="na">as=</span><span class="s">"item()?"</span><span class="nt">/></span>
<span class="nt"><xsl:evaluate</span> <span class="na">xpath=</span><span class="s">"$expression"</span> <span class="na">context-item=</span><span class="s">"$context-item"</span> <span class="na">with-params=</span><span class="s">"map{}"</span><span class="nt">/></span>
<span class="nt"></xsl:function></span>
<span class="nt"></xsl:stylesheet></span>
</code></pre>
<p>the Javascript code is e.g.</p>
<pre><code class="javascript syntaxhl" data-language="javascript"><span class="kd">const</span> <span class="nx">path</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">'</span><span class="s1">path</span><span class="dl">'</span><span class="p">);</span>
<span class="kd">const</span> <span class="nx">url</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">'</span><span class="s1">url</span><span class="dl">'</span><span class="p">);</span>
<span class="kd">const</span> <span class="nx">SaxonJS</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">'</span><span class="s1">saxon-js</span><span class="dl">'</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">xmlResource1</span> <span class="o">=</span> <span class="nx">SaxonJS</span><span class="p">.</span><span class="nx">getResource</span><span class="p">({</span><span class="dl">'</span><span class="s1">type</span><span class="dl">'</span><span class="p">:</span> <span class="dl">'</span><span class="s1">xml</span><span class="dl">'</span><span class="p">,</span> <span class="dl">'</span><span class="s1">text</span><span class="dl">'</span> <span class="p">:</span> <span class="dl">'</span><span class="s1"><root>foo</root></span><span class="dl">'</span> <span class="p">});</span>
<span class="kd">var</span> <span class="nx">doc1Uri</span> <span class="o">=</span> <span class="dl">'</span><span class="s1">doc1.xml</span><span class="dl">'</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">docPool</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">xmlResource1</span><span class="p">.</span><span class="nx">then</span><span class="p">(</span><span class="nx">doc</span> <span class="o">=></span> <span class="p">{</span> <span class="nx">docPool</span><span class="p">[</span><span class="nx">url</span><span class="p">.</span><span class="nx">pathToFileURL</span><span class="p">(</span><span class="nx">path</span><span class="p">.</span><span class="nx">resolve</span><span class="p">(</span><span class="dl">'</span><span class="s1">.</span><span class="dl">'</span><span class="p">,</span> <span class="nx">doc1Uri</span><span class="p">))]</span> <span class="o">=</span> <span class="nx">doc</span><span class="p">;</span> <span class="p">})</span>
<span class="p">.</span><span class="nx">then</span><span class="p">(()</span> <span class="o">=></span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">docPool</span><span class="p">);</span>
<span class="nx">SaxonJS</span><span class="p">.</span><span class="nx">transform</span><span class="p">({</span>
<span class="na">documentPool</span><span class="p">:</span> <span class="nx">docPool</span><span class="p">,</span>
<span class="na">stylesheetLocation</span><span class="p">:</span> <span class="dl">'</span><span class="s1">exposeXslEvaluate.xsl.sef.json</span><span class="dl">'</span><span class="p">,</span>
<span class="na">stylesheetBaseURI</span><span class="p">:</span> <span class="nx">url</span><span class="p">.</span><span class="nx">pathToFileURL</span><span class="p">(</span><span class="nx">path</span><span class="p">.</span><span class="nx">resolve</span><span class="p">(</span><span class="dl">'</span><span class="s1">.</span><span class="dl">'</span><span class="p">,</span> <span class="dl">'</span><span class="s1">exposeXslEvaluate.xsl</span><span class="dl">'</span><span class="p">)),</span>
<span class="na">initialFunction</span><span class="p">:</span> <span class="dl">'</span><span class="s1">Q{http://example.com/mf}eval</span><span class="dl">'</span><span class="p">,</span>
<span class="na">functionParams</span><span class="p">:</span> <span class="p">[</span><span class="dl">'</span><span class="s1">doc("doc1.xml")</span><span class="dl">'</span><span class="p">],</span>
<span class="na">destination</span><span class="p">:</span> <span class="dl">'</span><span class="s1">raw</span><span class="dl">'</span>
<span class="p">},</span> <span class="dl">'</span><span class="s1">async</span><span class="dl">'</span><span class="p">).</span><span class="nx">then</span><span class="p">(</span><span class="nx">result</span> <span class="o">=></span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">SaxonJS</span><span class="p">.</span><span class="nx">serialize</span><span class="p">(</span><span class="nx">result</span><span class="p">.</span><span class="nx">principalResult</span><span class="p">));</span>
<span class="p">});</span>
<span class="p">});</span>
</code></pre> SaxonJS - Bug #5916 (New): Using xsl:merge with xsl:merge-source for-each-source="'input1.xml'" s...https://saxonica.plan.io/issues/59162023-03-12T12:40:08ZMartin Honnenmartin.honnen@gmx.de
<p>I have tried to run an XSLT 3 example using XSLT 3's new xsl:merge through SaxonJS 2.5's <code>xslt3</code> command line tool under Windows 11 with Node 16, a simple example using e.g.</p>
<pre><code class="xml syntaxhl" data-language="xml"> <span class="nt"><xsl:template</span> <span class="na">name=</span><span class="s">"xsl:initial-template"</span><span class="nt">></span>
<span class="nt"><list></span>
<span class="nt"><xsl:merge></span>
<span class="nt"><xsl:merge-source</span> <span class="na">name=</span><span class="s">"master"</span> <span class="na">for-each-source=</span><span class="s">"'input1.xml'"</span> <span class="na">sort-before-merge=</span><span class="s">"yes"</span> <span class="na">select=</span><span class="s">"/list/item"</span><span class="nt">></span>
<span class="nt"><xsl:merge-key</span> <span class="na">select=</span><span class="s">"@id"</span> <span class="na">order=</span><span class="s">"ascending"</span><span class="nt">/></span>
<span class="nt"></xsl:merge-source></span>
</code></pre>
<p>gives an error</p>
<pre><code>Transformation failure: Error XPDY0002 at sheet1.xsl#7
Focus for / is absent
Error XPDY0002 at sheet1.xsl#7
Focus for / is absent
</code></pre>
<p>The code runs fine through Saxon HE 11.5 Java.</p>
<p>Full files attached; command line <code>xslt3 -t -it -xsl:sheet1.xsl</code> gives output</p>
<pre><code>SaxonJS 2.5 from Saxonica
Node.js version v16.17.1
Compiling stylesheet C:\Users\marti\OneDrive\Documents\xslt\blog-xslt-3-by-example\nested-merge\sheet1.xsl
Stylesheet compilation time: 0.342s
Initial template: Q{http://www.w3.org/1999/XSL/Transform}initial-template
Asynchronous transform with options: stylesheetText={"N":"package","version":"30",(string), stylesheetBaseURI=file://C:/Users/marti/OneDrive(string), stylesheetParams=[object Object](string), outputProperties=[object Object](string), extraOptions=[object Object](string), destination=stdout(string), baseOutputURI=file://C:/Users/marti/OneDrive(string), logLevel=2(string), initialTemplate=Q{http://www.w3.org/1999/XSL/T(string),
SEF generated by SaxonJS 2.5 at 2023-03-12T13:32:13.485+01:00
Transformation failure: Error XPDY0002 at sheet1.xsl#7
Focus for / is absent
Error XPDY0002 at sheet1.xsl#7
Focus for / is absent
</code></pre> SaxonJS - Bug #5830 (New): Stylesheets with entity references do not compilehttps://saxonica.plan.io/issues/58302023-01-18T04:33:31ZEvan Lenzevan@lenzconsulting.com
<p>See the attached test.xsl file. When I try to compile it using the latest release:</p>
<pre><code>xslt3 -xsl:test.xsl -export:test.sef.json
</code></pre>
<p>I get the following output:</p>
<pre><code>Error FODC0002:
Failed parsing XML in file://path/to/test.xsl: Reference to unknown entity &REUSABLE_PATTERN; at line 8 column 41
Failed to compile stylesheet
</code></pre>
<p>I did notice feature <a class="issue tracker-2 status-1 priority-2 priority-default" title="Feature: Recognize entity declarations in DTDs (New)" href="https://saxonica.plan.io/issues/4597">#4597</a> ("Recognize entity declarations in DTDs"). However, I believe this should be considered a bug report rather than a feature request, as I believe a conforming XML processor will <em>always</em> be able to recognize entity declarations in the internal DTD subset. This is actually the first time I've ever seen them not recognized in an XML processing context.</p>
<p>I sometimes use them for repeated long XSLT patterns. My temporary workaround is to expand them all (repeating them throughout the stylesheet).</p> SaxonJS - Bug #5807 (New): current() does not work when invoked via xsl:evaluatehttps://saxonica.plan.io/issues/58072023-01-11T17:50:01ZJohn Dziurlaj
<p>When passing the following expression to <code>@xpath</code> of <code>xsl:evaluate</code> in SaxonJS, <code>instance('i2')/month[@code = current()]</code> , I get the error "The current() construct is not implemented in SaxonJS"</p>
<ul>
<li>Stylesheet location (context): <a href="https://github.com/Saxonica/Saxon-Forms/blob/5ab05598219361cfb56b730da9d30409b0726cf1/src/saxon-xforms.xsl#L1468-L1481" class="external">https://github.com/Saxonica/Saxon-Forms/blob/5ab05598219361cfb56b730da9d30409b0726cf1/src/saxon-xforms.xsl#L1468-L1481</a>
</li>
<li>See also: <a href="https://github.com/Saxonica/Saxon-Forms/issues/20" class="external">https://github.com/Saxonica/Saxon-Forms/issues/20</a>
</li>
<li>Normative reference: <a href="https://www.w3.org/TR/xforms11/#fn-current" class="external">https://www.w3.org/TR/xforms11/#fn-current</a>
</li>
</ul>
<p>Note that this error is masked by another error related to namespace declarations, which is more fully described in Saxon-Forms <a class="issue tracker-1 status-3 priority-2 priority-default closed" title="Bug: position variable incorrectly removed in ForClause (Closed)" href="https://saxonica.plan.io/issues/20">#20</a>. (the error can be suppressed by removing the <code>@namespace-context</code> from <code>xsl:evaluate</code>).</p>