Project

Profile

Help

SaxonC 11.99/12 EE can't run its SEF: java.lang.ClassCastException: net.sf.saxon.type.AnyItemType cannot be cast to net.sf.saxon.type.BuiltInAtomicType

Added by Martin Honnen about 1 year ago

While my main aim was to have an SEF for SaxonC HE 11.99/12 I have also now tried to run the SEF compilation result EE produces through EE itself, kind of suprisingly it goes down with an error:

SaxonC-EE 12.0 from Saxonica
java.lang.ClassCastException: net.sf.saxon.type.AnyItemType cannot be cast to net.sf.saxon.type.BuiltInAtomicType
	at net.sf.saxon.expr.ValueComparison$ValueComparisonElaborator.elaborateForItem(ValueComparison.java:548)
	at net.sf.saxon.expr.elab.ItemElaborator.elaborateForPull(ItemElaborator.java:23)
	at net.sf.saxon.expr.FilterExpression$FilterExprElaborator.elaborateForPull(FilterExpression.java:1298)
	at net.sf.saxon.expr.VennExpression$VennElaborator.gatherUnionLeafEvaluators(VennExpression.java:841)
	at net.sf.saxon.expr.VennExpression$VennElaborator.elaborateForPull(VennExpression.java:815)
	at net.sf.saxon.expr.FirstItemExpression$FirstItemExprElaborator.elaborateForItem(FirstItemExpression.java:164)
	at net.sf.saxon.expr.elab.ItemElaborator.elaborateForPull(ItemElaborator.java:23)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.elaborateForPull(LetExpression.java:928)
	at net.sf.saxon.expr.elab.Elaborator.lazily(Elaborator.java:105)
	at net.sf.saxon.expr.LetExpression.setEvaluator(LetExpression.java:404)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.makeSequenceEvaluator(LetExpression.java:809)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.setAllVariables(LetExpression.java:847)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.elaborateForPush(LetExpression.java:941)
	at net.sf.saxon.expr.instruct.ForEach$ForEachElaborator.elaborateForPush(ForEach.java:698)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.elaborateForPush(Block.java:846)
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:270)
	at net.sf.saxon.expr.instruct.CallTemplate$CallTemplateElaborator.lambda$elaborateForPush$1(CallTemplate.java:636)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$2(Block.java:864)
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:274)
	at net.sf.saxon.expr.instruct.CallTemplate$CallTemplateElaborator.lambda$elaborateForPush$1(CallTemplate.java:636)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:898)
	at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$2(Block.java:870)
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:274)
	at net.sf.saxon.expr.instruct.CallTemplate$CallTemplateElaborator.lambda$elaborateForPush$1(CallTemplate.java:636)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$2(Block.java:870)
	at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:653)
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:396)
	at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:568)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:502)
	at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$2(Block.java:870)
	at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$1(Block.java:854)
	at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$1(Block.java:856)
	at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:898)
	at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$3(Block.java:888)
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:396)
	at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:568)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:502)
	at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$2(Block.java:870)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$elaborateForPush$6(LetExpression.java:948)
	at net.sf.saxon.expr.instruct.ForEachGroup$ForEachGroupElaborator.lambda$elaborateForPush$6(ForEachGroup.java:894)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:898)
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:274)
	at net.sf.saxon.expr.instruct.CallTemplate$CallTemplateElaborator.lambda$elaborateForPush$1(CallTemplate.java:636)
	at net.sf.saxon.expr.elab.PushElaborator.lambda$elaborateForPull$0(PushElaborator.java:26)
	at net.sf.saxon.expr.CardinalityChecker$CardinalityCheckerElaborator.lambda$elaborateForPull$0(CardinalityChecker.java:503)
	at net.sf.saxon.expr.ItemChecker$ItemCheckerElaborator.lambda$elaborateForPull$0(ItemChecker.java:454)
	at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:27)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$setAllVariables$4(LetExpression.java:905)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$elaborateForPush$6(LetExpression.java:946)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$1(Block.java:856)
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:274)
	at net.sf.saxon.expr.instruct.CallTemplate$CallTemplatePackage.processLeavingTail(CallTemplate.java:517)
	at net.sf.saxon.trans.rules.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:74)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:499)
	at net.sf.saxon.trans.XsltController.applyTemplates(XsltController.java:684)
	at net.sf.saxon.s9api.AbstractXsltTransformer.applyTemplatesToSource(AbstractXsltTransformer.java:427)
	at net.sf.saxon.s9api.Xslt30Transformer.applyTemplates(Xslt30Transformer.java:304)
	at net.sf.saxon.option.cpp.Xslt30Processor.applyTemplatesReturningValue(Xslt30Processor.java:569)
