You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2020/09/03 23:18:23 UTC
svn commit: r1881423 [4/4] - in /xmlbeans/trunk/src/main:
java/org/apache/xmlbeans/ java/org/apache/xmlbeans/impl/common/
java/org/apache/xmlbeans/impl/schema/ java/org/apache/xmlbeans/impl/store/
java/org/apache/xmlbeans/impl/xpath/ java/org/apache/xm...
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Locale.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Locale.java?rev=1881423&r1=1881422&r2=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Locale.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Locale.java Thu Sep 3 23:18:22 2020
@@ -112,7 +112,6 @@ public final class Locale
_saaj = options.getSaaj();
if (_saaj != null) {
-
_saaj.setCallback(this);
}
}
@@ -121,7 +120,7 @@ public final class Locale
//
//
- static Locale getLocale(SchemaTypeLoader stl, XmlOptions options) {
+ public static Locale getLocale(SchemaTypeLoader stl, XmlOptions options) {
if (stl == null) {
stl = XmlBeans.getContextTypeLoader();
}
@@ -136,31 +135,30 @@ public final class Locale
Locale l;
- if (source instanceof Locale) {
- l = (Locale) source;
- } else if (source instanceof XmlTokenSource) {
- l = (Locale) ((XmlTokenSource) source).monitor();
- } else {
- throw new IllegalArgumentException(
- "Source locale not understood: " + source);
- }
+ if (source instanceof Locale) {
+ l = (Locale) source;
+ } else if (source instanceof XmlTokenSource) {
+ l = (Locale) ((XmlTokenSource) source).monitor();
+ } else {
+ throw new IllegalArgumentException("Source locale not understood: " + source);
+ }
- if (l._schemaTypeLoader != stl) {
- throw new IllegalArgumentException(
- "Source locale does not support same schema type loader");
- }
+ if (l._schemaTypeLoader != stl) {
+ throw new IllegalArgumentException(
+ "Source locale does not support same schema type loader");
+ }
if (l._saaj != null && l._saaj != options.getSaaj()) {
- throw new IllegalArgumentException(
- "Source locale does not support same saaj");
- }
+ throw new IllegalArgumentException(
+ "Source locale does not support same saaj");
+ }
- if (l._validateOnSet && !options.isValidateOnSet()) {
- throw new IllegalArgumentException(
- "Source locale does not support same validate on set");
- }
+ if (l._validateOnSet && !options.isValidateOnSet()) {
+ throw new IllegalArgumentException(
+ "Source locale does not support same validate on set");
+ }
- // TODO - other things to check?
+ // TODO - other things to check?
return l;
}
@@ -169,7 +167,7 @@ public final class Locale
//
//
- static void associateSourceName(Cur c, XmlOptions options) {
+ public static void associateSourceName(Cur c, XmlOptions options) {
String sourceName = options == null ? null : options.getDocumentSourceName();
if (sourceName != null) {
@@ -181,8 +179,8 @@ public final class Locale
//
//
- static void autoTypeDocument(Cur c, SchemaType requestedType,
- XmlOptions options)
+ public static void autoTypeDocument(Cur c, SchemaType requestedType,
+ XmlOptions options)
throws XmlException {
assert c.isRoot();
@@ -1193,7 +1191,7 @@ public final class Locale
}
}
- void loadNode(Node n, LoadContext context) {
+ public void loadNode(Node n, LoadContext context) {
switch (n.getNodeType()) {
case Node.DOCUMENT_NODE:
case Node.DOCUMENT_FRAGMENT_NODE:
@@ -1280,7 +1278,6 @@ public final class Locale
XmlOptions saxHandlerOptions = new XmlOptions(options);
saxHandlerOptions.setLoadUseLocaleCharUtil(true);
-
initSaxHandler(l, saxHandlerOptions);
}
@@ -1822,7 +1819,7 @@ public final class Locale
return false;
}
- static boolean toFirstChildElement(Cur c) {
+ public static boolean toFirstChildElement(Cur c) {
// if (!pushToContainer(c))
// return false;
//
@@ -2010,7 +2007,7 @@ public final class Locale
}
}
- static Map<String,String> getAllNamespaces(Cur c, Map<String,String> filleMe) {
+ static Map<String, String> getAllNamespaces(Cur c, Map<String, String> filleMe) {
assert c.isNode();
c.push();
@@ -2366,7 +2363,7 @@ public final class Locale
return _charUtil;
}
- long version() {
+ public long version() {
return _versionAll;
}
@@ -2627,7 +2624,7 @@ public final class Locale
// Loading/parsing
//
- static abstract class LoadContext {
+ public static abstract class LoadContext {
protected abstract void startDTD(String name, String publicId,
String systemId);
@@ -2637,7 +2634,7 @@ public final class Locale
protected abstract void endElement();
- protected abstract void attr(QName name, String value);
+ public abstract void attr(QName name, String value);
protected abstract void attr(String local, String uri, String prefix,
String value);
@@ -2654,7 +2651,7 @@ public final class Locale
protected abstract void text(String s);
- protected abstract Cur finish();
+ public abstract Cur finish();
protected abstract void abort();
@@ -3232,6 +3229,9 @@ public final class Locale
parentName);
}
+ public SchemaTypeLoader getSchemaTypeLoader() {
+ return _schemaTypeLoader;
+ }
private static final class DefaultQNameFactory
implements QNameFactory {
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Public2.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Public2.java?rev=1881423&r1=1881422&r2=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Public2.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Public2.java Thu Sep 3 23:18:22 2020
@@ -15,42 +15,24 @@
package org.apache.xmlbeans.impl.store;
-import javax.xml.stream.XMLStreamReader;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Node;
-import org.w3c.dom.Document;
-
-import org.apache.xmlbeans.XmlBeans;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlException;
-
-import java.io.PrintStream;
-
+import org.apache.xmlbeans.*;
import org.apache.xmlbeans.impl.store.DomImpl.Dom;
-
import org.apache.xmlbeans.impl.store.Saver.TextSaver;
-
+import org.apache.xmlbeans.impl.values.NamespaceManager;
import org.apache.xmlbeans.impl.values.TypeStore;
import org.apache.xmlbeans.impl.values.TypeStoreUser;
import org.apache.xmlbeans.impl.values.TypeStoreVisitor;
-import org.apache.xmlbeans.impl.values.TypeStoreUserFactory;
-
-import org.apache.xmlbeans.SchemaType;
-
-import org.apache.xmlbeans.impl.values.NamespaceManager;
+import org.apache.xmlbeans.impl.xpath.XPathFactory;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
import javax.xml.namespace.QName;
-
-import org.apache.xmlbeans.SchemaField;
-
-import org.apache.xmlbeans.QNameSet;
+import javax.xml.stream.XMLStreamReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
public final class Public2
{
@@ -83,7 +65,7 @@ public final class Public2
public static String compilePath ( String path, XmlOptions options )
{
- return Path.compilePath( path, options );
+ return XPathFactory.compilePath( path, options );
}
public static DOMImplementation getDomImplementation ( )
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Xobj.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Xobj.java?rev=1881423&r1=1881422&r2=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Xobj.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Xobj.java Thu Sep 3 23:18:22 2020
@@ -24,6 +24,7 @@ import org.apache.xmlbeans.impl.values.T
import org.apache.xmlbeans.impl.values.TypeStoreUser;
import org.apache.xmlbeans.impl.values.TypeStoreUserFactory;
import org.apache.xmlbeans.impl.values.TypeStoreVisitor;
+import org.apache.xmlbeans.impl.xpath.XPathFactory;
import javax.xml.namespace.QName;
import java.io.PrintStream;
@@ -2473,7 +2474,7 @@ abstract class Xobj implements TypeStore
try {
Cur c = tempCur();
- XmlObject[] result = Query.objectExecQuery(c, queryExpr, options);
+ XmlObject[] result = XPathFactory.objectExecQuery(c, queryExpr, options);
c.release();
Copied: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/Path.java (from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Path.java)
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/Path.java?p2=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/Path.java&p1=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Path.java&r1=1881422&r2=1881423&rev=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Path.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/Path.java Thu Sep 3 23:18:22 2020
@@ -13,459 +13,12 @@
* limitations under the License.
*/
-package org.apache.xmlbeans.impl.store;
+package org.apache.xmlbeans.impl.xpath;
-import org.apache.xmlbeans.*;
-import org.apache.xmlbeans.impl.common.DefaultClassLoaderResourceLoader;
-import org.apache.xmlbeans.impl.common.XPath;
-import org.apache.xmlbeans.impl.common.XPath.XPathCompileException;
-import org.apache.xmlbeans.impl.common.XPathExecutionContext;
-import org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath;
-import org.w3c.dom.Node;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.store.Cur;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-// TODO - This class handled query *and* path ... rename it?
-
-public abstract class Path {
- public static final String PATH_DELEGATE_INTERFACE = "PATH_DELEGATE_INTERFACE";
- public static String _useDelegateForXpath = "use delegate for xpath";
- public static String _useXbeanForXpath = "use xbean for xpath";
-
- private static final int USE_XBEAN = 0x01;
- private static final int USE_DELEGATE = 0x04;
-
- private static final Map<String, WeakReference<Path>> _xbeanPathCache = new WeakHashMap<>();
-
-
- private static final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
-
- protected final String _pathKey;
-
- Path(String key) {
- _pathKey = key;
- }
-
-
- interface PathEngine {
- void release();
-
- boolean next(Cur c);
- }
-
- abstract PathEngine execute(Cur c, XmlOptions options);
-
- //
- //
- //
-
- static String getCurrentNodeVar(XmlOptions options) {
- String currentNodeVar = "this";
-
- options = XmlOptions.maskNull(options);
-
- String cnv = options.getXqueryCurrentNodeVar();
- if (cnv != null) {
- currentNodeVar = cnv;
-
- if (currentNodeVar.startsWith("$")) {
- throw new IllegalArgumentException("Omit the '$' prefix for the current node variable");
- }
- }
-
- return currentNodeVar;
- }
-
- public static Path getCompiledPath(String pathExpr, XmlOptions options) {
- options = XmlOptions.maskNull(options);
-
- int force =
- options.isXPathUseDelegate() ? USE_DELEGATE
- : options.isXPathUseXmlBeans() ? USE_XBEAN
- : USE_XBEAN | USE_DELEGATE;
- String delIntfName = XBeansXPath.class.getName();
-
- return getCompiledPath(pathExpr, force, getCurrentNodeVar(options), delIntfName);
- }
-
- static Path getCompiledPath(String pathExpr, int force,
- String currentVar, String delIntfName) {
- Path path = null;
- WeakReference<Path> pathWeakRef = null;
- Map<String, String> namespaces = (force & USE_DELEGATE) != 0 ? new HashMap<>() : null;
- lock.readLock().lock();
- try {
- if ((force & USE_XBEAN) != 0) {
- pathWeakRef = _xbeanPathCache.get(pathExpr);
- }
-
- if (pathWeakRef != null) {
- path = pathWeakRef.get();
- }
- if (path != null) {
- return path;
- }
- } finally {
- lock.readLock().unlock();
- }
- lock.writeLock().lock();
- try {
- if ((force & USE_XBEAN) != 0) {
- pathWeakRef = _xbeanPathCache.get(pathExpr);
- if (pathWeakRef != null) {
- path = pathWeakRef.get();
- }
- if (path == null) {
- path = getCompiledPathXbean(pathExpr, currentVar, namespaces);
- }
- }
- if (path == null && (force & USE_DELEGATE) != 0) {
- path = getCompiledPathDelegate(pathExpr, currentVar, namespaces, delIntfName);
- }
- if (path == null) {
- StringBuilder errMessage = new StringBuilder();
- if ((force & USE_XBEAN) != 0) {
- errMessage.append(" Trying XBeans path engine...");
- }
- if ((force & USE_DELEGATE) != 0) {
- errMessage.append(" Trying delegated path engine...");
- }
-
- throw new RuntimeException(errMessage.toString() + " FAILED on " + pathExpr);
- }
- } finally {
- lock.writeLock().unlock();
- }
- return path;
- }
-
- static private Path getCompiledPathXbean(String pathExpr,
- String currentVar, Map<String, String> namespaces) {
- Path path = XbeanPath.create(pathExpr, currentVar, namespaces);
- if (path != null) {
- _xbeanPathCache.put(path._pathKey, new WeakReference<>(path));
- }
-
- return path;
- }
-
- static private Path getCompiledPathDelegate(String pathExpr, String currentVar, Map<String, String> namespaces, String delIntfName) {
- if (namespaces == null) {
- namespaces = new HashMap<>();
- }
-
- try {
- XPath.compileXPath(pathExpr, currentVar, namespaces);
- } catch (XPath.XPathCompileException e) {
- //do nothing, this function is only called to populate the namespaces map
- }
-
-
- int offset = Integer.parseInt(namespaces.getOrDefault(XPath._NS_BOUNDARY, "0"));
- namespaces.remove(XPath._NS_BOUNDARY);
-
- return DelegatePathImpl.create(delIntfName,
- pathExpr.substring(offset),
- currentVar,
- namespaces);
- }
-
-
- public static String compilePath(String pathExpr, XmlOptions options) {
- return getCompiledPath(pathExpr, options)._pathKey;
- }
-
- //
- // Xbean store specific implementation of compiled path
- //
-
- private static final class XbeanPath extends Path {
- static Path create(String pathExpr, String currentVar, Map<String, String> namespaces) {
- try {
- return new XbeanPath(pathExpr, currentVar,
- XPath.compileXPath(pathExpr, currentVar, namespaces));
- } catch (XPathCompileException e) {
- return null;
- }
- }
-
- private XbeanPath(String pathExpr, String currentVar, XPath xpath) {
- super(pathExpr);
-
- _currentVar = currentVar;
- _compiledPath = xpath;
- }
-
- PathEngine execute(Cur c, XmlOptions options) {
- options = XmlOptions.maskNull(options);
- String delIntfName = XBeansXPath.class.getName();
-
- // The builtin XPath engine works only on containers. Delegate to
- // xqrl otherwise. Also, if the path had a //. at the end, the
- // simple xpath engine can't do the generate case, it only handles
- // attrs and elements.
-
- if (!c.isContainer() || _compiledPath.sawDeepDot()) {
- int force = USE_DELEGATE;
- return getCompiledPath(_pathKey, force, _currentVar, delIntfName).execute(c, options);
- }
- return new XbeanPathEngine(_compiledPath, c);
- }
-
- private final String _currentVar;
- private final XPath _compiledPath;
- public Map<String, String> namespaces;
- }
-
- private static final class XbeanPathEngine
- extends XPathExecutionContext
- implements PathEngine {
- XbeanPathEngine(XPath xpath, Cur c) {
- assert c.isContainer();
-
- _version = c._locale.version();
- _cur = c.weakCur(this);
-
- _cur.push();
-
- init(xpath);
-
- int ret = start();
-
- if ((ret & HIT) != 0) {
- c.addToSelection();
- }
-
- doAttrs(ret, c);
-
- if ((ret & DESCEND) == 0 || !Locale.toFirstChildElement(_cur)) {
- release();
- }
- }
-
- private void advance(Cur c) {
- assert _cur != null;
-
- if (_cur.isFinish()) {
- if (_cur.isAtEndOfLastPush()) {
- release();
- } else {
- end();
- _cur.next();
- }
- } else if (_cur.isElem()) {
- int ret = element(_cur.getName());
-
- if ((ret & HIT) != 0) {
- c.addToSelection(_cur);
- }
-
- doAttrs(ret, c);
-
- if ((ret & DESCEND) == 0 || !Locale.toFirstChildElement(_cur)) {
- end();
- _cur.skip();
- }
- } else {
- do {
- _cur.next();
- }
- while (!_cur.isContainerOrFinish());
- }
- }
-
- private void doAttrs(int ret, Cur c) {
- assert _cur.isContainer();
-
- if ((ret & ATTRS) != 0) {
- if (_cur.toFirstAttr()) {
- do {
- if (attr(_cur.getName())) {
- c.addToSelection(_cur);
- }
- }
- while (_cur.toNextAttr());
-
- _cur.toParent();
- }
- }
- }
-
- public boolean next(Cur c) {
- if (_cur != null && _version != _cur._locale.version()) {
- throw new ConcurrentModificationException("Document changed during select");
- }
-
- int startCount = c.selectionCount();
-
- while (_cur != null) {
- advance(c);
-
- if (startCount != c.selectionCount()) {
- return true;
- }
- }
-
- return false;
- }
-
- public void release() {
- if (_cur != null) {
- _cur.release();
- _cur = null;
- }
- }
-
- private final long _version;
- private Cur _cur;
- }
-
- private static final class DelegatePathImpl
- extends Path {
- private PathDelegate.SelectPathInterface _xpathImpl;
-
- static Path create(String implClassName, String pathExpr, String currentNodeVar, Map namespaceMap) {
- assert !currentNodeVar.startsWith("$"); // cezar review with ericvas
-
- PathDelegate.SelectPathInterface impl =
- PathDelegate.createInstance(implClassName, pathExpr, currentNodeVar, namespaceMap);
- if (impl == null) {
- return null;
- }
-
- return new DelegatePathImpl(impl, pathExpr);
- }
-
-
- private DelegatePathImpl(PathDelegate.SelectPathInterface xpathImpl,
- String pathExpr) {
- super(pathExpr);
- _xpathImpl = xpathImpl;
- }
-
- protected PathEngine execute(Cur c, XmlOptions options) {
- return new DelegatePathEngine(_xpathImpl, c);
- }
-
- private static class DelegatePathEngine
- extends XPathExecutionContext
- implements PathEngine {
- // full datetime format: yyyy-MM-dd'T'HH:mm:ss'Z'
- private final DateFormat xmlDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-
- DelegatePathEngine(PathDelegate.SelectPathInterface xpathImpl,
- Cur c) {
- _engine = xpathImpl;
- _version = c._locale.version();
- _cur = c.weakCur(this);
- }
-
- public boolean next(Cur c) {
- if (!_firstCall) {
- return false;
- }
-
- _firstCall = false;
-
- if (_cur != null && _version != _cur._locale.version()) {
- throw new ConcurrentModificationException("Document changed during select");
- }
-
- List resultsList;
-
- Object context_node = _cur.getDom();
- resultsList = _engine.selectPath(context_node);
-
- int i;
- for (i = 0; i < resultsList.size(); i++) {
- //simple type function results
- Object node = resultsList.get(i);
- Cur pos = null;
- if (!(node instanceof Node)) {
- Object obj = resultsList.get(i);
- String value;
- if (obj instanceof Date) {
- value = xmlDateFormat.format((Date) obj);
- } else if (obj instanceof BigDecimal) {
- value = ((BigDecimal) obj).toPlainString();
- } else {
- value = obj.toString();
- }
-
- //we cannot leave the cursor's locale, as
- //everything is done in the selections of this cursor
-
- Locale l = c._locale;
- try {
- pos = l.load("<xml-fragment/>").tempCur();
- pos.setValue(value);
- SchemaType type = getType(node);
- Locale.autoTypeDocument(pos, type, null);
- //move the cur to the actual text
- pos.next();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- } else {
- assert (node instanceof DomImpl.Dom) :
- "New object created in XPATH!";
- pos = ((DomImpl.Dom) node).tempCur();
-
- }
- c.addToSelection(pos);
- pos.release();
- }
- release();
- _engine = null;
- return true;
- }
-
- private SchemaType getType(Object node) {
- SchemaType type;
- if (node instanceof Integer) {
- type = XmlInteger.type;
- } else if (node instanceof Double) {
- type = XmlDouble.type;
- } else if (node instanceof Long) {
- type = XmlLong.type;
- } else if (node instanceof Float) {
- type = XmlFloat.type;
- } else if (node instanceof BigDecimal) {
- type = XmlDecimal.type;
- } else if (node instanceof Boolean) {
- type = XmlBoolean.type;
- } else if (node instanceof String) {
- type = XmlString.type;
- } else if (node instanceof Date) {
- type = XmlDate.type;
- } else {
- type = XmlAnySimpleType.type;
- }
- return type;
- }
-
- public void release() {
- if (_cur != null) {
- _cur.release();
- _cur = null;
- }
- }
-
- private Cur _cur;
- private PathDelegate.SelectPathInterface _engine;
- private boolean _firstCall = true;
- private long _version;
- }
- }
+public interface Path {
+ XPathEngine execute(Cur c, XmlOptions options);
}
Copied: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPath.java (from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPath.java)
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPath.java?p2=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPath.java&p1=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPath.java&r1=1881422&r2=1881423&rev=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPath.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPath.java Thu Sep 3 23:18:22 2020
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package org.apache.xmlbeans.impl.common;
+package org.apache.xmlbeans.impl.xpath;
import org.apache.xmlbeans.XmlError;
import org.apache.xmlbeans.XmlException;
@@ -38,21 +38,18 @@ public class XPath {
}
public static XPath compileXPath(String xpath, String currentNodeVar)
- throws XPathCompileException {
+ throws XPathCompileException {
return compileXPath(xpath, currentNodeVar, null);
}
public static XPath compileXPath(String xpath, Map<String, String> namespaces)
- throws XPathCompileException {
+ throws XPathCompileException {
return compileXPath(xpath, "$this", namespaces);
}
- public static XPath compileXPath(
- String xpath, String currentNodeVar, Map<String, String> namespaces)
- throws XPathCompileException {
- return
- new XPathCompilationContext(namespaces, currentNodeVar).
- compile(xpath);
+ public static XPath compileXPath(String xpath, String currentNodeVar, Map<String, String> namespaces)
+ throws XPathCompileException {
+ return new XPathCompilationContext(namespaces, currentNodeVar).compile(xpath);
}
static final class Selector {
@@ -63,10 +60,6 @@ public class XPath {
final XPathStep[] _paths;
}
- //
- //
- //
-
XPath(Selector selector, boolean sawDeepDot) {
_selector = selector;
_sawDeepDot = sawDeepDot;
Copied: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathCompilationContext.java (from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathCompilationContext.java)
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathCompilationContext.java?p2=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathCompilationContext.java&p1=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathCompilationContext.java&r1=1881422&r2=1881423&rev=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathCompilationContext.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathCompilationContext.java Thu Sep 3 23:18:22 2020
@@ -13,16 +13,17 @@
* limitations under the License.
*/
-package org.apache.xmlbeans.impl.common;
+package org.apache.xmlbeans.impl.xpath;
import org.apache.xmlbeans.XmlError;
+import org.apache.xmlbeans.impl.common.XMLChar;
import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
-import static org.apache.xmlbeans.impl.common.XPath._NS_BOUNDARY;
+import static org.apache.xmlbeans.impl.xpath.XPath._NS_BOUNDARY;
class XPathCompilationContext {
private String _expr;
@@ -42,7 +43,7 @@ class XPathCompilationContext {
XPathCompilationContext(Map<String, String> namespaces, String currentNodeVar) {
// TODO: checkme
-// assert (_currentNodeVar == null || _currentNodeVar.startsWith("$"));
+ // assert (_currentNodeVar == null || _currentNodeVar.startsWith("$"));
_currentNodeVar = (currentNodeVar == null) ? "$this" : currentNodeVar;
@@ -144,22 +145,22 @@ class XPathCompilationContext {
switch (prefix != null ? prefix : "") {
case "xml":
- return "http://www.w3.org/XML/1998/namespace";
+ return "http://www.w3.org/XML/1998/namespace";
case "xs":
- return "http://www.w3.org/2001/XMLSchema";
+ return "http://www.w3.org/2001/XMLSchema";
case "xsi":
- return "http://www.w3.org/2001/XMLSchema-instance";
+ return "http://www.w3.org/2001/XMLSchema-instance";
case "fn":
- return "http://www.w3.org/2002/11/xquery-functions";
+ return "http://www.w3.org/2002/11/xquery-functions";
case "xdt":
- return "http://www.w3.org/2003/11/xpath-datatypes";
+ return "http://www.w3.org/2003/11/xpath-datatypes";
case "local":
- return "http://www.w3.org/2003/11/xquery-local-functions";
+ return "http://www.w3.org/2003/11/xquery-local-functions";
}
throw newError("Undefined prefix: " + prefix);
@@ -187,15 +188,15 @@ class XPathCompilationContext {
for (String s : tokens) {
assert (s != null && !s.isEmpty());
- while (isWhitespace(offset)) {
- offset++;
- }
+ while (isWhitespace(offset)) {
+ offset++;
+ }
- if (!startsWith(s, offset)) {
- return false;
- }
+ if (!startsWith(s, offset)) {
+ return false;
+ }
- offset += s.length();
+ offset += s.length();
}
advance(offset);
@@ -332,10 +333,10 @@ class XPathCompilationContext {
} else {
tokenize("child", "::");
name = tokenizeQName();
- steps = addStep(deep, false, name, steps);
- deep = false; // only this step needs to be deep
- // other folowing steps will be deep only if they are preceded by // wildcard
- }
+ steps = addStep(deep, false, name, steps);
+ deep = false; // only this step needs to be deep
+ // other folowing steps will be deep only if they are preceded by // wildcard
+ }
if (tokenize("//")) {
deep = true;
Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathEngine.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathEngine.java?rev=1881423&view=auto
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathEngine.java (added)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathEngine.java Thu Sep 3 23:18:22 2020
@@ -0,0 +1,24 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.xpath;
+
+import org.apache.xmlbeans.impl.store.Cur;
+
+public interface XPathEngine {
+ void release();
+
+ boolean next(Cur c);
+}
Copied: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathExecutionContext.java (from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathExecutionContext.java)
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathExecutionContext.java?p2=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathExecutionContext.java&p1=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathExecutionContext.java&r1=1881422&r2=1881423&rev=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathExecutionContext.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathExecutionContext.java Thu Sep 3 23:18:22 2020
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package org.apache.xmlbeans.impl.common;
+package org.apache.xmlbeans.impl.xpath;
import javax.xml.namespace.QName;
import java.util.ArrayList;
Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathFactory.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathFactory.java?rev=1881423&view=auto
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathFactory.java (added)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathFactory.java Thu Sep 3 23:18:22 2020
@@ -0,0 +1,189 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.xpath;
+
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.store.Cur;
+import org.apache.xmlbeans.impl.xpath.saxon.SaxonXPath;
+import org.apache.xmlbeans.impl.xpath.saxon.SaxonXQuery;
+import org.apache.xmlbeans.impl.xpath.xmlbeans.XmlbeansXPath;
+
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class XPathFactory {
+ private static final int USE_XMLBEANS = 0x01;
+ private static final int USE_SAXON = 0x04;
+
+ private static final Map<String, WeakReference<Path>> _xmlbeansPathCache = new WeakHashMap<>();
+ private static final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+
+ static String getCurrentNodeVar(XmlOptions options) {
+ String currentNodeVar = "this";
+
+ options = XmlOptions.maskNull(options);
+
+ String cnv = options.getXqueryCurrentNodeVar();
+ if (cnv != null) {
+ currentNodeVar = cnv;
+
+ if (currentNodeVar.startsWith("$")) {
+ throw new IllegalArgumentException("Omit the '$' prefix for the current node variable");
+ }
+ }
+
+ return currentNodeVar;
+ }
+
+ public static Path getCompiledPath(String pathExpr, XmlOptions options) {
+ options = XmlOptions.maskNull(options);
+ return getCompiledPath(pathExpr, options, getCurrentNodeVar(options));
+ }
+
+ public static Path getCompiledPath(String pathExpr, XmlOptions options, String currentVar) {
+ int force =
+ options.isXPathUseSaxon() ? USE_SAXON
+ : options.isXPathUseXmlBeans() ? USE_XMLBEANS
+ : USE_XMLBEANS | USE_SAXON;
+
+ Path path = null;
+ WeakReference<Path> pathWeakRef = null;
+ Map<String, String> namespaces = (force & USE_SAXON) != 0 ? new HashMap<>() : null;
+ lock.readLock().lock();
+ try {
+ if ((force & USE_XMLBEANS) != 0) {
+ pathWeakRef = _xmlbeansPathCache.get(pathExpr);
+ }
+ if (pathWeakRef != null) {
+ path = pathWeakRef.get();
+ }
+ if (path != null) {
+ return path;
+ }
+ } finally {
+ lock.readLock().unlock();
+ }
+ lock.writeLock().lock();
+ try {
+ if ((force & USE_XMLBEANS) != 0) {
+ pathWeakRef = _xmlbeansPathCache.get(pathExpr);
+ if (pathWeakRef != null) {
+ path = pathWeakRef.get();
+ }
+ if (path == null) {
+ path = getCompiledPathXmlBeans(pathExpr, currentVar, namespaces);
+ }
+ }
+ if (path == null && (force & USE_SAXON) != 0) {
+ path = getCompiledPathSaxon(pathExpr, currentVar, namespaces);
+ }
+ if (path == null) {
+ StringBuilder errMessage = new StringBuilder();
+ if ((force & USE_XMLBEANS) != 0) {
+ errMessage.append(" Trying XmlBeans path engine...");
+ }
+ if ((force & USE_SAXON) != 0) {
+ errMessage.append(" Trying Saxon path engine...");
+ }
+
+ throw new RuntimeException(errMessage.toString() + " FAILED on " + pathExpr);
+ }
+ } finally {
+ lock.writeLock().unlock();
+ }
+ return path;
+ }
+
+ private static Path getCompiledPathXmlBeans(String pathExpr, String currentVar, Map<String, String> namespaces) {
+ try {
+ Path path = new XmlbeansXPath(pathExpr, currentVar,
+ XPath.compileXPath(pathExpr, currentVar, namespaces));
+ _xmlbeansPathCache.put(pathExpr, new WeakReference<>(path));
+ return path;
+ } catch (XPath.XPathCompileException ignored) {
+ return null;
+ }
+ }
+
+ public static Path getCompiledPathSaxon(String pathExpr, String currentVar, Map<String, String> namespaces) {
+ if (namespaces == null) {
+ namespaces = new HashMap<>();
+ }
+
+ try {
+ XPath.compileXPath(pathExpr, currentVar, namespaces);
+ } catch (XPath.XPathCompileException e) {
+ //do nothing, this function is only called to populate the namespaces map
+ }
+
+
+ int offset = Integer.parseInt(namespaces.getOrDefault(XPath._NS_BOUNDARY, "0"));
+ namespaces.remove(XPath._NS_BOUNDARY);
+
+ return new SaxonXPath(pathExpr.substring(offset), currentVar, namespaces);
+ }
+
+
+ public static String compilePath(String pathExpr, XmlOptions options) {
+ getCompiledPath(pathExpr, options);
+ return pathExpr;
+ }
+
+ //
+ // Xqrl store specific implementation of compiled path/query
+ //
+
+ public static XmlObject[] objectExecQuery(Cur c, String queryExpr, XmlOptions options) {
+ return getCompiledQuery(queryExpr, options).objectExecute(c, options);
+ }
+
+ public static XmlCursor cursorExecQuery(Cur c, String queryExpr, XmlOptions options) {
+ return getCompiledQuery(queryExpr, options).cursorExecute(c, options);
+ }
+
+ public static synchronized XQuery getCompiledQuery(String queryExpr, XmlOptions options) {
+ return getCompiledQuery(queryExpr, XPathFactory.getCurrentNodeVar(options), options);
+ }
+
+ static synchronized XQuery getCompiledQuery(String queryExpr, String currentVar, XmlOptions options) {
+ assert queryExpr != null;
+ options = XmlOptions.maskNull(options);
+
+ //Parse the query via XmlBeans: need to figure out end of prolog
+ //in order to bind $this...not good but...
+ Map<String, String> boundary = new HashMap<>();
+ int boundaryVal;
+ try {
+ XPath.compileXPath(queryExpr, currentVar, boundary);
+ } catch (XPath.XPathCompileException e) {
+ //don't care if it fails, just care about boundary
+ } finally {
+ boundaryVal = Integer.parseInt(boundary.getOrDefault(XPath._NS_BOUNDARY, "0"));
+ }
+
+ return new SaxonXQuery(queryExpr, currentVar, boundaryVal, options);
+ }
+
+ public static synchronized String compileQuery(String queryExpr, XmlOptions options) {
+ getCompiledQuery(queryExpr, options);
+ return queryExpr;
+ }
+}
Copied: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathStep.java (from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathStep.java)
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathStep.java?p2=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathStep.java&p1=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathStep.java&r1=1881422&r2=1881423&rev=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathStep.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathStep.java Thu Sep 3 23:18:22 2020
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package org.apache.xmlbeans.impl.common;
+package org.apache.xmlbeans.impl.xpath;
import javax.xml.namespace.QName;
Copied: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XQuery.java (from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Query.java)
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XQuery.java?p2=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XQuery.java&p1=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Query.java&r1=1881422&r2=1881423&rev=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Query.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XQuery.java Thu Sep 3 23:18:22 2020
@@ -13,277 +13,15 @@
* limitations under the License.
*/
-package org.apache.xmlbeans.impl.store;
+package org.apache.xmlbeans.impl.xpath;
-import org.apache.xmlbeans.*;
-import org.apache.xmlbeans.impl.common.DefaultClassLoaderResourceLoader;
-import org.apache.xmlbeans.impl.common.XPath;
-import org.apache.xmlbeans.impl.xquery.saxon.XBeansXQuery;
-import org.w3c.dom.Node;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.store.Cur;
-import javax.xml.namespace.QName;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public abstract class Query {
- public static final String QUERY_DELEGATE_INTERFACE = "QUERY_DELEGATE_INTERFACE";
- public static String _useDelegateForXQuery = "use delegate for xquery";
-
-
- abstract XmlObject[] objectExecute(Cur c, XmlOptions options);
-
- abstract XmlCursor cursorExecute(Cur c, XmlOptions options);
-
- //
- // Xqrl store specific implementation of compiled path/query
- //
-
- static XmlObject[] objectExecQuery(Cur c, String queryExpr, XmlOptions options) {
- return getCompiledQuery(queryExpr, options).objectExecute(c, options);
- }
-
- static XmlCursor cursorExecQuery(Cur c, String queryExpr, XmlOptions options) {
- return getCompiledQuery(queryExpr, options).cursorExecute(c, options);
- }
-
- public static synchronized Query getCompiledQuery(String queryExpr, XmlOptions options) {
- return getCompiledQuery(queryExpr, Path.getCurrentNodeVar(options), options);
- }
-
- static synchronized Query getCompiledQuery(String queryExpr, String currentVar, XmlOptions options) {
- assert queryExpr != null;
- options = XmlOptions.maskNull(options);
- Query query;
-
- //Parse the query via XBeans: need to figure out end of prolog
- //in order to bind $this...not good but...
- Map<String, String> boundary = new HashMap<>();
- int boundaryVal;
- try {
- XPath.compileXPath(queryExpr, currentVar, boundary);
- } catch (XPath.XPathCompileException e) {
- //don't care if it fails, just care about boundary
- } finally {
- boundaryVal = Integer.parseInt(boundary.getOrDefault(XPath._NS_BOUNDARY, "0"));
- }
-
-
- String delIntfName = XBeansXQuery.class.getName();
- query = DelegateQueryImpl.createDelegateCompiledQuery(delIntfName, queryExpr, currentVar, boundaryVal, options);
-
- if (query != null) {
- //_delegateQueryCache.put(queryExpr, query);
- return query;
- }
-
- throw new RuntimeException("No query engine found");
- }
-
- public static synchronized String compileQuery(String queryExpr, XmlOptions options) {
- getCompiledQuery(queryExpr, options);
- return queryExpr;
- }
-
-
-
-
- private static final class DelegateQueryImpl extends Query {
- private DelegateQueryImpl(QueryDelegate.QueryInterface xqueryImpl) {
- _xqueryImpl = xqueryImpl;
- }
-
- static Query createDelegateCompiledQuery(String delIntfName,
- String queryExpr,
- String currentVar,
- int boundary,
- XmlOptions xmlOptions) {
- assert !(currentVar.startsWith(".") || currentVar.startsWith(".."));
- QueryDelegate.QueryInterface impl =
- QueryDelegate.createInstance(delIntfName, queryExpr,
- currentVar, boundary, xmlOptions);
- if (impl == null) {
- return null;
- }
-
- return new DelegateQueryImpl(impl);
- }
-
- XmlObject[] objectExecute(Cur c, XmlOptions options) {
- return new DelegateQueryEngine(_xqueryImpl, c, options).objectExecute();
- }
-
- XmlCursor cursorExecute(Cur c, XmlOptions options) {
- return new DelegateQueryEngine(_xqueryImpl, c, options).cursorExecute();
- }
-
-
- private static class DelegateQueryEngine {
- public DelegateQueryEngine(QueryDelegate.QueryInterface xqImpl,
- Cur c, XmlOptions opt) {
-
- _engine = xqImpl;
- _version = c._locale.version();
- _cur = c.weakCur(this);
- _options = opt;
-
- }
-
- public XmlObject[] objectExecute() {
- if (_cur != null && _version != _cur._locale.version())
- //throw new ConcurrentModificationException
- // ("Document changed during select")
- {
- ;
- }
-
- Map<String, Object> bindings = XmlOptions.maskNull(_options).getXqueryVariables();
- List resultsList = _engine.execQuery(_cur.getDom(), bindings);
-
- XmlObject[] result = new XmlObject[resultsList.size()];
- int i;
- for (i = 0; i < resultsList.size(); i++) {
- //copy objects into the locale
- Locale l = Locale.getLocale(_cur._locale._schemaTypeLoader, _options);
-
- l.enter();
- Object node = resultsList.get(i);
- Cur res = null;
- try {
- //typed function results of XQuery
- if (!(node instanceof Node)) {
- //TODO: exact same code as Path.java
- //make a common super-class and pull this--what to name that
- //superclass???
- res = l.load("<xml-fragment/>").tempCur();
- res.setValue(node.toString());
- SchemaType type = getType(node);
- Locale.autoTypeDocument(res, type, null);
- result[i] = res.getObject();
- } else {
- res = loadNode(l, (Node) node);
- }
- result[i] = res.getObject();
- } catch (XmlException e) {
- throw new RuntimeException(e);
- } finally {
- l.exit();
- }
- res.release();
- }
- release();
- _engine = null;
- return result;
- }
-
- private SchemaType getType(Object node) {
- SchemaType type;
- if (node instanceof Integer) {
- type = XmlInteger.type;
- } else if (node instanceof Double) {
- type = XmlDouble.type;
- } else if (node instanceof Long) {
- type = XmlLong.type;
- } else if (node instanceof Float) {
- type = XmlFloat.type;
- } else if (node instanceof BigDecimal) {
- type = XmlDecimal.type;
- } else if (node instanceof Boolean) {
- type = XmlBoolean.type;
- } else if (node instanceof String) {
- type = XmlString.type;
- } else if (node instanceof Date) {
- type = XmlDate.type;
- } else {
- type = XmlAnySimpleType.type;
- }
- return type;
- }
-
- public XmlCursor cursorExecute() {
- if (_cur != null && _version != _cur._locale.version())
- //throw new ConcurrentModificationException
- // ("Document changed during select")
- {
- ;
- }
-
- Map<String, Object> bindings = XmlOptions.maskNull(_options).getXqueryVariables();
- List resultsList = _engine.execQuery(_cur.getDom(), bindings);
-
- int i;
- _engine = null;
-
- Locale locale = Locale.getLocale(_cur._locale._schemaTypeLoader, _options);
- locale.enter();
- Locale.LoadContext _context = new Cur.CurLoadContext(locale, _options);
- Cursor resultCur = null;
- try {
- for (i = 0; i < resultsList.size(); i++) {
- loadNodeHelper(locale, (Node) resultsList.get(i), _context);
- }
- Cur c = _context.finish();
- Locale.associateSourceName(c, _options);
- Locale.autoTypeDocument(c, null, _options);
- resultCur = new Cursor(c);
- } catch (Exception e) {
- } finally {
- locale.exit();
- }
- release();
- return resultCur;
- }
-
-
- public void release() {
- if (_cur != null) {
- _cur.release();
- _cur = null;
- }
- }
-
-
- private Cur loadNode(Locale locale, Node node) {
- Locale.LoadContext context = new Cur.CurLoadContext(locale, _options);
-
- try {
- loadNodeHelper(locale, node, context);
- Cur c = context.finish();
- Locale.associateSourceName(c, _options);
- Locale.autoTypeDocument(c, null, _options);
- return c;
- } catch (Exception e) {
- throw new XmlRuntimeException(e.getMessage(), e);
- }
- }
-
- private void loadNodeHelper(Locale locale, Node node, Locale.LoadContext context) {
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- QName attName = new QName(node.getNamespaceURI(),
- node.getLocalName(),
- node.getPrefix());
- context.attr(attName, node.getNodeValue());
- } else {
- locale.loadNode(node, context);
- }
-
- }
-
-
- private Cur _cur;
- private QueryDelegate.QueryInterface _engine;
- private long _version;
- private XmlOptions _options;
- }
-
- private QueryDelegate.QueryInterface _xqueryImpl;
- }
+public interface XQuery {
+ XmlObject[] objectExecute(Cur c, XmlOptions options);
+ XmlCursor cursorExecute(Cur c, XmlOptions options);
}
Copied: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPath.java (from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/XBeansXPath.java)
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPath.java?p2=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPath.java&p1=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/XBeansXPath.java&r1=1881422&r2=1881423&rev=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/XBeansXPath.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPath.java Thu Sep 3 23:18:22 2020
@@ -22,7 +22,11 @@ import net.sf.saxon.om.NodeInfo;
import net.sf.saxon.om.SequenceTool;
import net.sf.saxon.sxpath.*;
import net.sf.saxon.tree.wrapper.VirtualNode;
-import org.apache.xmlbeans.impl.store.PathDelegate;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.store.Cur;
+import org.apache.xmlbeans.impl.xpath.Path;
+import org.apache.xmlbeans.impl.xpath.XPath;
+import org.apache.xmlbeans.impl.xpath.XPathEngine;
import org.w3c.dom.Node;
import javax.xml.transform.TransformerException;
@@ -33,9 +37,8 @@ import java.util.List;
import java.util.Map;
@SuppressWarnings("WeakerAccess")
-public class XBeansXPath
- implements PathDelegate.SelectPathInterface {
- private final Map<String, String> namespaceMap = new HashMap<String, String>();
+public class SaxonXPath implements Path {
+ private final Map<String, String> namespaceMap = new HashMap<>();
private String path;
private String contextVar;
private String defaultNS;
@@ -46,16 +49,20 @@ public class XBeansXPath
* @param path The XPath expression
* @param contextVar The name of the context variable
* @param namespaceMap a map of prefix/uri bindings for NS support
- * @param defaultNS the uri for the default element NS, if any
*/
- public XBeansXPath(String path, String contextVar,
- Map<String, String> namespaceMap, String defaultNS) {
+ public SaxonXPath(String path, String contextVar, Map<String, String> namespaceMap) {
this.path = path;
this.contextVar = contextVar;
- this.defaultNS = defaultNS;
+ this.defaultNS = namespaceMap.get(XPath._DEFAULT_ELT_NS);
this.namespaceMap.putAll(namespaceMap);
+ this.namespaceMap.remove(XPath._DEFAULT_ELT_NS);
}
+ public XPathEngine execute(Cur c, XmlOptions options) {
+ return new SaxonXPathEngine(this, c);
+ }
+
+
/**
* Select all nodes that are selectable by this XPath
* expression. If multiple nodes match, multiple nodes
Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPathEngine.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPathEngine.java?rev=1881423&view=auto
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPathEngine.java (added)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPathEngine.java Thu Sep 3 23:18:22 2020
@@ -0,0 +1,138 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.xpath.saxon;
+
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.store.Cur;
+import org.apache.xmlbeans.impl.store.DomImpl;
+import org.apache.xmlbeans.impl.store.Locale;
+import org.apache.xmlbeans.impl.xpath.XPathEngine;
+import org.apache.xmlbeans.impl.xpath.XPathExecutionContext;
+import org.w3c.dom.Node;
+
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ConcurrentModificationException;
+import java.util.Date;
+import java.util.List;
+
+public class SaxonXPathEngine extends XPathExecutionContext implements XPathEngine {
+ // full datetime format: yyyy-MM-dd'T'HH:mm:ss'Z'
+ private final DateFormat xmlDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
+ private Cur _cur;
+ private SaxonXPath _engine;
+ private boolean _firstCall = true;
+ private final long _version;
+
+
+ SaxonXPathEngine(SaxonXPath xpathImpl, Cur c) {
+ _engine = xpathImpl;
+ _version = c.getLocale().version();
+ _cur = c.weakCur(this);
+ }
+
+ public boolean next(Cur c) {
+ if (!_firstCall) {
+ return false;
+ }
+
+ _firstCall = false;
+
+ if (_cur != null && _version != _cur.getLocale().version()) {
+ throw new ConcurrentModificationException("Document changed during select");
+ }
+
+ List resultsList = _engine.selectPath(_cur.getDom());
+
+ int i;
+ for (i = 0; i < resultsList.size(); i++) {
+ //simple type function results
+ Object node = resultsList.get(i);
+ Cur pos = null;
+ if (!(node instanceof Node)) {
+ Object obj = resultsList.get(i);
+ String value;
+ if (obj instanceof Date) {
+ value = xmlDateFormat.format((Date) obj);
+ } else if (obj instanceof BigDecimal) {
+ value = ((BigDecimal) obj).toPlainString();
+ } else {
+ value = obj.toString();
+ }
+
+ //we cannot leave the cursor's locale, as
+ //everything is done in the selections of this cursor
+
+ org.apache.xmlbeans.impl.store.Locale l = c.getLocale();
+ try {
+ pos = l.load("<xml-fragment/>").tempCur();
+ pos.setValue(value);
+ SchemaType type = getType(node);
+ Locale.autoTypeDocument(pos, type, null);
+ //move the cur to the actual text
+ pos.next();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ assert (node instanceof DomImpl.Dom) :
+ "New object created in XPATH!";
+ pos = ((DomImpl.Dom) node).tempCur();
+
+ }
+ c.addToSelection(pos);
+ pos.release();
+ }
+ release();
+ _engine = null;
+ return true;
+ }
+
+ private SchemaType getType(Object node) {
+ SchemaType type;
+ if (node instanceof Integer) {
+ type = XmlInteger.type;
+ } else if (node instanceof Double) {
+ type = XmlDouble.type;
+ } else if (node instanceof Long) {
+ type = XmlLong.type;
+ } else if (node instanceof Float) {
+ type = XmlFloat.type;
+ } else if (node instanceof BigDecimal) {
+ type = XmlDecimal.type;
+ } else if (node instanceof Boolean) {
+ type = XmlBoolean.type;
+ } else if (node instanceof String) {
+ type = XmlString.type;
+ } else if (node instanceof Date) {
+ type = XmlDate.type;
+ } else {
+ type = XmlAnySimpleType.type;
+ }
+ return type;
+ }
+
+ public void release() {
+ if (_cur != null) {
+ _cur.release();
+ _cur = null;
+ }
+ }
+
+
+}
Copied: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXQuery.java (from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java)
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXQuery.java?p2=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXQuery.java&p1=xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java&r1=1881422&r2=1881423&rev=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXQuery.java Thu Sep 3 23:18:22 2020
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package org.apache.xmlbeans.impl.xquery.saxon;
+package org.apache.xmlbeans.impl.xpath.saxon;
import net.sf.saxon.Configuration;
import net.sf.saxon.dom.DocumentWrapper;
@@ -27,10 +27,11 @@ import net.sf.saxon.query.StaticQueryCon
import net.sf.saxon.query.XQueryExpression;
import net.sf.saxon.type.BuiltInAtomicType;
import net.sf.saxon.value.*;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlRuntimeException;
-import org.apache.xmlbeans.XmlTokenSource;
-import org.apache.xmlbeans.impl.store.QueryDelegate;
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.store.Cur;
+import org.apache.xmlbeans.impl.store.Cursor;
+import org.apache.xmlbeans.impl.store.Locale;
+import org.apache.xmlbeans.impl.xpath.XQuery;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -43,15 +44,20 @@ import javax.xml.xpath.XPathException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
+import java.util.Date;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
-public class XBeansXQuery
- implements QueryDelegate.QueryInterface {
- private XQueryExpression xquery;
- private String contextVar;
- private Configuration config;
+public class SaxonXQuery implements XQuery {
+ private final XQueryExpression xquery;
+ private final String contextVar;
+ private final Configuration config;
+
+ private Cur _cur;
+ private long _version;
+ private XmlOptions _options;
+
/**
* Construct given an XQuery expression string.
@@ -60,7 +66,12 @@ public class XBeansXQuery
* @param contextVar The name of the context variable
* @param boundary The offset of the end of the prolog
*/
- public XBeansXQuery(final String query, String contextVar, Integer boundary, XmlOptions xmlOptions) {
+ public SaxonXQuery(final String query, String contextVar, Integer boundary, XmlOptions xmlOptions) {
+ assert !(contextVar.startsWith(".") || contextVar.startsWith(".."));
+
+ _options = xmlOptions;
+
+
config = new Configuration();
StaticQueryContext sc = config.newStaticQueryContext();
Map<String, String> nsMap = xmlOptions.getLoadAdditionalNamespaces();
@@ -78,6 +89,22 @@ public class XBeansXQuery
}
}
+
+ public XmlObject[] objectExecute(Cur c, XmlOptions options) {
+ _version = c.getLocale().version();
+ _cur = c.weakCur(this);
+ this._options = options;
+ return objectExecute();
+ }
+
+ public XmlCursor cursorExecute(Cur c, XmlOptions options) {
+ _version = c.getLocale().version();
+ _cur = c.weakCur(this);
+ this._options = options;
+ return cursorExecute();
+ }
+
+
public List execQuery(Object node, Map variableBindings) {
try {
Node contextNode = (Node) node;
@@ -206,4 +233,144 @@ public class XBeansXQuery
return new ObjectValue(value);
}
}
+
+
+ public XmlObject[] objectExecute() {
+ if (_cur != null && _version != _cur.getLocale().version())
+ //throw new ConcurrentModificationException
+ // ("Document changed during select")
+ {
+ ;
+ }
+
+ Map<String, Object> bindings = XmlOptions.maskNull(_options).getXqueryVariables();
+ List resultsList = execQuery(_cur.getDom(), bindings);
+
+ XmlObject[] result = new XmlObject[resultsList.size()];
+ int i;
+ for (i = 0; i < resultsList.size(); i++) {
+ //copy objects into the locale
+ Locale l = Locale.getLocale(_cur.getLocale().getSchemaTypeLoader(), _options);
+
+ l.enter();
+ Object node = resultsList.get(i);
+ Cur res = null;
+ try {
+ //typed function results of XQuery
+ if (!(node instanceof Node)) {
+ //TODO: exact same code as Path.java
+ //make a common super-class and pull this--what to name that
+ //superclass???
+ res = l.load("<xml-fragment/>").tempCur();
+ res.setValue(node.toString());
+ SchemaType type = getType(node);
+ Locale.autoTypeDocument(res, type, null);
+ result[i] = res.getObject();
+ } else {
+ res = loadNode(l, (Node) node);
+ }
+ result[i] = res.getObject();
+ } catch (XmlException e) {
+ throw new RuntimeException(e);
+ } finally {
+ l.exit();
+ }
+ res.release();
+ }
+ release();
+ return result;
+ }
+
+ private SchemaType getType(Object node) {
+ SchemaType type;
+ if (node instanceof Integer) {
+ type = XmlInteger.type;
+ } else if (node instanceof Double) {
+ type = XmlDouble.type;
+ } else if (node instanceof Long) {
+ type = XmlLong.type;
+ } else if (node instanceof Float) {
+ type = XmlFloat.type;
+ } else if (node instanceof BigDecimal) {
+ type = XmlDecimal.type;
+ } else if (node instanceof Boolean) {
+ type = XmlBoolean.type;
+ } else if (node instanceof String) {
+ type = XmlString.type;
+ } else if (node instanceof Date) {
+ type = XmlDate.type;
+ } else {
+ type = XmlAnySimpleType.type;
+ }
+ return type;
+ }
+
+ public XmlCursor cursorExecute() {
+ if (_cur != null && _version != _cur.getLocale().version())
+ //throw new ConcurrentModificationException
+ // ("Document changed during select")
+ {
+ ;
+ }
+
+ Map<String, Object> bindings = XmlOptions.maskNull(_options).getXqueryVariables();
+ List resultsList = execQuery(_cur.getDom(), bindings);
+
+ int i;
+
+ Locale locale = Locale.getLocale(_cur.getLocale().getSchemaTypeLoader(), _options);
+ locale.enter();
+ Locale.LoadContext _context = new Cur.CurLoadContext(locale, _options);
+ Cursor resultCur = null;
+ try {
+ for (i = 0; i < resultsList.size(); i++) {
+ loadNodeHelper(locale, (Node) resultsList.get(i), _context);
+ }
+ Cur c = _context.finish();
+ Locale.associateSourceName(c, _options);
+ Locale.autoTypeDocument(c, null, _options);
+ resultCur = new Cursor(c);
+ } catch (Exception e) {
+ } finally {
+ locale.exit();
+ }
+ release();
+ return resultCur;
+ }
+
+
+ public void release() {
+ if (_cur != null) {
+ _cur.release();
+ _cur = null;
+ }
+ }
+
+
+ private Cur loadNode(Locale locale, Node node) {
+ Locale.LoadContext context = new Cur.CurLoadContext(locale, _options);
+
+ try {
+ loadNodeHelper(locale, node, context);
+ Cur c = context.finish();
+ Locale.associateSourceName(c, _options);
+ Locale.autoTypeDocument(c, null, _options);
+ return c;
+ } catch (Exception e) {
+ throw new XmlRuntimeException(e.getMessage(), e);
+ }
+ }
+
+ private void loadNodeHelper(Locale locale, Node node, Locale.LoadContext context) {
+ if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
+ QName attName = new QName(node.getNamespaceURI(),
+ node.getLocalName(),
+ node.getPrefix());
+ context.attr(attName, node.getNodeValue());
+ } else {
+ locale.loadNode(node, context);
+ }
+
+ }
+
}
Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPath.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPath.java?rev=1881423&view=auto
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPath.java (added)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPath.java Thu Sep 3 23:18:22 2020
@@ -0,0 +1,56 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.xpath.xmlbeans;
+
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.store.Cur;
+import org.apache.xmlbeans.impl.xpath.Path;
+import org.apache.xmlbeans.impl.xpath.XPath;
+import org.apache.xmlbeans.impl.xpath.XPathEngine;
+import org.apache.xmlbeans.impl.xpath.XPathFactory;
+
+//
+// XmlBeans store specific implementation of compiled path
+//
+
+public class XmlbeansXPath implements Path {
+ private final String _pathKey;
+ private final String _currentVar;
+ private final XPath _compiledPath;
+
+ public XmlbeansXPath(String pathExpr, String currentVar, XPath xpath) {
+ _pathKey = pathExpr;
+
+ _currentVar = currentVar;
+ _compiledPath = xpath;
+ }
+
+ public XPathEngine execute(Cur c, XmlOptions options) {
+ options = XmlOptions.maskNull(options);
+
+ // The builtin XPath engine works only on containers. Delegate to
+ // saxon otherwise. Also, if the path had a //. at the end, the
+ // simple xpath engine can't do the generate case, it only handles
+ // attrs and elements.
+ if (!c.isContainer() || _compiledPath.sawDeepDot()) {
+ Path xpe = XPathFactory.getCompiledPathSaxon(_pathKey, _currentVar, null);
+ return xpe.execute(c, options);
+ } else {
+ return new XmlbeansXPathEngine(_compiledPath, c);
+ }
+ }
+
+}
Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPathEngine.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPathEngine.java?rev=1881423&view=auto
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPathEngine.java (added)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPathEngine.java Thu Sep 3 23:18:22 2020
@@ -0,0 +1,126 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.xpath.xmlbeans;
+
+import org.apache.xmlbeans.impl.store.Cur;
+import org.apache.xmlbeans.impl.store.Locale;
+import org.apache.xmlbeans.impl.xpath.XPath;
+import org.apache.xmlbeans.impl.xpath.XPathEngine;
+import org.apache.xmlbeans.impl.xpath.XPathExecutionContext;
+
+import java.util.ConcurrentModificationException;
+
+class XmlbeansXPathEngine extends XPathExecutionContext implements XPathEngine {
+ XmlbeansXPathEngine(XPath xpath, Cur c) {
+ assert c.isContainer();
+
+ _version = c.getLocale().version();
+ _cur = c.weakCur(this);
+
+ _cur.push();
+
+ init(xpath);
+
+ int ret = start();
+
+ if ((ret & HIT) != 0) {
+ c.addToSelection();
+ }
+
+ doAttrs(ret, c);
+
+ if ((ret & DESCEND) == 0 || !Locale.toFirstChildElement(_cur)) {
+ release();
+ }
+ }
+
+ private void advance(Cur c) {
+ assert _cur != null;
+
+ if (_cur.isFinish()) {
+ if (_cur.isAtEndOfLastPush()) {
+ release();
+ } else {
+ end();
+ _cur.next();
+ }
+ } else if (_cur.isElem()) {
+ int ret = element(_cur.getName());
+
+ if ((ret & HIT) != 0) {
+ c.addToSelection(_cur);
+ }
+
+ doAttrs(ret, c);
+
+ if ((ret & DESCEND) == 0 || !Locale.toFirstChildElement(_cur)) {
+ end();
+ _cur.skip();
+ }
+ } else {
+ do {
+ _cur.next();
+ }
+ while (!_cur.isContainerOrFinish());
+ }
+ }
+
+ private void doAttrs(int ret, Cur c) {
+ assert _cur.isContainer();
+
+ if ((ret & ATTRS) != 0) {
+ if (_cur.toFirstAttr()) {
+ do {
+ if (attr(_cur.getName())) {
+ c.addToSelection(_cur);
+ }
+ }
+ while (_cur.toNextAttr());
+
+ _cur.toParent();
+ }
+ }
+ }
+
+ public boolean next(Cur c) {
+ if (_cur != null && _version != _cur.getLocale().version()) {
+ throw new ConcurrentModificationException("Document changed during select");
+ }
+
+ int startCount = c.selectionCount();
+
+ while (_cur != null) {
+ advance(c);
+
+ if (startCount != c.selectionCount()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public void release() {
+ if (_cur != null) {
+ _cur.release();
+ _cur = null;
+ }
+ }
+
+ private final long _version;
+ private Cur _cur;
+}
+
Modified: xmlbeans/trunk/src/main/multimodule/java9/module-info.class
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/multimodule/java9/module-info.class?rev=1881423&r1=1881422&r2=1881423&view=diff
==============================================================================
Binary files - no diff available.
Modified: xmlbeans/trunk/src/main/multimodule/java9/module-info.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/multimodule/java9/module-info.java?rev=1881423&r1=1881422&r2=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/multimodule/java9/module-info.java (original)
+++ xmlbeans/trunk/src/main/multimodule/java9/module-info.java Thu Sep 3 23:18:22 2020
@@ -30,12 +30,11 @@ module org.apache.xmlbeans {
exports org.apache.xmlbeans.impl.repackage;
exports org.apache.xmlbeans.impl.common;
exports org.apache.xmlbeans.impl.config;
- // exports org.apache.xmlbeans.impl.xquery;
- exports org.apache.xmlbeans.impl.xquery.saxon;
exports org.apache.xmlbeans.impl.richParser;
exports org.apache.xmlbeans.impl.soap;
- // exports org.apache.xmlbeans.impl.xpath;
+ exports org.apache.xmlbeans.impl.xpath;
exports org.apache.xmlbeans.impl.xpath.saxon;
+ exports org.apache.xmlbeans.impl.xpath.xmlbeans;
exports org.apache.xmlbeans.impl.regex;
exports org.apache.xmlbeans.impl.tool;
exports org.apache.xmlbeans.impl.schema;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org