From: .::: M. :::. <mp...@cc...> - 2009-01-02 08:00:44
|
Hi, I Am trying to pass an XML document to an XQuery expression as an external variable using the following Java code: --------- 8< ---------- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); org.w3c.dom.Document d = db.parse( xmlDocumentAsInputStream ); // Uses the following driver class 'org.exist.xmldb.DatabaseImpl' xqueryService.declareVariable( "xmlDocumentVariableName", d ); ----------- 8< -------- And XQuery expression: ------------ 8< ------- xquery version "1.0" encoding "UTF-8"; (: Declare external variables :) declare variable $xmlDocumentVariableName as node() external; (: Return the result :) for $myResult in $xmlDocumentVariableName return $myResult --------------- 8< ------------ The code execution fails and I will get the following error message: -------------- 8< ------------- Caused by: MyException: XML:DB Exception (error code: 1). ... Caused by: org.xmldb.api.base.XMLDBException: unsupported Java type: class org.apache.xerces.dom.DeferredDocumentImpl at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:111) at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:70) at org.exist.xmldb.RemoteXPathQueryService.execute(RemoteXPathQueryService.java:404) ... Caused by: java.io.IOException: unsupported Java type: class org.apache.xerces.dom.DeferredDocumentImpl at org.apache.xmlrpc.XmlRpcClient$Worker.execute(XmlRpcClient.java:444) at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:163) at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:98) ... 28 more ----------------------- 8< ------------------ Am I doing something wrong here? How should I pass an XML document to an XQuery expression as an external variable? I know that I could pass the XML document as a string (xs:string in XQuery expression) and then use eXist's util:parse() function but I would like to keep my XQuery expressions "clean" i.e. without implementation specific code. I am using eXist-db 1.2.4-rev:8072-20080802 Kind regards -Markku Laine |