Project

Profile

Help

Bug #4562

java.lang.UnsupportedOperationException relating to typing of template parameters

Added by Peter Charles 2 months ago. Updated 15 days ago.

Status:
Duplicate
Priority:
Low
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2020-05-27
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:

Description

The following input xml and stylsheet work fine in saxon-he-9.x and 10.0, but fail in 10.1 when the param level has 1 subtracted the following error is generated:

java.lang.UnsupportedOperationException at net.sf.saxon.value.UntypedAtomicValue.copyAsSubType(UntypedAtomicValue.java:46) at net.sf.saxon.type.Converter$UpCastingConverter.convert(Converter.java:188) at net.sf.saxon.type.Converter$UpCastingConverter.convert(Converter.java:180) at net.sf.saxon.expr.CastExpression.doCast(CastExpression.java:376) at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:395) at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:30) at net.sf.saxon.expr.ValueComparison.effectiveBooleanValue(ValueComparison.java:347) at net.sf.saxon.expr.instruct.Choose.choose(Choose.java:946) at net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:920) at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:736) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:374) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:555) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:562) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:473) at net.sf.saxon.trans.XsltController.applyTemplates(XsltController.java:659) at net.sf.saxon.s9api.AbstractXsltTransformer.applyTemplatesToSource(AbstractXsltTransformer.java:360) at net.sf.saxon.s9api.Xslt30Transformer.applyTemplates(Xslt30Transformer.java:285) at net.sf.saxon.Transform.processFile(Transform.java:1313) at net.sf.saxon.Transform.doTransform(Transform.java:853) at net.sf.saxon.Transform.main(Transform.java:82)

XML Input

<?xml version="1.0" encoding="UTF-8"?>
<test>
    <ol>
        <li data-list-id="0" data-list-level="0">
            <div>level one</div>
            <ol>
                <li data-list-id="1" data-list-level="0">
                    <div>level two</div>
                    <ol>
                        <li data-list-id="1"  data-list-level="1">
                            <div>level three</div> 
                        </li>
                    </ol>
                </li>
            </ol>
        </li>
    </ol>
</test>

STYLESHEET

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3"  xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xsl:template match="/">
        <xsl:apply-templates select="descendant::li[not(ol)]"/>
    </xsl:template>
    <xsl:template match="li[not(ol)]">
            <xsl:call-template name="analyze-list">
                <xsl:with-param name="id" select="@data-list-id"/> 
                <xsl:with-param name="level" select="@data-list-level"/>
                <xsl:with-param name="count">0</xsl:with-param>
            </xsl:call-template>
    </xsl:template>
    <xsl:template name="analyze-list">
        <xsl:param name="id"/>
        <xsl:param name="count"/> 
        <xsl:param name="level"/>
        <xsl:apply-templates select="ancestor::li[1]" mode="analyze"> 
            <xsl:with-param name="level" select="@data-list-level"/>
        </xsl:apply-templates>
    </xsl:template>
    <xsl:template match="li" mode="analyze"> 
        <xsl:param name="level"/>
        <xsl:choose>
            <!-- works 
                <xsl:when test="@data-list-level = xs:integer($level) - 1">  -->
            <!-- fails -->
                 <xsl:when test="@data-list-level = ($level - 1)">
            <!-- works 
                <xsl:when test="$level = (@data-list-level + 1)">  --> 
                <xsl:element name="fail"/>
            </xsl:when> 
            <xsl:otherwise>
                <xsl:element name="list-depth"> 
                    <xsl:attribute name="count" select="$level+1"/>
                </xsl:element>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="@*|node()">
        <xsl:apply-templates select="@*|node()"/>
    </xsl:template>
     
</xsl:stylesheet>

History

#1 Updated by Michael Kay 2 months ago

This looks likely to be a duplicate of bug #4556, but I will check.

#2 Updated by Michael Kay 15 days ago

  • Status changed from New to Duplicate

Please register to edit this issue

Also available in: Atom PDF