gpt4 book ai didi

net.sf.saxon.sxpath.XPathStaticContext类的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 23:11:05 26 4
gpt4 key购买 nike

本文整理了Java中net.sf.saxon.sxpath.XPathStaticContext类的一些代码示例,展示了XPathStaticContext类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XPathStaticContext类的具体详情如下:
包路径:net.sf.saxon.sxpath.XPathStaticContext
类名称:XPathStaticContext

XPathStaticContext介绍

[英]This interface defines methods that must be provided when Saxon's free-standing XPath API is used. The default implementation of this interface is net.sf.saxon.sxpath.IndependentContext, and that implementation should be adequate for most purposes; but for extra customization, a user-written implementation of this interface may be used instead.
[中]该接口定义了在使用Saxon的独立XPathAPI时必须提供的方法。这个接口的默认实现是net。旧金山。撒克逊人。sxpath。独立的环境,并且对于大多数目的来说,实施应该是足够的;但对于额外的定制,可以使用该接口的用户编写的实现。

代码示例

代码示例来源:origin: pmd/pmd

final String name = propertyDescriptor.name();
if (!"xpath".equals(name)) {
  final XPathVariable xpathVariable = xpathStaticContext.declareVariable(null, name);
  xpathVariables.add(xpathVariable);

代码示例来源:origin: net.sf.saxon/Saxon-HE

Executable exec = new Executable(config);
boolean allowXPath30 = staticContext.getXPathVersion() >= 30;
exec.setTopLevelPackage(staticContext.getPackageData());
exec.setSchemaAware(staticContext.getPackageData().isSchemaAware());
exec.setHostLanguage(Configuration.XPATH);
RetainedStaticContext rsc = staticContext.makeRetainedStaticContext();
exp.setRetainedStaticContext(rsc);
ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
ItemType contextItemType = staticContext.getRequiredContextItemType();
ContextItemStaticInfo cit = config.makeContextItemStaticInfo(contextItemType, true);
exp = exp.typeCheck(visitor, cit);
SlotManager map = staticContext.getStackFrameMap();
int numberOfExternalVariables = map.getNumberOfVariables();
ExpressionTool.allocateSlots(exp, numberOfExternalVariables, map);

代码示例来源:origin: org.opengis.cite.saxon/saxon9

/**
 * Set the external namespace resolver to be used. The NamespaceResolver is stored
 * as part of the static context. It overrides any namespaces declared directly
 * using declareNamespace on the staticContext object
 * @param namespaceResolver The namespace resolver, which maintains a mapping of prefixes to URIs.
 * Any namespace prefix used in the XPath expression is resolved using this namespaceResolver.
 */
public void setNamespaceResolver(NamespaceResolver namespaceResolver) {
  staticContext.setNamespaceResolver(namespaceResolver);
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * Prepare (compile) an XSLT pattern for subsequent evaluation. The result is an XPathExpression
 * object representing a (pseudo-) expression that when evaluated returns a boolean result: true
 * if the context node matches the pattern, false if it does not.
 * @param pattern the XSLT pattern to be compiled, supplied as a string
 * @return an XPathExpression object representing the pattern, wrapped as an expression
 * @throws XPathException if the syntax of the expression is wrong, or if it references namespaces,
 * variables, or functions that have not been declared.
 * @since 9.1
 */
public XPathExpression createPattern(String pattern) throws XPathException {
  Pattern pat = Pattern.make(pattern, staticContext, staticContext.getExecutable());
  ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
  pat.analyze(visitor, Type.NODE_TYPE);
  SlotManager map = staticContext.getStackFrameMap();
  int slots = map.getNumberOfVariables();
  slots = pat.allocateSlots(staticContext, map, slots);
  PatternSponsor sponsor = new PatternSponsor(pat);
  XPathExpression xpe = new XPathExpression(this, sponsor);
  xpe.setStackFrameMap(map, slots);
  return xpe;
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

/**
 * Get the Configuration in use.
 *
 * @return the Saxon configuration
 */
public Configuration getConfiguration() {
  return staticContext.getConfiguration();
}

代码示例来源:origin: org.opengis.cite.saxon/saxon9

/**
* Prepare (compile) an XPath expression for subsequent evaluation.
* @param expression The XPath expression to be compiled, supplied as a string.
* @return an XPathExpression object representing the prepared expression
* @throws XPathException if the syntax of the expression is wrong, or if it references namespaces,
* variables, or functions that have not been declared.
*/
public XPathExpression createExpression(String expression) throws XPathException {
  Expression exp = ExpressionTool.make(expression, staticContext, 0, -1, 1, false);
  exp.setContainer(staticContext);
  ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
  visitor.setExecutable(getExecutable());
  exp = visitor.typeCheck(exp, Type.ITEM_TYPE);
  SlotManager map = staticContext.getStackFrameMap();
  int numberOfExternalVariables = map.getNumberOfVariables();
  ExpressionTool.allocateSlots(exp, numberOfExternalVariables, map);
  XPathExpression xpe = new XPathExpression(this, exp);
  xpe.setStackFrameMap(map, numberOfExternalVariables);
  return xpe;
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * Get the external namespace resolver, if one has been set using {@link #setNamespaceResolver}
 * @return the namespace resolver supplied by the user if set, or a system-defined namespace resolver
 * otherwise. By default, the {@link IndependentContext} object used as the {@link XPathStaticContext}
 * also acts as the {@link NamespaceResolver}.
 */
public NamespaceResolver getNamespaceResolver() {
  return staticContext.getNamespaceResolver();
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * Get the executable
 * @return the executable. This holds details of function bindings and collations.
 */
public Executable getExecutable() {
  return staticContext.getExecutable();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

Executable exec = new Executable(config);
boolean allowXPath30 = staticContext.getXPathVersion() >= 30;
exec.setTopLevelPackage(staticContext.getPackageData());
exec.setSchemaAware(staticContext.getPackageData().isSchemaAware());
exec.setHostLanguage(Configuration.XPATH);
RetainedStaticContext rsc = staticContext.makeRetainedStaticContext();
exp.setRetainedStaticContext(rsc);
ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
ItemType contextItemType = staticContext.getRequiredContextItemType();
ContextItemStaticInfo cit = config.makeContextItemStaticInfo(contextItemType, true);
exp = exp.typeCheck(visitor, cit);
SlotManager map = staticContext.getStackFrameMap();
int numberOfExternalVariables = map.getNumberOfVariables();
ExpressionTool.allocateSlots(exp, numberOfExternalVariables, map);

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * Set the external namespace resolver to be used. The NamespaceResolver is stored
 * as part of the static context. It overrides any namespaces declared directly
 * using declareNamespace on the staticContext object
 * @param namespaceResolver The namespace resolver, which maintains a mapping of prefixes to URIs.
 * Any namespace prefix used in the XPath expression is resolved using this namespaceResolver.
 */
public void setNamespaceResolver(NamespaceResolver namespaceResolver) {
  staticContext.setNamespaceResolver(namespaceResolver);
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * Get the Configuration in use.
 * @return the Saxon configuration
 */
public Configuration getConfiguration() {
  return staticContext.getConfiguration();
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
* Prepare (compile) an XPath expression for subsequent evaluation.
* @param expression The XPath expression to be compiled, supplied as a string.
* @return an XPathExpression object representing the prepared expression
* @throws XPathException if the syntax of the expression is wrong, or if it references namespaces,
* variables, or functions that have not been declared.
*/
public XPathExpression createExpression(String expression) throws XPathException {
  Expression exp = ExpressionTool.make(expression, staticContext, 0, -1, 1, false);
  exp.setContainer(staticContext);
  ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
  visitor.setExecutable(getExecutable());
  exp = visitor.typeCheck(exp, Type.ITEM_TYPE);
  exp = visitor.optimize(exp, Type.ITEM_TYPE);
  SlotManager map = staticContext.getStackFrameMap();
  int numberOfExternalVariables = map.getNumberOfVariables();
  ExpressionTool.allocateSlots(exp, numberOfExternalVariables, map);
  XPathExpression xpe = new XPathExpression(this, exp);
  xpe.setStackFrameMap(map, numberOfExternalVariables);
  return xpe;
}

代码示例来源:origin: org.opengis.cite.saxon/saxon9

/**
 * Get the external namespace resolver, if one has been set using {@link #setNamespaceResolver}
 * @return the namespace resolver supplied by the user if set, or a system-defined namespace resolver
 * otherwise. By default, the {@link IndependentContext} object used as the {@link XPathStaticContext}
 * also acts as the {@link NamespaceResolver}.
 */
public NamespaceResolver getNamespaceResolver() {
  return staticContext.getNamespaceResolver();
}

代码示例来源:origin: org.opengis.cite.saxon/saxon9

/**
 * Get the executable
 * @return the executable. This holds details of function bindings and collations.
 */
public Executable getExecutable() {
  return staticContext.getExecutable();
}

代码示例来源:origin: org.daisy.pipeline/common-utils

public static XPathExpression compileExpression(String expression, Hashtable<String,String> namespaceBindings, Configuration configuration)
    throws XPathException {
  XPathEvaluator xpathEvaluator = new XPathEvaluator(configuration);
  xpathEvaluator.getStaticContext().setNamespaceResolver(new MatchingNamespaceResolver(namespaceBindings));
  return xpathEvaluator.createPattern(expression);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

/**
 * Get the Configuration in use.
 *
 * @return the Saxon configuration
 */
public Configuration getConfiguration() {
  return staticContext.getConfiguration();
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

/**
 * Prepare (compile) an XSLT pattern for subsequent evaluation. The result is an XPathExpression
 * object representing a (pseudo-) expression that when evaluated returns a boolean result: true
 * if the context node matches the pattern, false if it does not.
 *
 * @param pattern the XSLT pattern to be compiled, supplied as a string
 * @return an XPathExpression object representing the pattern, wrapped as an expression
 * @throws XPathException if the syntax of the expression is wrong, or if it references namespaces,
 *                        variables, or functions that have not been declared.
 * @since 9.1
 */
/*@NotNull*/
public XPathExpression createPattern(String pattern) throws XPathException {
  Configuration config = getConfiguration();
  Executable exec = new Executable(config);
  Pattern pat = Pattern.make(pattern, staticContext, new PackageData(config));
  ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
  pat.typeCheck(visitor, config.makeContextItemStaticInfo(Type.NODE_TYPE, true));
  SlotManager map = staticContext.getStackFrameMap();
  int slots = map.getNumberOfVariables();
  slots = pat.allocateSlots(map, slots);
  //PatternSponsor sponsor = new PatternSponsor(pat);
  XPathExpression xpe = new XPathExpression(staticContext, pat, exec);
  xpe.setStackFrameMap(map, slots);
  return xpe;
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * Declare a variable, making it available for use within a subsequently-compiled XPath expression.
 * The variable may subsequently be assigned a value using the method
 * {@link XPathDynamicContext#setVariable(XPathVariable, net.sf.saxon.om.ValueRepresentation)}.
 * Any external variable used in an XPath expression must be declared before the XPath expression
 * is compiled.
 * @param uri The namespace URI of the variable name. Use "" for the null namespace.
 * @param localName The local part of the variable name.
 * @return an object representing the variable
 */
public XPathVariable declareVariable(String uri, String localName) {
  return staticContext.declareVariable(uri, localName);
}

代码示例来源:origin: org.daisy.libs/com.xmlcalabash

public int count(XdmNode doc, RuntimeValue match, boolean deep) {
  count = 0;
  try {
    XPathEvaluator xeval = new XPathEvaluator(saxonConfig);
    NamespaceResolver resolver = new MatchingNamespaceResolver(match.getNamespaceBindings());
    xeval.getStaticContext().setNamespaceResolver(resolver);
    matcher = xeval.createPattern(match.getString());
    traverse(doc, deep);
  } catch (XProcException e) {
    throw e;
  } catch (Exception e) {
    throw new XProcException(e);
  }
  return count;
}

代码示例来源:origin: org.opengis.cite.saxon/saxon9

/**
 * Get the Configuration in use.
 * @return the Saxon configuration
 */
public Configuration getConfiguration() {
  return staticContext.getConfiguration();
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com