Skip to content

Commit

Permalink
saxon 12.3
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/xmlbeans/trunk@1912656 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
pjfanning committed Oct 1, 2023
1 parent bdf69c3 commit 249cb55
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion LICENSE-binary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,4 @@ org.slf4j:slf4j-api:1.7.25
Mozilla Public License 2.0
--------------------------

net.sf.saxon:Saxon-HE:11.5
net.sf.saxon:Saxon-HE:12.3
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ext {
antVersion = '1.10.14'
javaparserVersion = '3.25.5'
log4jVersion = '2.20.0'
saxonVersion = '11.5'
saxonVersion = '12.3'
androidSdkMinimum = '26'
}

Expand Down
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<!-- dependencies -->
<dependency prefix="xml-apis" artifact="xml-apis:xml-apis:1.4.01" usage="java8"/>
<dependency prefix="log4j-api" artifact="org.apache.logging.log4j:log4j-api:2.20.0" usage="main"/>
<dependency prefix="saxon" artifact="net.sf.saxon:Saxon-HE:11.5" usage="main"/>
<dependency prefix="saxon" artifact="net.sf.saxon:Saxon-HE:12.3" usage="main"/>
<dependency prefix="ant" artifact="org.apache.ant:ant:1.10.14" usage="main"/>
<dependency prefix="javaparser-core" artifact="com.github.javaparser:javaparser-core:3.25.5" usage="main"/>
<dependency prefix="javaparser-symbol-solver-core" artifact="com.github.javaparser:javaparser-symbol-solver-core:3.25.5" usage="main"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.sf.saxon.Configuration;
import net.sf.saxon.dom.DOMNodeWrapper;
import net.sf.saxon.om.Item;
import net.sf.saxon.om.NamespaceUri;
import net.sf.saxon.om.NodeInfo;
import net.sf.saxon.om.SequenceTool;
import net.sf.saxon.sxpath.*;
Expand Down Expand Up @@ -94,16 +95,18 @@ public List selectNodes(Object node) {
// also see https://saxonica.plan.io/issues/2130
// (XPath referencing attribute with namespace fails when using DOM)
if (defaultNS != null) {
sc.setDefaultElementNamespace(defaultNS);
sc.setDefaultElementNamespace(NamespaceUri.of(defaultNS));
}

namespaceMap.forEach(sc::declareNamespace);
for (Map.Entry<String, String> entry : namespaceMap.entrySet()) {
sc.declareNamespace(entry.getKey(), NamespaceUri.of(entry.getValue()));
}

NodeInfo contextItem = config.unravel(new DOMSource(contextNode));

XPathEvaluator xpe = new XPathEvaluator(config);
xpe.setStaticContext(sc);
XPathVariable thisVar = sc.declareVariable("", contextVar);
XPathVariable thisVar = sc.declareVariable(NamespaceUri.of(""), contextVar);
XPathExpression xpath = xpe.createExpression(path);
XPathDynamicContext dc = xpath.createDynamicContext(null);
dc.setContextItem(contextItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.sf.saxon.dom.NodeOverNodeInfo;
import net.sf.saxon.ma.map.HashTrieMap;
import net.sf.saxon.om.Item;
import net.sf.saxon.om.NamespaceUri;
import net.sf.saxon.om.NodeInfo;
import net.sf.saxon.om.StructuredQName;
import net.sf.saxon.query.DynamicQueryContext;
Expand Down Expand Up @@ -81,7 +82,9 @@ public SaxonXQuery(final String query, String contextVar, Integer boundary, XmlO
StaticQueryContext sc = config.newStaticQueryContext();
Map<String, String> nsMap = xmlOptions.getLoadAdditionalNamespaces();
if (nsMap != null) {
nsMap.forEach(sc::declareNamespace);
for (Map.Entry<String, String> entry : nsMap.entrySet()) {
sc.declareNamespace(entry.getKey(), NamespaceUri.of(entry.getValue()));
}
}
this.contextVar = contextVar;
//Saxon requires external variables at the end of the prolog...
Expand Down Expand Up @@ -176,13 +179,14 @@ public List<Object> execQuery(Object node, Map<String,Object> variableBindings)
DocumentWrapper docWrapper = new DocumentWrapper(dom, null, config);
NodeInfo root = docWrapper.wrap(contextNode);

NamespaceUri emptyUri = NamespaceUri.of("");
DynamicQueryContext dc = new DynamicQueryContext(config);
dc.setContextItem(root);
dc.setParameter(new StructuredQName("", null, contextVar), root);
dc.setParameter(new StructuredQName("", emptyUri, contextVar), root);
// Set the other variables
if (variableBindings != null) {
for (Map.Entry<String, Object> me : variableBindings.entrySet()) {
StructuredQName key = new StructuredQName("", null, me.getKey());
StructuredQName key = new StructuredQName("", emptyUri, me.getKey());
Object value = me.getValue();
if (value instanceof XmlTokenSource) {
Node paramObject = ((XmlTokenSource) value).getDomNode();
Expand Down Expand Up @@ -282,7 +286,7 @@ private static Item objectToItem(Object value, Configuration config) throws XPat
}
} else if (value instanceof QName) {
QName q = (QName) value;
return new QNameValue(q.getPrefix(), q.getNamespaceURI(), q.getLocalPart()); //BuiltInAtomicType.QNAME, null);
return new QNameValue(q.getPrefix(), NamespaceUri.of(q.getNamespaceURI()), q.getLocalPart()); //BuiltInAtomicType.QNAME, null);
} else if (value instanceof URI) {
return new AnyURIValue(value.toString());
} else if (value instanceof Map) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/maven/org.apache.xmlbeans/xmlbeans/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>11.5</version>
<version>12.3</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion src/main/maven/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>11.5</version>
<version>12.3</version>
</dependency>
<dependency>
<groupId>com.github.javaparser</groupId>
Expand Down

0 comments on commit 249cb55

Please sign in to comment.