Assertion error in package override

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Assertion error in package override

Toshihiko Makita
Hi,

I have a lot of XSLT 2.0 stylesheet modules and I want to convert them
into XSLT 3.0 package. But following test program ended with assertion.

[Saxon config file]
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://saxon.sf.net/ns/configuration"
     edition="EE">
     <xsltPackages>
         <package name="urn:test:pkg:xslt3" version="1.0"
sourceLocation="test-pkg-xslt3.xsl"/>
         <package name="urn:test:use:pkg:xslt3" version="1.0"
sourceLocation="test-use-pkg-xslt3.xsl"/>
     </xsltPackages>
</configuration>

[input.xml]
<?xml version="1.0" encoding="UTF-8"?>
<dita-doc>
     <ph class="- topic/ph ">Phrase text</ph>
     <b class="+ topic/ph hi-d/b ">Bold text</b>
</dita-doc>

[Main Package]
<?xml version="1.0" encoding="UTF-8"?>
<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:math="http://www.w3.org/2005/xpath-functions/math"
     xmlns:fo="http://www.w3.org/1999/XSL/Format"
     xmlns:ahf="http://www.antennahouse.com/Names/XSLT/Document"
     exclude-result-prefixes="xs math ahf"
     version="3.0"
     name="urn:test:pkg:xslt3:main">

     <xsl:use-package name="urn:test:use:pkg:xslt3"/>

     <xsl:mode/>

     <xsl:template match="/*">
         <fo:block>
             <xsl:copy-of select="ahf:setRed()"/>
             <xsl:apply-templates mode="normal"/>
         </fo:block>
     </xsl:template>

</xsl:package>

[test-use-pkg-xslt3.xsl]
<?xml version="1.0" encoding="UTF-8"?>
<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:fo="http://www.w3.org/1999/XSL/Format"
     package-version="1.0"
     name="urn:test:use:pkg:xslt3"
     exclude-result-prefixes="xs"
     version="3.0">

     <xsl:mode/>

     <xsl:use-package name="urn:test:pkg:xslt3" package-version="1.0">
         <xsl:accept component="template" names="*" visibility="public" />
         <xsl:override default-mode="normal">
             <xsl:template match="*[contains(@class,' topic/ph ')]">
                 <fo:inline>
                     <xsl:text>ph:</xsl:text>
                     <xsl:apply-templates/>
                 </fo:inline>
             </xsl:template>
         </xsl:override>
     </xsl:use-package>

</xsl:package>

[test-pkg-xslt3.xsl]
<?xml version="1.0" encoding="UTF-8"?>
<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:fo="http://www.w3.org/1999/XSL/Format"
     xmlns:ahf="http://www.antennahouse.com/Names/XSLT/Document"
     package-version="1.0"
     name="urn:test:pkg:xslt3"
     exclude-result-prefixes="xs ahf"
     version="3.0"
     default-mode="normal">

     <xsl:mode name="normal" visibility="public"/>
     <xsl:mode/>

     <xsl:template match="*[contains(@class,' topic/ph ')]" name="tplPh">
         <fo:inline>
             <xsl:apply-templates/>
         </fo:inline>
     </xsl:template>

     <xsl:template match="*[contains(@class,' hi-d/b ')]" priority="2"
name="tplB">
         <fo:inline font-weight="bold">
             <xsl:apply-templates/>
         </fo:inline>
     </xsl:template>

     <xsl:function name="ahf:setRed" as="attribute()*" visibility="public">
         <xsl:attribute name="color" select="'red'"/>
     </xsl:function>

</xsl:package>

[The assertion]

C:\Users\toshi\OneDrive\Documents\test\xslt\20170423-package>java -jar
D:\My_Documents\Java\SaxonEE9-8-0-3J\saxon9ee.jar
  -s:input.xml -o:output-xslt3.xml -xsl:test-pkg-main-xslt3.xsl
-config:config.xml
Exception in thread "main" java.lang.AssertionError: **** Component
reference mode normal is already bound
         at
net.sf.saxon.expr.instruct.Actor.processComponentReference(Actor.java:145)
         at
net.sf.saxon.expr.instruct.Actor.allocateBindingSlotsRecursive(Actor.java:108)
         at
