https://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2017-07-04T15:22:57ZSaxonica Developer CommunitySaxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=93982017-07-04T15:22:57ZMichael Kaymike@saxonica.com
<ul></ul><p>I think I need to see the source code (or a repro that demonstrates the problem) to understand what's going on here.</p>
<p>If something is public in generalVariables then it should become private within the packages that use it, so this conflict shouldn't happen -- in theory.</p>
<p>The code in this area hasn't had a large amount of exposure except to synthetic small-scale test cases so my instinct is to suspect a bug somewhere: in which case I will need a repro to investigate.</p> Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=94062017-07-05T08:06:39ZMark Dunnmark.dunn@oup.com
<ul><li><strong>File</strong> <a href="/attachments/692">test-packages.zip</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/692/test-packages.zip">test-packages.zip</a> added</li></ul><p>I've attached a set of files with two top-level stylesheets, which illustrate a couple of scenarios.</p>
<a name="test-xslt3-packages-1xsl"></a>
<h1 >test-xslt3-packages-1.xsl<a href="#test-xslt3-packages-1xsl" class="wiki-anchor">¶</a></h1>
<p>Uses "oup-academic-common-package", which uses "logger", "generalFunctions", "generalVariables", and "runner".</p>
<p>"logger" uses "generalVariables"</p>
<p>"generalFunctions" uses "generalVariables"</p>
<p>Error message:</p>
<p>javax.xml.transform.TransformerConfigurationException: net.sf.saxon.s9api.SaxonApiException: Duplicate variable oupdtg:city</p>
<a name="test-xslt3-packages-2xsl"></a>
<h1 >test-xslt3-packages-2.xsl<a href="#test-xslt3-packages-2xsl" class="wiki-anchor">¶</a></h1>
<p>Uses "runner", which uses "logger" and "generalFunctions".</p>
<p>Error message:</p>
<p>java.lang.AssertionError: Saxon can't find the new component corresponding to variable oupdtg:city</p>
<p>Also included is an Ant build file and a batch file which I used to run the transformations using Saxon 9.8 HE. The error messages were the same using both methods of running the transformations.</p> Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=95912017-07-17T13:57:36ZMichael Kaymike@saxonica.com
<ul></ul><p>Sorry for the delay in responding. I've added some internal tracing to the code to show what's going on (it would seem a good idea to productize this). For the first case (packages-1) we have</p>
<p>Adding components from <a href="http://www.oup.com/generalVariables" class="external">http://www.oup.com/generalVariables</a> to <a href="http://www.oup.com/logger" class="external">http://www.oup.com/logger</a></p>
<p>variable oupdtg:city (PUBLIC) becomes PRIVATE</p>
<p>mode xsl:unnamed (PRIVATE) becomes HIDDEN</p>
<p>Adding components from <a href="http://www.oup.com/generalVariables" class="external">http://www.oup.com/generalVariables</a> to <a href="http://www.oup.com/generalFunctions" class="external">http://www.oup.com/generalFunctions</a></p>
<p>variable oupdtg:city (PUBLIC) becomes PRIVATE</p>
<p>mode xsl:unnamed (PRIVATE) becomes HIDDEN</p>
<p>Adding components from <a href="http://www.oup.com/logger" class="external">http://www.oup.com/logger</a> to <a href="http://www.oup.com/runner" class="external">http://www.oup.com/runner</a></p>
<p>template oupdtg:log (PUBLIC) becomes PRIVATE</p>
<p>variable oupdtg:city (PRIVATE) becomes HIDDEN [<em>1</em>]</p>
<p>mode xsl:unnamed (PRIVATE) becomes HIDDEN</p>
<p>Adding components from <a href="http://www.oup.com/generalFunctions" class="external">http://www.oup.com/generalFunctions</a> to <a href="http://www.oup.com/runner" class="external">http://www.oup.com/runner</a></p>
<p>variable oupdtg:city (PRIVATE) becomes HIDDEN</p>
<p>function oupdtg:getCity#0 (PUBLIC) becomes PRIVATE</p>
<p>mode xsl:unnamed (PRIVATE) becomes HIDDEN</p>
<p>Adding components from <a href="http://www.oup.com/logger" class="external">http://www.oup.com/logger</a> to <a href="http://www.oup.com/oup-academic-common-package" class="external">http://www.oup.com/oup-academic-common-package</a></p>
<p>template oupdtg:log (PUBLIC) becomes PRIVATE</p>
<p>variable oupdtg:city (PRIVATE) becomes HIDDEN</p>
<p>mode xsl:unnamed (PRIVATE) becomes HIDDEN</p>
<p>Adding components from <a href="http://www.oup.com/generalFunctions" class="external">http://www.oup.com/generalFunctions</a> to <a href="http://www.oup.com/oup-academic-common-package" class="external">http://www.oup.com/oup-academic-common-package</a></p>
<p>variable oupdtg:city (PRIVATE) becomes HIDDEN</p>
<p>function oupdtg:getCity#0 (PUBLIC) becomes PRIVATE</p>
<p>mode xsl:unnamed (PRIVATE) becomes HIDDEN</p>
<p>Adding components from <a href="http://www.oup.com/generalVariables" class="external">http://www.oup.com/generalVariables</a> to <a href="http://www.oup.com/oup-academic-common-package" class="external">http://www.oup.com/oup-academic-common-package</a></p>
<p>variable oupdtg:city (PUBLIC) becomes PRIVATE</p>
<p>mode xsl:unnamed (PRIVATE) becomes HIDDEN</p>
<p>Adding components from <a href="http://www.oup.com/runner" class="external">http://www.oup.com/runner</a> to <a href="http://www.oup.com/oup-academic-common-package" class="external">http://www.oup.com/oup-academic-common-package</a></p>
<p>template oupdtg:log (PRIVATE) becomes HIDDEN</p>
<p>variable oupdtg:city (PUBLIC) becomes PRIVATE [<em>2</em>]</p>
<p>Error at procedure oupdtg:city on line 19 of generalVariables.xsl:</p>
<p>XTSE3050: Duplicate variable oupdtg:city</p>
<p>Duplicate variable oupdtg:city</p>
<p>Messages labelled [<em>1</em>] and [<em>2</em>] appear to show a contradiction - the variable should be HIDDEN in runner, and therefore remain HIDDEN in academic-common.</p> Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=95922017-07-17T14:58:54ZMichael Kaymike@saxonica.com
<ul></ul><p>What's happening here is specific to global variables (as distinct from other kinds of component). After collecting together all the components acquired from a used package, we allocate slot numbers for space allocation in the Bindery for the package (StylesheetPackage.allocateBinderySlots()). This invokes the method registerGlobalVariable(), which has the side-effect of creating a PUBLIC global variable with the requisite name. This is clearly incorrect.</p>
<p>I'm concerned about another couple of things noticed while analyzing this:</p>
<p>(a) where a package acquires two hidden components with the same name from different packages, they are being merged into one. This seems wrong. The merging happens because StylesheetPackage.hiddenComponents is a map keyed on symbolic name.</p>
<p>(b) the process of acquiring components from a used package seems to ignore hidden components in the used package.</p> Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=95932017-07-17T14:59:24ZMichael Kaymike@saxonica.com
<ul><li><strong>Tracker</strong> changed from <i>Support</i> to <i>Bug</i></li><li><strong>Category</strong> set to <i>XSLT 3.0 packages</i></li><li><strong>Status</strong> changed from <i>New</i> to <i>In Progress</i></li><li><strong>Assignee</strong> set to <i>Michael Kay</i></li><li><strong>Priority</strong> changed from <i>Low</i> to <i>Normal</i></li><li><strong>Applies to branch</strong> <i>9.8</i> added</li></ul> Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=95942017-07-17T15:00:41ZMichael Kaymike@saxonica.com
<ul><li><strong>Subject</strong> changed from <i>Can I create a package containing a hierarchy of used packages?</i> to <i>Using an XSLT 3.0 package indirectly by several routes</i></li></ul> Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=95952017-07-17T15:27:14ZMichael Kaymike@saxonica.com
<ul></ul><p>I've fixed the problems identified above, and compilation of packages-1.xsl now fails with</p>
<pre><code>Static error in {oupdtg:getCity()} in expression in xsl:copy-of/@select on line 16 column 53 of test-xslt3-packages-1.xsl:
XPST0017: Cannot find a matching 0-argument function named {http://www.oup.com/oupdtg}getCity()
Static error at xsl:call-template on line 15 column 51 of test-xslt3-packages-1.xsl:
XTSE0650: No template exists named oupdtg:log
</code></pre>
<p>which is correct, because these components are private in common-package and therefore hidden in packages-1.</p>
<p>Adding</p>
<pre><code><xsl:expose component="*" names="*" visibility="public"/>
</code></pre>
<p>to common-package doesn't help because the components are private in common-package and therefore cannot be exposed as public. Instead I need to insert an xsl:accept element into each xsl:use-package, in the form</p>
<pre><code><xsl:accept component="*" names="*" visibility="public"/>
</code></pre>
<p>after which I get the (presumably) correct result</p>
<pre><code><output><log>Oxford</log><city>Oxford</city></output>
</code></pre> Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=95962017-07-17T15:29:35ZMichael Kaymike@saxonica.com
<ul></ul><p>Confirmed that the above changes cause no regression in test-sets package, use-package, expose, accept, or override.</p> Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=95972017-07-17T15:32:13ZMichael Kaymike@saxonica.com
<ul></ul><p>The second test, test-packages-2, also runs successfully after making these changes.</p> Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=95982017-07-17T15:56:02ZMark Dunnmark.dunn@oup.com
<ul></ul><p>That's the correct output, and adding the <a href="xsl:accept/" class="external">xsl:accept/</a> statement to common-package to produce it makes sense to me.</p>
<p>Glad to be of help flushing out this issue!</p> Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=96022017-07-19T09:44:31ZMichael Kaymike@saxonica.com
<ul><li><strong>Status</strong> changed from <i>In Progress</i> to <i>Resolved</i></li></ul> Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=97172017-08-09T13:56:18ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Has duplicate</strong> <i><a class="issue tracker-1 status-4 priority-2 priority-default closed" href="/issues/3367">Bug #3367</a>: function not found inside xslt package</i> added</li></ul> Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=98812017-08-16T10:45:12ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li><li><strong>Fix Committed on Branch</strong> <i>9.8</i> added</li></ul> Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routeshttps://saxonica.plan.io/issues/3333?journal_id=98892017-08-16T10:50:57ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li><li><strong>Fixed in Maintenance Release</strong> <i>9.8.0.4</i> added</li></ul><p>Bug fix applied in the Saxon 9.8.0.4 maintenance release.</p>