I ran into the same need for saxon8.8 as is documented in:
http://issues.apache.org/jira/browse/XMLBEANS-287
From the saxon release notes, is looks like anything > 8.3 saxon is probably broken.
Attached are the necessary changes working, if not well tested, against the svn trunk @465816. It would not be backwards compatible with <8.3 saxon versions since the dom-wrapper class didn't exist.
I'd appreciate it if somebody could open the enhancement request. (in my case, it is needed for interop with xmldb)
regards,
-d
M src/xpath_xquery/org/apache/xmlbeans/impl/xpath/saxon/XBeansXPath.java
M src/xpath_xquery/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java
M build.xml
Index: src/xpath_xquery/org/apache/xmlbeans/impl/xpath/saxon/XBeansXPath.java
===================================================================
--- src/xpath_xquery/org/apache/xmlbeans/impl/xpath/saxon/XBeansXPath.java
(revision 465816)
+++ src/xpath_xquery/org/apache/xmlbeans/impl/xpath/saxon/XBeansXPath.java
(working copy)
@@ -18,12 +18,16 @@
import org.apache.xmlbeans.impl.store.SaxonXBeansDelegate;
import org.w3c.dom.Node;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.xml.transform.TransformerException;
import net.sf.saxon.Configuration;
+import net.sf.saxon.dom.NodeOverNodeInfo;
+import net.sf.saxon.om.NodeInfo;
import net.sf.saxon.sxpath.XPathEvaluator;
import net.sf.saxon.sxpath.XPathExpression;
import net.sf.saxon.trans.Variable;
@@ -101,7 +105,28 @@
thisVar.setValue(rootNode);
XPathExpression exp = xpe.createExpression(_queryExpr);
- return exp.evaluate(rootNode);
+
+ //return exp.evaluate(rootNode);
+
+ // After 8.3(?) Saxon nodes no longer implement Dom.
+ // The client needs saxon8-dom.jar, and the code needs
+ // this NodeOverNodeInfo Dom wrapper doohickey
+ List domNodesOrSimple = new ArrayList();
+ List saxonNodes = exp.evaluate(rootNode);
+ for(Iterator it = saxonNodes.iterator(); it.hasNext(); )
+ {
+ Object o = it.next();
+ if(o instanceof NodeInfo)
+ {
+ Node n = NodeOverNodeInfo.wrap((NodeInfo)o);
+ domNodesOrSimple.add(n);
+ }
+ else
+ {
+ domNodesOrSimple.add(o);
+ }
+ }
+ return domNodesOrSimple;
}
catch (TransformerException e)
{
Index: src/xpath_xquery/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java
===================================================================
--- src/xpath_xquery/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java
(revision 465816)
+++ src/xpath_xquery/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java
(working copy)
@@ -16,6 +16,8 @@
package org.apache.xmlbeans.impl.xquery.saxon;
import net.sf.saxon.Configuration;
+import net.sf.saxon.dom.NodeOverNodeInfo;
+import net.sf.saxon.om.NodeInfo;
import net.sf.saxon.query.DynamicQueryContext;
import net.sf.saxon.query.StaticQueryContext;
import net.sf.saxon.query.XQueryExpression;
@@ -26,9 +28,10 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.TransformerException;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Iterator;
public class XBeansXQuery
@@ -75,7 +78,7 @@
dynamicContext.setContextNode(_stcContext.
buildDocument(new DOMSource(context_node)));
dynamicContext.setParameter(_contextVar,
- dynamicContext.getContextNode());
+ dynamicContext.getContextItem());
// Set the other variables
if (variableBindings != null)
for (Iterator it = variableBindings.entrySet().iterator();
@@ -95,7 +98,25 @@
entry.getValue());
}
- return _xquery.evaluate(dynamicContext);
+ // After 8.3(?) Saxon nodes no longer implement Dom.
+ // The client needs saxon8-dom.jar, and the code needs
+ // this NodeOverNodeInfo Dom wrapper doohickey
+ List domNodesOrSimple = new ArrayList();
+ List saxonNodes = _xquery.evaluate(dynamicContext);
+ for(Iterator it = saxonNodes.iterator(); it.hasNext(); )
+ {
+ Object o = it.next();
+ if(o instanceof NodeInfo)
+ {
+ Node n = NodeOverNodeInfo.wrap((NodeInfo)o);
+ domNodesOrSimple.add(n);
+ }
+ else
+ {
+ domNodesOrSimple.add(o);
+ }
+ }
+ return domNodesOrSimple;
}
catch (TransformerException e) {
throw new RuntimeException(" Error binding " + _contextVar, e);
Index: build.xml
===================================================================
--- build.xml (revision 465816)
+++ build.xml (working copy)
@@ -53,9 +53,6 @@
<target name="clean.jars" description="Delete any downloaded jars and
accompanying licenses">
<delete>
<fileset dir="external/lib">
- <include name="saxonb8-6-1.zip"/>
- <include name="saxonb8-2.zip"/>
- <include name="saxonb8-1.zip"/>
<include name="jsr173_1.0_api_bundle.jar"/>
<include name="jsr173_1.0_api.jar"/>
<include name="saxon8.jar"/>
@@ -84,9 +81,11 @@
<property environment="env"/>
<target name="saxon.find1" if="env.XMLBEANS_EXTERNALS">
<property name="saxon_jar" value="${env.XMLBEANS_EXTERNALS}/saxon8.jar"/>
+ <property name="saxon_dom_jar"
value="${env.XMLBEANS_EXTERNALS}/saxon8-dom.jar"/>
</target>
<target name="saxon.find2">
<property name="saxon_jar" value="build/lib/saxon8.jar"/>
+ <property name="saxon_dom_jar" value="build/lib/saxon8-dom.jar"/>
</target>
<target name="check.saxon8.jar" depends="saxon.find1,saxon.find2">
@@ -100,24 +99,24 @@
<target name="saxon8.jar" depends="check.saxon8.jar, dirs"
unless="saxon8.jar.exists">
+
<!-- other saxon urls
http://voxel.dl.sourceforge.net/sourceforge/saxon/saxonb8-1.zip
+
http://superb-west.dl.sourceforge.net/sourceforge/saxon/saxonb8-8j.zip
-->
- <get dest="external/lib/saxonb8-6-1.zip"
-
src="http://easynews.dl.sourceforge.net/sourceforge/saxon/saxonb8-6-1.zip"
+ <get dest="external/lib/saxonb8-8j.zip"
+
src="http://superb-west.dl.sourceforge.net/sourceforge/saxon/saxonb8-8j.zip"
verbose="true" usetimestamp="true" ignoreerrors="true"/>
- <unzip src="external/lib/saxonb8-6-1.zip" dest="external/lib/">
+ <unzip src="external/lib/saxonb8-8j.zip" dest="external/lib/">
<patternset>
<include name="saxon8.jar"/>
<include name="saxon8-dom.jar"/>
</patternset>
</unzip>
-
+
<copy file="external/lib/saxon8.jar" tofile="build/lib/saxon8.jar"/>
+ <copy file="external/lib/saxon8-dom.jar"
tofile="build/lib/saxon8-dom.jar"/>
- <!-- saxon8-dom.jar is used to register DOMObjectModel for use in
- xpath/xquery checkintest -->
- <copy file="external/lib/saxon8-dom.jar"
tofile="build/lib/saxon8-dom.jar"/>
</target>
<target name="jsr173-bundle.downloaded">
@@ -937,6 +936,7 @@
<pathelement location="build/classes/xmlpublic"/>
<pathelement location="build/classes/store"/>
<pathelement location="${saxon_jar}"/>
+ <pathelement location="${saxon_dom_jar}"/>
</classpath>
</javac>
</target>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