net.sf.saxon.expr.instruct.Actor.allocateBindingSlotsRecursive(Actor.java:111)
         at
net.sf.saxon.expr.instruct.Actor.allocateBindingSlotsRecursive(Actor.java:111)
         at
net.sf.saxon.expr.instruct.Actor.allocateBindingSlotsRecursive(Actor.java:111)
         at net.sf.saxon.trans.SimpleMode$2.processRule(SimpleMode.java:943)
         at
net.sf.saxon.trans.SimpleMode.processRuleChain(SimpleMode.java:1140)
         at net.sf.saxon.trans.SimpleMode.processRules(SimpleMode.java:1066)
         at net.sf.saxon.trans.SimpleMode.processRules(SimpleMode.java:1054)
         at
net.sf.saxon.trans.SimpleMode.forceAllocateAllBindingSlots(SimpleMode.java:937)
         at
net.sf.saxon.trans.CompoundMode.allocateAllBindingSlots(CompoundMode.java:158)
         at
net.sf.saxon.style.PrincipalStylesheetModule.compile(PrincipalStylesheetModule.java:1367)
         at
net.sf.saxon.style.Compilation.compilePackage(Compilation.java:328)
         at
net.sf.saxon.style.StylesheetModule.loadStylesheet(StylesheetModule.java:257)
         at
net.sf.saxon.style.Compilation.compileSingletonPackage(Compilation.java:106)
         at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:743)
         at net.sf.saxon.Transform.doTransform(Transform.java:701)
         at net.sf.saxon.Transform.main(Transform.java:81)

If the stylesheet contains any mistakes, please indicate it to me as I'm
a beginner of XSLT 3.0 package,

Regards,

--
/*--------------------------------------------------
  Toshihiko Makita
  Development Group. Antenna House, Inc. Ina Branch
  E-Mail [hidden email]
  8077-1 Horikita Minamiminowa Vil. Kamiina Co.
  Nagano Pref. 399-4511 Japan
  Tel +81-265-76-9300 Fax +81-265-78-1668
  Web site:
  http://www.antenna.co.jp/
  http://www.antennahouse.com/
  --------------------------------------------------*/


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Assertion error in package override

Michael Kay
Thanks for submitting it. We can assume that an internal AssertionError is a Saxon bug - at the very least, if you've done something wrong then it should give you sensible diagnostics.

Several people seem to have started using packages seriously in the last couple of weeks so a few internal problems are being uncovered. The feedback is very welcome. I'm afraid most of the test cases for packages are rather miniscule and there's a real need for tests with a more realistic level of complexity.

Michael Kay
Saxonica

