1
votes

I want to use saxon to transform xml

and in the XSLT ,

i add a parameter which i expect it as a "Document"

<xsl:param name="doc" as="node()*" />

and in java ,

    DOM4JDocumentWrapper documentNode = new DOM4JDocumentWrapper(doc4j, "", config);
    NodeInfo nodeInfo=documentNode.getRoot();
    XsltTransformer tr =   xsltExecutable.load();
    tr.setParameter(idQname, new XdmNode(nodeInfo));

but met such error:

Caused by: net.sf.saxon.trans.XPathException: Cannot convert value class net.sf.saxon.option.dom4j.DOM4JNodeWrapper of type element(Q{}xxx) to class net.sf.saxon.tree.tiny.TinyElementImpl
    at net.sf.saxon.expr.PJConverter$Identity.convert(PJConverter.java:527)
1
What are xsltExecutable and XdmNode? Links to docs would be helpful. - LarsH

1 Answers

0
votes

It looks to be as if the Saxon Configuration you are using is not aware of the DOM4J object model implementation. That is, it has not been registered using Configuration.registerExternalObjectModel().

With Saxon-PE and Saxon-EE this should be known by default, but with Saxon-HE it has to be registered explicitly. So we need to know more about what version of the Saxon software you are using and how it is initialized.

This question is very specific to Saxon, and the best strategy for getting answers to such questions is to ask on the forums at saxonica.plan.io. We check questions tagged "saxon" on StackOverflow from time to time, but it can take a few days before we notice them, and we don't give them priority.