Project

Profile

Help

Bug #4567

closed

Failure trying to return a JDOM2 document from a reflexive extension function

Added by Michael Kay almost 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Saxon extensions
Sprint/Milestone:
-
Start date:
2020-06-02
Due date:
% Done:

100%

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

Description

The following test case:

public static JDOM2DocumentWrapper parseToJdom(XPathContext context, String content) throws Exception {

        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(new StringReader(content));
        return new JDOM2DocumentWrapper(document, context.getConfiguration());
    }

    public void testJDOM2extension() {
        try {
            Processor proc = new Processor(true);
            XQueryEvaluator eval = proc.newXQueryCompiler().compile(
                    "Q{java:jaxptest.ExtensionTest}parseToJdom('<magic/>')//*/name()").load();
            XdmValue result = eval.evaluate();
            assertEquals("magic", ((XdmAtomicValue) result).getStringValue());
        } catch (SaxonApiException e) {
            e.printStackTrace();
            fail();
        }
    }

fails with the exception:

Error on line 1 column 43 
   Unknown source class net.sf.saxon.option.jdom2.JDOM2DocumentWrapper
net.sf.saxon.s9api.SaxonApiException: Unknown source class net.sf.saxon.option.jdom2.JDOM2DocumentWrapper
	at net.sf.saxon.s9api.XQueryEvaluator.evaluate(XQueryEvaluator.java:434)
	at jaxptest.ExtensionTest.testJDOM2extension(ExtensionTest.java:392)
...
Caused by: net.sf.saxon.trans.XPathException: Unknown source class net.sf.saxon.option.jdom2.JDOM2DocumentWrapper
	at net.sf.saxon.Configuration.buildDocumentTree(Configuration.java:4171)
	at net.sf.saxon.expr.JPConverter$FromSource.convert(JPConverter.java:674)
	at net.sf.saxon.expr.JPConverter$FromSource.convert(JPConverter.java:664)
	at com.saxonica.expr.JavaExtensionFunctionCall.asSequence(JavaExtensionFunctionCall.java:665)
	at com.saxonica.expr.JavaExtensionFunctionCall.call(JavaExtensionFunctionCall.java:576)
	at com.saxonica.expr.JavaExtensionFunctionCall.iterate(JavaExtensionFunctionCall.java:445)

Please register to edit this issue

Also available in: Atom PDF