com.sun.org.apache.xpath.internal.XPath类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(157)

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

XPath介绍

[英]The XPath class wraps an expression object and provides general services for execution of that expression.
[中]XPath类包装一个表达式对象,并为该表达式的执行提供一般服务。

代码示例

代码示例来源:origin: org.freemarker/freemarker

XPath xpath = new XPath(xpathQuery, null, customPrefixResolver, XPath.SELECT, null);
int ctxtNode = xpathContext.getDTMHandleFromNode(node);
XObject xresult = xpath.execute(xpathContext, ctxtNode, customPrefixResolver);
if (xresult instanceof XNodeSet) {
  NodeListModel result = new NodeListModel(node);

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

/**
 * Construct an XPath object.
 *
 * @param expr The Expression object.
 *
 * @throws javax.xml.transform.TransformerException if syntax or other error.
 */
public XPath(Expression expr)
{  
 this.setExpression(expr);
 initFunctionTable();   
}

代码示例来源:origin: io.snappydata/gemfirexd-core

query = new XPath(queryExpr, null, new PrefixResolverDefault(
  dBuilder.newDocument()), XPath.SELECT);

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

/**
 * Given an expression and a context, evaluate the XPath
 * and return the result.
 * 
 * @param xctxt The execution context.
 * @param contextNode The node that "." expresses.
 * @param namespaceContext The context in which namespaces in the
 * XPath are supposed to be expanded.
 *
 * @return The result of the XPath or null if callbacks are used.
 * @throws TransformerException thrown if
 * the error condition is severe enough to halt processing.
 *
 * @throws javax.xml.transform.TransformerException
 * @xsl.usage experimental
 */
public XObject execute(
    XPathContext xctxt, org.w3c.dom.Node contextNode, 
    PrefixResolver namespaceContext)
     throws javax.xml.transform.TransformerException
{
 return execute(
    xctxt, xctxt.getDTMHandleFromNode(contextNode), 
    namespaceContext);
}

代码示例来源:origin: io.snappydata/gemfirexd-core

SanityManager.ASSERT((query != null) && (query.getExpression() != null),
   "Failed to locate compiled XML query expression.");
XObject xOb = query.execute(xpContext, docNode, null);

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

/**
   * The number of nodes in the result snapshot. Valid values for 
   * snapshotItem indices are <code>0</code> to 
   * <code>snapshotLength-1</code> inclusive.
   * @exception XPathException
   *   TYPE_ERR: raised if <code>resultType</code> is not 
   *   <code>UNORDERED_NODE_SNAPSHOT_TYPE</code> or 
   *   <code>ORDERED_NODE_SNAPSHOT_TYPE</code>.
   * 
   * @see org.w3c.dom.xpath.XPathResult#getSnapshotLength()
   */
  public int getSnapshotLength() throws XPathException {
  
    if ((m_resultType != UNORDERED_NODE_SNAPSHOT_TYPE) &&
      (m_resultType != ORDERED_NODE_SNAPSHOT_TYPE)) {
        String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_GET_SNAPSHOT_LENGTH, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});                        
        throw new XPathException(XPathException.TYPE_ERR,fmsg); 
//                "The method getSnapshotLength cannot be called on the XPathResult of XPath expression {0} because its XPathResultType is {1}.
    }
      
    return m_list.getLength();
  }

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

te.setLocator(this.getLocator());
ErrorListener el = xctxt.getErrorListener();
if(null != el) // defensive, should never happen.
    getLocator(), e);
ErrorListener el = xctxt.getErrorListener();

代码示例来源:origin: io.snappydata/gemfirexd

query = new XPath(queryExpr, null, new PrefixResolverDefault(
  dBuilder.newDocument()), XPath.SELECT);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

/**
 * Given an expression and a context, evaluate the XPath
 * and return the result.
 * 
 * @param xctxt The execution context.
 * @param contextNode The node that "." expresses.
 * @param namespaceContext The context in which namespaces in the
 * XPath are supposed to be expanded.
 *
 * @return The result of the XPath or null if callbacks are used.
 * @throws TransformerException thrown if
 * the error condition is severe enough to halt processing.
 *
 * @throws javax.xml.transform.TransformerException
 * @xsl.usage experimental
 */
public XObject execute(
    XPathContext xctxt, org.w3c.dom.Node contextNode, 
    PrefixResolver namespaceContext)
     throws javax.xml.transform.TransformerException
{
 return execute(
    xctxt, xctxt.getDTMHandleFromNode(contextNode), 
    namespaceContext);
}

代码示例来源:origin: io.snappydata/snappydata-store-core

SanityManager.ASSERT((query != null) && (query.getExpression() != null),
   "Failed to locate compiled XML query expression.");
XObject xOb = query.execute(xpContext, docNode, null);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

/**
   * The number of nodes in the result snapshot. Valid values for 
   * snapshotItem indices are <code>0</code> to 
   * <code>snapshotLength-1</code> inclusive.
   * @exception XPathException
   *   TYPE_ERR: raised if <code>resultType</code> is not 
   *   <code>UNORDERED_NODE_SNAPSHOT_TYPE</code> or 
   *   <code>ORDERED_NODE_SNAPSHOT_TYPE</code>.
   * 
   * @see org.w3c.dom.xpath.XPathResult#getSnapshotLength()
   */
  public int getSnapshotLength() throws XPathException {
  
    if ((m_resultType != UNORDERED_NODE_SNAPSHOT_TYPE) &&
      (m_resultType != ORDERED_NODE_SNAPSHOT_TYPE)) {
        String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_GET_SNAPSHOT_LENGTH, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});                        
        throw new XPathException(XPathException.TYPE_ERR,fmsg); 
