Why it doesn't work?

  • Vasily Dobry

    Vasily Dobry - 2004-12-10

    Why this example doesn't work?

    public static NodeList test ( NodeList list )
    return list;

    <xsl:for-each select="my:test(*)">

    at net.sf.saxon.dom.DOMNodeList.item(DOMNodeList.java:68)
    at net.sf.saxon.value.Value.convertJavaObjectToXPath(Value.java:483)
    at net.sf.saxon.functions.ExtensionFunctionCall.asIterator(ExtensionFunctionCall.java:314)
    at net.sf.saxon.functions.ExtensionFunctionCall.call(ExtensionFunctionCall.java:232)
    at net.sf.saxon.functions.ExtensionFunctionCall.iterate(ExtensionFunctionCall.java:115)
    at net.sf.saxon.instruct.ForEach.processLeavingTail(ForEach.java:131)
    at net.sf.saxon.instruct.Instruction.process(Instruction.java:91)
    at net.sf.saxon.instruct.InstructionWithChildren.processChildren(InstructionWithChildren.java:158)
    at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:122)
    at net.sf.saxon.instruct.Template.expand(Template.java:98)
    at net.sf.saxon.instruct.Template.processLeavingTail(Template.java:82)
    at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:262)
    at net.sf.saxon.Controller.transformDocument(Controller.java:1094)
    at net.sf.saxon.Controller.transform(Controller.java:940)

    I use Saxon 8.1.1

    • Michael Kay

      Michael Kay - 2004-12-10

      Thanks for reporting this. It seems there is an asymmetry between the code that converts from a Saxon node sequence to a DOM NodeList and the code that converts back again.

      I guess you are supplying the source document in the form of a DOM, and Saxon is creating its own wrappers around these nodes. In this case the idea is that the NodeList passed to the function contains (or appears to contain) the original DOM nodes. However, a DOM NodeList that's returned from an extension function must contain nodes that implement Saxon's native NodeInfo interface.

      I'll try to fix this so it works in the case where the extension function doesn't modify the NodeList. However, there will still be restrictions if it's modified. Frankly, Saxon and the DOM don't work all that happily together, because of differences between the DOM data model and the XPath data model (not to mention the fact that the XSLT processing model assumes nodes are immutable). It might be worth looking at what you are trying to achieve and seeing if there is a better way.

      Michael Kay


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks