gpt4 book ai didi

net.sf.saxon.sxpath.XPathVariable.setRequiredType()方法的使用及代码示例

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

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

XPathVariable.setRequiredType介绍

[英]Set the required type of this variable. If no required type is specified, the type item()* is assumed.
[中]设置此变量所需的类型。如果未指定所需类型,则假定类型为item()*

代码示例

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

/**
 * Declare a variable as part of the static context for XPath expressions compiled using this
 * {@code XPathCompiler}. It is an error for the XPath expression to refer to a variable unless it has been
 * declared, unless the method {@link #setAllowUndeclaredVariables(boolean)} has been called to permit
 * undeclared variables. This method declares the existence of the variable, and defines the required type
 * of the variable, but it does not bind any value to the variable; that is done later,
 * when the XPath expression is evaluated.
 *
 * @param qname       The name of the variable, expressed as a {@link QName}
 * @param itemType    The required item type of the value of the variable, for example {@code ItemType.BOOLEAN}
 * @param occurrences The allowed number of items in the sequence forming the value of the variable
 */
public void declareVariable(QName qname, ItemType itemType, OccurrenceIndicator occurrences) {
  if (cache != null) {
    cache.clear();
  }
  XPathVariable var = env.declareVariable(qname.getNamespaceURI(), qname.getLocalName());
  var.setRequiredType(
      SequenceType.makeSequenceType(
          itemType.getUnderlyingItemType(), occurrences.getCardinality()));
}

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

/**
 * Declare a variable as part of the static context for XPath expressions compiled using this
 * {@code XPathCompiler}. It is an error for the XPath expression to refer to a variable unless it has been
 * declared, unless the method {@link #setAllowUndeclaredVariables(boolean)} has been called to permit
 * undeclared variables. This method declares the existence of the variable, and defines the required type
 * of the variable, but it does not bind any value to the variable; that is done later,
 * when the XPath expression is evaluated.
 *
 * @param qname       The name of the variable, expressed as a {@link QName}
 * @param itemType    The required item type of the value of the variable, for example {@code ItemType.BOOLEAN}
 * @param occurrences The allowed number of items in the sequence forming the value of the variable
 */
public void declareVariable(QName qname, ItemType itemType, OccurrenceIndicator occurrences) {
  if (cache != null) {
    cache.clear();
  }
  XPathVariable var = env.declareVariable(qname.getNamespaceURI(), qname.getLocalName());
  var.setRequiredType(
      SequenceType.makeSequenceType(
          itemType.getUnderlyingItemType(), occurrences.getCardinality()));
}

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

/**
   * Declare a variable as part of the static context for XPath expressions compiled using this
   * XPathCompiler. It is an error for the XPath expression to refer to a variable unless it has been
   * declared. This method declares the existence of the variable, and defines the required type
   * of the variable, but it does not bind any value to the variable; that is done later,
   * when the XPath expression is evaluated.
   *
   * @param qname The name of the variable, expressed as a QName
   * @param itemType The required item type of the value of the variable
   * @param occurrences The allowed number of items in the sequence forming the value of the variable
   * @throws SaxonApiException if the requiredType is syntactically invalid or if it refers to namespace
   * prefixes or schema components that are not present in the static context
   */

  public void declareVariable(QName qname, ItemType itemType, OccurrenceIndicator occurrences) throws SaxonApiException {
//        ExpressionParser parser = new ExpressionParser();
//        SequenceType type;
//        try {
//            type = parser.parseSequenceType(requiredType, env);
//        } catch (XPathException e) {
//            throw new SaxonApiException(e);
//        }
    XPathVariable var = env.declareVariable(qname.getNamespaceURI(), qname.getLocalName());
    var.setRequiredType(
        SequenceType.makeSequenceType(
            itemType.getUnderlyingItemType(), occurrences.getCardinality()));
    declaredVariables.add(var);
  }

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

private XPathExecutable internalCompile(String source) throws SaxonApiException {
  try {
    env.getDecimalFormatManager().checkConsistency();
  } catch (net.sf.saxon.trans.XPathException e) {
    throw new SaxonApiException(e);
  }
  XPathEvaluator eval = evaluator;
  IndependentContext ic = env;
  if (ic.isAllowUndeclaredVariables()) {
    // self-declaring variables modify the static context. The XPathCompiler must not change state
    // as the result of compiling an expression, so we need to copy the static context.
    eval = new XPathEvaluator(processor.getUnderlyingConfiguration());
    ic = new IndependentContext(env);
    eval.setStaticContext(ic);
    for (Iterator iter = env.iterateExternalVariables(); iter.hasNext(); ) {
      XPathVariable var = (XPathVariable) iter.next();
      XPathVariable var2 = ic.declareVariable(var.getVariableQName());
      var2.setRequiredType(var.getRequiredType());
    }
  }
  try {
    XPathExpression cexp = eval.createExpression(source);
    return new XPathExecutable(cexp, processor, ic);
  } catch (XPathException e) {
    throw new SaxonApiException(e);
  }
}

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

private XPathExecutable internalCompile(String source) throws SaxonApiException {
  try {
    env.getDecimalFormatManager().checkConsistency();
  } catch (net.sf.saxon.trans.XPathException e) {
    throw new SaxonApiException(e);
  }
  XPathEvaluator eval = evaluator;
  IndependentContext ic = env;
  if (ic.isAllowUndeclaredVariables()) {
    // self-declaring variables modify the static context. The XPathCompiler must not change state
    // as the result of compiling an expression, so we need to copy the static context.
    eval = new XPathEvaluator(processor.getUnderlyingConfiguration());
    ic = new IndependentContext(env);
    eval.setStaticContext(ic);
    for (Iterator iter = env.iterateExternalVariables(); iter.hasNext(); ) {
      XPathVariable var = (XPathVariable) iter.next();
      XPathVariable var2 = ic.declareVariable(var.getVariableQName());
      var2.setRequiredType(var.getRequiredType());
    }
  }
  try {
    XPathExpression cexp = eval.createExpression(source);
    return new XPathExecutable(cexp, processor, ic);
  } catch (XPathException e) {
    throw new SaxonApiException(e);
  }
}

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