> On 17 Jul 2017, at 15:50, Toshihiko Makita <[hidden email]> wrote:
>
> Hi,
>
> I have a lot of XSLT 2.0 stylesheet modules and I want to convert them into XSLT 3.0 package. But following test program ended with assertion.
>
> [Saxon config file]
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration xmlns="http://saxon.sf.net/ns/configuration"
>    edition="EE">
>    <xsltPackages>
>        <package name="urn:test:pkg:xslt3" version="1.0" sourceLocation="test-pkg-xslt3.xsl"/>
>        <package name="urn:test:use:pkg:xslt3" version="1.0" sourceLocation="test-use-pkg-xslt3.xsl"/>
>    </xsltPackages>
> </configuration>
>
> [input.xml]
> <?xml version="1.0" encoding="UTF-8"?>
> <dita-doc>
>    <ph class="- topic/ph ">Phrase text</ph>
>    <b class="+ topic/ph hi-d/b ">Bold text</b>
> </dita-doc>
>
> [Main Package]
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    xmlns:math="http://www.w3.org/2005/xpath-functions/math"
>    xmlns:fo="http://www.w3.org/1999/XSL/Format"
>    xmlns:ahf="http://www.antennahouse.com/Names/XSLT/Document"
>    exclude-result-prefixes="xs math ahf"
>    version="3.0"
>    name="urn:test:pkg:xslt3:main">
>
>    <xsl:use-package name="urn:test:use:pkg:xslt3"/>
>
>    <xsl:mode/>
>
>    <xsl:template match="/*">
>        <fo:block>
>            <xsl:copy-of select="ahf:setRed()"/>
>            <xsl:apply-templates mode="normal"/>
>        </fo:block>
>    </xsl:template>
>
> </xsl:package>
>
> [test-use-pkg-xslt3.xsl]
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    xmlns:fo="http://www.w3.org/1999/XSL/Format"
>    package-version="1.0"
>    name="urn:test:use:pkg:xslt3"
>    exclude-result-prefixes="xs"
>    version="3.0">
>
>    <xsl:mode/>
>
>    <xsl:use-package name="urn:test:pkg:xslt3" package-version="1.0">
>        <xsl:accept component="template" names="*" visibility="public" />
>        <xsl:override default-mode="normal">
>            <xsl:template match="*[contains(@class,' topic/ph ')]">
>                <fo:inline>
>                    <xsl:text>ph:</xsl:text>
>                    <xsl:apply-templates/>
>                </fo:inline>
>            </xsl:template>
>        </xsl:override>
>    </xsl:use-package>
>
> </xsl:package>
>
> [test-pkg-xslt3.xsl]
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    xmlns:fo="http://www.w3.org/1999/XSL/Format"
>    xmlns:ahf="http://www.antennahouse.com/Names/XSLT/Document"
>    package-version="1.0"
>    name="urn:test:pkg:xslt3"
>    exclude-result-prefixes="xs ahf"
>    version="3.0"
>    default-mode="normal">
>
>    <xsl:mode name="normal" visibility="public"/>
>    <xsl:mode/>
>
>    <xsl:template match="*[contains(@class,' topic/ph ')]" name="tplPh">
>        <fo:inline>
>            <xsl:apply-templates/>
>        </fo:inline>
>    </xsl:template>
>
>    <xsl:template match="*[contains(@class,' hi-d/b ')]" priority="2" name="tplB">
>        <fo:inline font-weight="bold">
>            <xsl:apply-templates/>
>        </fo:inline>
>    </xsl:template>
>
>    <xsl:function name="ahf:setRed" as="attribute()*" visibility="public">
>        <xsl:attribute name="color" select="'red'"/>
>    </xsl:function>
>
> </xsl:package>
>
> [The assertion]
>
> C:\Users\toshi\OneDrive\Documents\test\xslt\20170423-package>java -jar D:\My_Documents\Java\SaxonEE9-8-0-3J\saxon9ee.jar
> -s:input.xml -o:output-xslt3.xml -xsl:test-pkg-main-xslt3.xsl -config:config.xml
> Exception in thread "main" java.lang.AssertionError: **** Component reference mode normal is already bound
>        at net.sf.saxon.expr.instruct.Actor.processComponentReference(Actor.java:145)
>        at net.sf.saxon.expr.instruct.Actor.allocateBindingSlotsRecursive(Actor.java:108)
>        at net.sf.saxon.expr.instruct.Actor.allocateBindingSlotsRecursive(Actor.java:111)
>        at net.sf.saxon.expr.instruct.Actor.allocateBindingSlotsRecursive(Actor.java:111)
>        at net.sf.saxon.expr.instruct.Actor.allocateBindingSlotsRecursive(Actor.java:111)
>        at net.sf.saxon.trans.SimpleMode$2.processRule(SimpleMode.java:943)
>        at net.sf.saxon.trans.SimpleMode.processRuleChain(SimpleMode.java:1140)
>        at net.sf.saxon.trans.SimpleMode.processRules(SimpleMode.java:1066)
>        at net.sf.saxon.trans.SimpleMode.processRules(SimpleMode.java:1054)
>        at net.sf.saxon.trans.SimpleMode.forceAllocateAllBindingSlots(SimpleMode.java:937)
>        at net.sf.saxon.trans.CompoundMode.allocateAllBindingSlots(CompoundMode.java:158)
>        at net.sf.saxon.style.PrincipalStylesheetModule.compile(PrincipalStylesheetModule.java:1367)
>        at net.sf.saxon.style.Compilation.compilePackage(Compilation.java:328)
>        at net.sf.saxon.style.StylesheetModule.loadStylesheet(StylesheetModule.java:257)
>        at net.sf.saxon.style.Compilation.compileSingletonPackage(Compilation.java:106)
>        at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:743)
>        at net.sf.saxon.Transform.doTransform(Transform.java:701)
>        at net.sf.saxon.Transform.main(Transform.java:81)
>
> If the stylesheet contains any mistakes, please indicate it to me as I'm a beginner of XSLT 3.0 package,
>
> Regards,
>
> --
> /*--------------------------------------------------
> Toshihiko Makita
> Development Group. Antenna House, Inc. Ina Branch
> E-Mail [hidden email]
> 8077-1 Horikita Minamiminowa Vil. Kamiina Co.
> Nagano Pref. 399-4511 Japan
> Tel +81-265-76-9300 Fax +81-265-78-1668
> Web site:
> http://www.antenna.co.jp/
> http://www.antennahouse.com/
> --------------------------------------------------*/
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Assertion error in package override