//                "The method getSnapshotLength cannot be called on the XPathResult of XPath expression {0} because its XPathResultType is {1}.
    }
      
    return m_list.getLength();
  }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

te.setLocator(this.getLocator());
ErrorListener el = xctxt.getErrorListener();
if(null != el) // defensive, should never happen.
    getLocator(), e);
ErrorListener el = xctxt.getErrorListener();

代码示例来源:origin: org.glassfish.web/jstl-impl

private XObject eval(String expression, Object contextItem)
  throws javax.xml.transform.TransformerException {
  com.sun.org.apache.xpath.internal.XPath xpath = new com.sun.org.apache.xpath.internal.XPath( expression,
    null, prefixResolver, com.sun.org.apache.xpath.internal.XPath.SELECT ); 
  com.sun.org.apache.xpath.internal.XPathContext xpathSupport = null;
  if ( functionResolver != null ) {
    com.sun.org.apache.xpath.internal.jaxp.JAXPExtensionsProvider jep = 
        new com.sun.org.apache.xpath.internal.jaxp.JAXPExtensionsProvider(
        functionResolver, featureSecureProcessing );
    xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext( jep );
  } else { 
    xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext();
  }
  XObject xobj = null;
  
  xpathSupport.setVarStack(new com.sun.org.apache.xpath.internal.jaxp.JAXPVariableStack(variableResolver));
  
  // If item is null, then we will create a a Dummy contextNode
  if ( contextItem instanceof Node ) {
    xobj = xpath.execute (xpathSupport, (Node)contextItem,
        prefixResolver );
  } else {
    xobj = xpath.execute ( xpathSupport, DTM.NULL, prefixResolver );
  }
  return xobj;
}

代码示例来源:origin: io.snappydata/snappydata-store-core

query = new XPath(queryExpr, null, new PrefixResolverDefault(
  dBuilder.newDocument()), XPath.SELECT);

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

private XObject eval ( Object contextItem )
    throws javax.xml.transform.TransformerException {
  com.sun.org.apache.xpath.internal.XPathContext xpathSupport = null;
  if ( functionResolver != null ) {
    JAXPExtensionsProvider jep = new JAXPExtensionsProvider(
        functionResolver, featureSecureProcessing );
    xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext( jep );
  } else {
    xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext();
  }
  xpathSupport.setVarStack(new JAXPVariableStack(variableResolver));
  XObject xobj = null;
   
  Node contextNode = (Node)contextItem;
  // We always need to have a ContextNode with Xalan XPath implementation
  // To allow simple expression evaluation like 1+1 we are setting 
  // dummy Document as Context Node
  
  if ( contextNode == null ) 
    xobj = xpath.execute(xpathSupport, DTM.NULL, prefixResolver);
  else
    xobj = xpath.execute(xpathSupport, contextNode, prefixResolver); 
  
  return xobj;
}

代码示例来源:origin: io.snappydata/gemfirexd

SanityManager.ASSERT((query != null) && (query.getExpression() != null),
   "Failed to locate compiled XML query expression.");
XObject xOb = query.execute(xpContext, docNode, null);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

/**
 * Construct an XPath object.
 *
 * @param expr The Expression object.
 *
 * @throws javax.xml.transform.TransformerException if syntax or other error.
 */
public XPath(Expression expr)
{  
 this.setExpression(expr);
 initFunctionTable();   
}

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

/**
   * @see org.w3c.dom.xpath.XPathResult#getBooleanValue()
   */
  public boolean getBooleanValue() throws XPathException {
    if (getResultType() != BOOLEAN_TYPE) {
      String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_BOOLEAN, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});		
      throw new XPathException(XPathException.TYPE_ERR,fmsg);
//        "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a boolean."            
    } else {
      try {
        return m_resultObj.bool();
      } catch (TransformerException e) {
        // Type check above should prevent this exception from occurring.
        throw new XPathException(XPathException.TYPE_ERR,e.getMessage());
      }
    }
  }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

te.setLocator(this.getLocator());
ErrorListener el = xctxt.getErrorListener();
if(null != el) // defensive, should never happen.
    getLocator(), e);
ErrorListener el = xctxt.getErrorListener();

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

private XObject eval(String expression, Object contextItem)
  throws javax.xml.transform.TransformerException {
  com.sun.org.apache.xpath.internal.XPath xpath = new com.sun.org.apache.xpath.internal.XPath( expression,
    null, prefixResolver, com.sun.org.apache.xpath.internal.XPath.SELECT ); 
  com.sun.org.apache.xpath.internal.XPathContext xpathSupport = null;
  if ( functionResolver != null ) {
    JAXPExtensionsProvider jep = new JAXPExtensionsProvider(
        functionResolver, featureSecureProcessing );
    xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext( jep );
  } else { 
    xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext();
  }
  XObject xobj = null;
  
  xpathSupport.setVarStack(new JAXPVariableStack(variableResolver));
  
  // If item is null, then we will create a a Dummy contextNode
  if ( contextItem instanceof Node ) {
    xobj = xpath.execute (xpathSupport, (Node)contextItem,
        prefixResolver );
  } else {
    xobj = xpath.execute ( xpathSupport, DTM.NULL, prefixResolver );
  }
  return xobj;
}

相关文章