java.lang.RuntimeException: Internal error evaluating template rule 
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:411)
	at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:568)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:502)
	at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$2(Block.java:870)
	at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$1(Block.java:854)
	at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$1(Block.java:856)
	at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:898)
	at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$3(Block.java:888)
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:396)
	at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:568)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:502)
	at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$2(Block.java:870)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$elaborateForPush$6(LetExpression.java:948)
	at net.sf.saxon.expr.instruct.ForEachGroup$ForEachGroupElaborator.lambda$elaborateForPush$6(ForEachGroup.java:894)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:898)
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:274)
	at net.sf.saxon.expr.instruct.CallTemplate$CallTemplateElaborator.lambda$elaborateForPush$1(CallTemplate.java:636)
	at net.sf.saxon.expr.elab.PushElaborator.lambda$elaborateForPull$0(PushElaborator.java:26)
	at net.sf.saxon.expr.CardinalityChecker$CardinalityCheckerElaborator.lambda$elaborateForPull$0(CardinalityChecker.java:503)
	at net.sf.saxon.expr.ItemChecker$ItemCheckerElaborator.lambda$elaborateForPull$0(ItemChecker.java:454)
	at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:27)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$setAllVariables$4(LetExpression.java:905)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$elaborateForPush$6(LetExpression.java:946)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$1(Block.java:856)
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:274)
	at net.sf.saxon.expr.instruct.CallTemplate$CallTemplatePackage.processLeavingTail(CallTemplate.java:517)
	at net.sf.saxon.trans.rules.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:74)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:499)
	at net.sf.saxon.trans.XsltController.applyTemplates(XsltController.java:684)
	at net.sf.saxon.s9api.AbstractXsltTransformer.applyTemplatesToSource(AbstractXsltTransformer.java:427)
	at net.sf.saxon.s9api.Xslt30Transformer.applyTemplates(Xslt30Transformer.java:304)
	at net.sf.saxon.option.cpp.Xslt30Processor.applyTemplatesReturningValue(Xslt30Processor.java:569)
Caused by: java.lang.ClassCastException: net.sf.saxon.type.AnyItemType cannot be cast to net.sf.saxon.type.BuiltInAtomicType
	at net.sf.saxon.expr.ValueComparison$ValueComparisonElaborator.elaborateForItem(ValueComparison.java:548)
	at net.sf.saxon.expr.elab.ItemElaborator.elaborateForPull(ItemElaborator.java:23)
	at net.sf.saxon.expr.FilterExpression$FilterExprElaborator.elaborateForPull(FilterExpression.java:1298)
	at net.sf.saxon.expr.VennExpression$VennElaborator.gatherUnionLeafEvaluators(VennExpression.java:841)
	at net.sf.saxon.expr.VennExpression$VennElaborator.elaborateForPull(VennExpression.java:815)
	at net.sf.saxon.expr.FirstItemExpression$FirstItemExprElaborator.elaborateForItem(FirstItemExpression.java:164)
	at net.sf.saxon.expr.elab.ItemElaborator.elaborateForPull(ItemElaborator.java:23)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.elaborateForPull(LetExpression.java:928)
	at net.sf.saxon.expr.elab.Elaborator.lazily(Elaborator.java:105)
	at net.sf.saxon.expr.LetExpression.setEvaluator(LetExpression.java:404)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.makeSequenceEvaluator(LetExpression.java:809)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.setAllVariables(LetExpression.java:847)
	at net.sf.saxon.expr.LetExpression$LetExprElaborator.elaborateForPush(LetExpression.java:941)
	at net.sf.saxon.expr.instruct.ForEach$ForEachElaborator.elaborateForPush(ForEach.java:698)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.elaborateForPush(Block.java:846)
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:270)
	at net.sf.saxon.expr.instruct.CallTemplate$CallTemplateElaborator.lambda$elaborateForPush$1(CallTemplate.java:636)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$2(Block.java:864)
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:274)
	at net.sf.saxon.expr.instruct.CallTemplate$CallTemplateElaborator.lambda$elaborateForPush$1(CallTemplate.java:636)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:898)
	at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:653)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$2(Block.java:870)
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:274)
	at net.sf.saxon.expr.instruct.CallTemplate$CallTemplateElaborator.lambda$elaborateForPush$1(CallTemplate.java:636)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$2(Block.java:870)
	at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:653)
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:396)
	... 37 more
Compiling Schematron failed Internal error evaluating template rule

I will attach the SEF and sample .sch file the SEF is run against.

The Python code producing the error is

from saxonc import *