Michael Kay
In reply to this post by Toshihiko Makita
I have turned this into W3C test case use-package-170.

After applying the fixes for bug 3333 (see https://saxonica.plan.io/issues/3333), I get the output

Static error in {ahf:setRed()} in expression in xsl:copy-of/@select on line 17 column 49 of use-package-170a.xsl:
  XPST0017: Cannot find a 0-argument function named
  {http://www.antennahouse.com/Names/XSLT/Document}setRed()
Static error at xsl:apply-templates on line 18 column 49 of use-package-170a.xsl:
  XTSE3085: Mode name normal must be explicitly declared in an xsl:mode declaration

The first error is legitimate: the setRed() function is public in the package where it is declared, but private in urn:test:use:pkg:xslt3, so it must be accepted as public if it is to be visible in the top-level package.

The second error is also legitimate. However, attempting to fix it by accepting the mode with public visibility doesn't seem to work. With some attempts I get the AssertionError that you are experiencing; with others I get a spurious error XTSE3085. I am investigating this one; it seems to be a bug.

Michael Kay
Saxonica


> On 17 Jul 2017, at 15:50, Toshihiko Makita <[hidden email]> wrote:
>
> Hi,
>
> I have a lot of XSLT 2.0 stylesheet modules and I want to convert them into XSLT 3.0 package. But following test program ended with assertion.
>
> [Saxon config file]
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration xmlns="http://saxon.sf.net/ns/configuration"
>    edition="EE">
>    <xsltPackages>
>        <package name="urn:test:pkg:xslt3" version="1.0" sourceLocation="test-pkg-xslt3.xsl"/>
>        <package name="urn:test:use:pkg:xslt3" version="1.0" sourceLocation="test-use-pkg-xslt3.xsl"/>
>    </xsltPackages>
> </configuration>
>
> [input.xml]
> <?xml version="1.0" encoding="UTF-8"?>
> <dita-doc>
>    <ph class="- topic/ph ">Phrase text</ph>
>    <b class="+ topic/ph hi-d/b ">Bold text</b>
> </dita-doc>
>
> [Main Package]
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    xmlns:math="http://www.w3.org/2005/xpath-functions/math"
>    xmlns:fo="http://www.w3.org/1999/XSL/Format"
>    xmlns:ahf="http://www.antennahouse.com/Names/XSLT/Document"
>    exclude-result-prefixes="xs math ahf"
>    version="3.0"
>    name="urn:test:pkg:xslt3:main">
>
>    <xsl:use-package name="urn:test:use:pkg:xslt3"/>
>
>    <xsl:mode/>
>
>    <xsl:template match="/*">
>        <fo:block>
>            <xsl:copy-of select="ahf:setRed()"/>
>            <xsl:apply-templates mode="normal"/>
>        </fo:block>
>    </xsl:template>
>
> </xsl:package>
>
> [test-use-pkg-xslt3.xsl]
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    xmlns:fo="http://www.w3.org/1999/XSL/Format"
>    package-version="1.0"
>    name="urn:test:use:pkg:xslt3"
>    exclude-result-prefixes="xs"
>    version="3.0">
>
>    <xsl:mode/>
>
>    <xsl:use-package name="urn:test:pkg:xslt3" package-version="1.0">
>        <xsl:accept component="template" names="*" visibility="public" />
>        <xsl:override default-mode="normal">
>            <xsl:template match="*[contains(@class,' topic/ph ')]">
>                <fo:inline>
>                    <xsl:text>ph:</xsl:text>
>                    <xsl:apply-templates/>
>                </fo:inline>
>            </xsl:template>
>        </xsl:override>
>    </xsl:use-package>
>
> </xsl:package>
>
> [test-pkg-xslt3.xsl]
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    xmlns:fo="http://www.w3.org/1999/XSL/Format"
>    xmlns:ahf="http://www.antennahouse.com/Names/XSLT/Document"
>    package-version="1.0"
>    name="urn:test:pkg:xslt3"
>    exclude-result-prefixes="xs ahf"
>    version="3.0"
>    default-mode="normal">
>
>    <xsl:mode name="normal" visibility="public"/>
>    <xsl:mode/>
>
>    <xsl:template match="*[contains(@class,' topic/ph ')]" name="tplPh">
>        <fo:inline>
>            <xsl:apply-templates/>
>        </fo:inline>
>    </xsl:template>
>
>    <xsl:template match="*[contains(@class,' hi-d/b ')]" priority="2" name="tplB">
>        <fo:inline font-weight="bold">
>            <xsl:apply-templates/>
>        </fo:inline>
>    </xsl:template>
>
>    <xsl:function name="ahf:setRed" as="attribute()*" visibility="public">
>        <xsl:attribute name="color" select="'red'"/>
>    </xsl:function>
>
> </xsl:package>
>
> [The assertion]
>
> C:\Users\toshi\OneDrive\Documents\test\xslt\20170423-package>java -jar D:\My_Documents\Java\SaxonEE9-8-0-3J\saxon9ee.jar
> -s:input.xml -o:output-xslt3.xml -xsl:test-pkg-main-xslt3.xsl -config:config.xml
> Exception in thread "main" java.lang.AssertionError: **** Component reference mode normal is already bound
>        at net.sf.saxon.expr.instruct.Actor.processComponentReference(Actor.java:145)
>        at net.sf.saxon.expr.instruct.Actor.allocateBindingSlotsRecursive(Actor.java:108)
>        at net.sf.saxon.expr.instruct.Actor.allocateBindingSlotsRecursive(Actor.java:111)
>        at net.sf.saxon.expr.instruct.Actor.allocateBindingSlotsRecursive(Actor.java:111)
>        at net.sf.saxon.expr.instruct.Actor.allocateBindingSlotsRecursive(Actor.java:111)
>        at net.sf.saxon.trans.SimpleMode$2.processRule(SimpleMode.java:943)
>        at net.sf.saxon.trans.SimpleMode.processRuleChain(SimpleMode.java:1140)
>        at net.sf.saxon.trans.SimpleMode.processRules(SimpleMode.java:1066)
>        at net.sf.saxon.trans.SimpleMode.processRules(SimpleMode.java:1054)
>        at net.sf.saxon.trans.SimpleMode.forceAllocateAllBindingSlots(SimpleMode.java:937)
>        at net.sf.saxon.trans.CompoundMode.allocateAllBindingSlots(CompoundMode.java:158)
>        at net.sf.saxon.style.PrincipalStylesheetModule.compile(PrincipalStylesheetModule.java:1367)
>        at net.sf.saxon.style.Compilation.compilePackage(Compilation.java:328)
>        at net.sf.saxon.style.StylesheetModule.loadStylesheet(StylesheetModule.java:257)
>        at net.sf.saxon.style.Compilation.compileSingletonPackage(Compilation.java:106)
>        at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:743)
>        at net.sf.saxon.Transform.doTransform(Transform.java:701)
>        at net.sf.saxon.Transform.main(Transform.java:81)
>
> If the stylesheet contains any mistakes, please indicate it to me as I'm a beginner of XSLT 3.0 package,
>
> Regards,
>
> --
> /*--------------------------------------------------
> Toshihiko Makita
> Development Group. Antenna House, Inc. Ina Branch
> E-Mail [hidden email]
> 8077-1 Horikita Minamiminowa Vil. Kamiina Co.
> Nagano Pref. 399-4511 Japan
> Tel +81-265-76-9300 Fax +81-265-78-1668
> Web site:
> http://www.antenna.co.jp/
> http://www.antennahouse.com/
> --------------------------------------------------*/
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Loading...