# schxslt_dir = r'C:\Users\marti\OneDrive\Documents\schematron\schxslt-1.9.4\2.0'
# schxslt_xslt = r'pipeline-for-svrl.xsl.SaxonEE114Compiled.sef' #r'pipeline-for-svrl.xsl'
#
# sample_xml = r'C:\Users\marti\OneDrive\Documents\schematron\streaming\examples\BookPrice\books.xml'
# sample_schematron = r'C:\Users\marti\OneDrive\Documents\schematron\streaming\examples\BookPrice\price.sch'
schxslt_dir = r'C:/Users/marti/OneDrive/Documents/schematron/schxslt-1.9.4/2.0'
schxslt_xslt = r'pipeline-for-svrl.xsl.SaxonEE124Compiled.sef' #r'pipeline-for-svrl.xsl.SaxonEE114Compiled.sef' #r'pipeline-for-svrl.xsl'

sample_xml = r'C:/Users/marti/OneDrive/Documents/schematron/streaming/examples/BookPrice/books.xml'
sample_schematron = r'C:/Users/marti/OneDrive/Documents/schematron/streaming/examples/BookPrice/price.sch'

with PySaxonProcessor(license=True) as proc:
    print(proc.version)

    xslt30_processor = proc.new_xslt30_processor()
    compiled_schxslt = xslt30_processor.compile_stylesheet(stylesheet_file = schxslt_dir + '/' + schxslt_xslt)

    if xslt30_processor.exception_occurred:
        print("Schxslt compilation failed", xslt30_processor.error_message)
    else:
        compiled_schema = compiled_schxslt.apply_templates_returning_value(source_file = sample_schematron)

        if compiled_schxslt.exception_occurred:
            print("Compiling Schematron failed", compiled_schxslt.error_message)
        else:
            xslt30_processor = proc.new_xslt30_processor()
            compiled_schema = xslt30_processor.compile_stylesheet(stylesheet_node = compiled_schema.head)

            if xslt30_processor.exception_occurred:
                print(xslt30_processor.error_message)
            else:
                svrl_report = compiled_schema.apply_templates_returning_string(source_file = sample_xml)

                print(svrl_report)

I am reporting it here on the SaxonC forum as I have no way currently to run it with 11.99/12 from the command line.


Replies (7)

Please register to reply

RE: SaxonC 11.99/12 EE can't run its SEF: java.lang.ClassCastException: net.sf.saxon.type.AnyItemType cannot be cast to net.sf.saxon.type.BuiltInAtomicType - Added by Martin Honnen about 1 year ago

Running the pipeline-for-svrl.xsl from which the SEF was compiled directly through SaxonC 11.99 EE or HE works fine.

RE: SaxonC 11.99/12 EE can't run its SEF: java.lang.ClassCastException: net.sf.saxon.type.AnyItemType cannot be cast to net.sf.saxon.type.BuiltInAtomicType - Added by Martin Honnen about 1 year ago

Is anyone of you Saxonica guys able to try to reproduce that with the command line versions of SaxonC EE or SaxonJ EE or SaxonCS EE 12? It would just be running an XSLT transformation with -s:price.sch -xsl:pipeline-for-svrl.xsl.SaxonEE124Compiled.sef.

Or are you now busy preparing the Saxon 12 release artifacts and will look into potential problems later?

RE: SaxonC 11.99/12 EE can't run its SEF: java.lang.ClassCastException: net.sf.saxon.type.AnyItemType cannot be cast to net.sf.saxon.type.BuiltInAtomicType - Added by O'Neil Delpratt about 1 year ago

Hi Martin, Thanks for reporting this issue. I confirm I am getting the same error on Saxon J EE 12.0. There is a bug against the Java version.

RE: SaxonC 11.99/12 EE can't run its SEF: java.lang.ClassCastException: net.sf.saxon.type.AnyItemType cannot be cast to net.sf.saxon.type.BuiltInAtomicType - Added by Martin Honnen about 1 year ago

Thanks for looking into it, O'Neil.

Will Michael pick it up as a bug on the Java version from this entry or are you going to file an issue at https://saxonica.plan.io/projects/saxon/issues/new or should I do that?

RE: SaxonC 11.99/12 EE can't run its SEF: java.lang.ClassCastException: net.sf.saxon.type.AnyItemType cannot be cast to net.sf.saxon.type.BuiltInAtomicType - Added by Michael Kay about 1 year ago

There's a problem here I've been a little anxious about for a while. When an expression tree is rebuilt from a SEF file, is full static type information always available?

We don't often need static type information at execution time, but in 12.x it's more common because of the introduction of expression elaboration. For example, a ValueComparison now allocates a comparer on first evaluation, rather than statically, and this is based on calling getItemType() on the operands. In this case the RH operand is a system-allocated local variable representing a call on current(), and getItemType() returns AnyItemType.

There's a reasonable circumvention to prevent the crash: if ValueComparison finds that the static type of an operand is AnyItemType, then it can assume AnyAtomicType.

Really though we should be saving more type information to the SEF file. This is probably particularly important if the SEF file is going to be loaded using SaxonJS.

    (1-7/7)

    Please register to reply