当前位置: 首页>>代码示例>>Java>>正文


Java PrefixResolverDefault类代码示例

本文整理汇总了Java中com.sun.org.apache.xml.internal.utils.PrefixResolverDefault的典型用法代码示例。如果您正苦于以下问题:Java PrefixResolverDefault类的具体用法?Java PrefixResolverDefault怎么用?Java PrefixResolverDefault使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PrefixResolverDefault类属于com.sun.org.apache.xml.internal.utils包,在下文中一共展示了PrefixResolverDefault类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: eval

import com.sun.org.apache.xml.internal.utils.PrefixResolverDefault; //导入依赖的package包/类
/**
 *  Evaluate XPath string to an XObject.
 *  XPath namespace prefixes are resolved from the namespaceNode.
 *  The implementation of this is a little slow, since it creates
 *  a number of objects each time it is called.  This could be optimized
 *  to keep the same objects around, but then thread-safety issues would arise.
 *
 *  @param contextNode The node to start searching from.
 *  @param str A valid XPath string.
 *  @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces.
 *  @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null.
 *  @see com.sun.org.apache.xpath.internal.objects.XObject
 *  @see com.sun.org.apache.xpath.internal.objects.XNull
 *  @see com.sun.org.apache.xpath.internal.objects.XBoolean
 *  @see com.sun.org.apache.xpath.internal.objects.XNumber
 *  @see com.sun.org.apache.xpath.internal.objects.XString
 *  @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag
 *
 * @throws TransformerException
 */
public static XObject eval(Node contextNode, String str, Node namespaceNode)
        throws TransformerException
{

  // Since we don't have a XML Parser involved here, install some default support
  // for things like namespaces, etc.
  // (Changed from: XPathContext xpathSupport = new XPathContext();
  //    because XPathContext is weak in a number of areas... perhaps
  //    XPathContext should be done away with.)
  XPathContext xpathSupport = new XPathContext();

  // Create an object to resolve namespace prefixes.
  // XPath namespaces are resolved from the input context node's document element
  // if it is a root node, or else the current context node (for lack of a better
  // resolution space, given the simplicity of this sample code).
  PrefixResolverDefault prefixResolver = new PrefixResolverDefault(
    (namespaceNode.getNodeType() == Node.DOCUMENT_NODE)
    ? ((Document) namespaceNode).getDocumentElement() : namespaceNode);

  // Create the XPath object.
  XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null);

  // Execute the XPath, and have it return the result
  // return xpath.execute(xpathSupport, contextNode, prefixResolver);
  int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode);

  return xpath.execute(xpathSupport, ctxtNode, prefixResolver);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:49,代码来源:XPathAPI.java

示例2: eval

import com.sun.org.apache.xml.internal.utils.PrefixResolverDefault; //导入依赖的package包/类
/**
 *  Evaluate XPath string to an XObject.
 *  XPath namespace prefixes are resolved from the namespaceNode.
 *  The implementation of this is a little slow, since it creates
 *  a number of objects each time it is called.  This could be optimized
 *  to keep the same objects around, but then thread-safety issues would arise.
 *
 *  @param contextNode The node to start searching from.
 *  @param str A valid XPath string.
 *  @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces.
 *  @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null.
 *  @see com.sun.org.apache.xpath.internal.objects.XObject
 *  @see com.sun.org.apache.xpath.internal.objects.XNull
 *  @see com.sun.org.apache.xpath.internal.objects.XBoolean
 *  @see com.sun.org.apache.xpath.internal.objects.XNumber
 *  @see com.sun.org.apache.xpath.internal.objects.XString
 *  @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag
 *
 * @throws TransformerException
 */
public  XObject eval(Node contextNode, String str, Node namespaceNode)
        throws TransformerException
{

  // Since we don't have a XML Parser involved here, install some default support
  // for things like namespaces, etc.
  // (Changed from: XPathContext xpathSupport = new XPathContext();
  //    because XPathContext is weak in a number of areas... perhaps
  //    XPathContext should be done away with.)

  // Create an object to resolve namespace prefixes.
  // XPath namespaces are resolved from the input context node's document element
  // if it is a root node, or else the current context node (for lack of a better
  // resolution space, given the simplicity of this sample code).
  PrefixResolverDefault prefixResolver = new PrefixResolverDefault(
    (namespaceNode.getNodeType() == Node.DOCUMENT_NODE)
    ? ((Document) namespaceNode).getDocumentElement() : namespaceNode);

  // Create the XPath object.
  XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null);

  // Execute the XPath, and have it return the result
  // return xpath.execute(xpathSupport, contextNode, prefixResolver);
  int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode);

  return xpath.execute(xpathSupport, ctxtNode, prefixResolver);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:48,代码来源:CachedXPathAPI.java

示例3: eval

import com.sun.org.apache.xml.internal.utils.PrefixResolverDefault; //导入依赖的package包/类
private XObject eval(Node contextNode, Node xpathnode, String str, Node namespaceNode)
    throws TransformerException {
    if (context == null) {
        context = new XPathContext(xpathnode);
        context.setSecureProcessing(true);
    }

    // Create an object to resolve namespace prefixes.
    // XPath namespaces are resolved from the input context node's document element
    // if it is a root node, or else the current context node (for lack of a better
    // resolution space, given the simplicity of this sample code).
    Node resolverNode =
        (namespaceNode.getNodeType() == Node.DOCUMENT_NODE)
            ? ((Document) namespaceNode).getDocumentElement() : namespaceNode;
    PrefixResolverDefault prefixResolver = new PrefixResolverDefault(resolverNode);

    if (!str.equals(xpathStr)) {
        if (str.indexOf("here()") > 0) {
            context.reset();
        }
        xpath = createXPath(str, prefixResolver);
        xpathStr = str;
    }

    // Execute the XPath, and have it return the result
    int ctxtNode = context.getDTMHandleFromNode(contextNode);

    return xpath.execute(context, ctxtNode, prefixResolver);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:30,代码来源:XalanXPathAPI.java

示例4: compileXQExpr

import com.sun.org.apache.xml.internal.utils.PrefixResolverDefault; //导入依赖的package包/类
/**
 * Take the received string, which is an XML query expression, compile it, and
 * store the compiled query locally. Note that for now, we only support XPath
 * because that's what Xalan supports.
 * 
 * @param queryExpr
 *          The XPath expression to compile
 */
public void compileXQExpr(final String queryExpr, final String opName,
    final DocumentBuilder dBuilder) throws StandardException {
  try {

    /* The following XPath constructor compiles the expression
     * as part of the construction process.  We have to pass
     * in a PrefixResolver object in order to avoid NPEs when
     * invalid/unknown functions are used, so we just create
     * a dummy one, which means prefixes will not be resolved
     * in the query (Xalan will just throw an error if a prefix
     * is used).  In the future we may want to revisit this
     * to make it easier for users to query based on namespaces.
     */
    query = new XPath(queryExpr, null, new PrefixResolverDefault(
        dBuilder.newDocument()), XPath.SELECT);

  } catch (Throwable te) {

    /* Something went wrong during compilation of the
     * expression; wrap the error and re-throw it.
     * Note: we catch "Throwable" here to catch as many
     * Xalan-produced errors as possible in order to
     * minimize the chance of an uncaught Xalan error
     * (such as a NullPointerException) causing Derby
     * to fail in a more serious way.  In particular, an
     * uncaught Java exception like NPE can result in
     * Derby throwing "ERROR 40XT0: An internal error was
     * identified by RawStore module" for all statements on
     * the connection after the failure--which we clearly
     * don't want.  If we catch the error and wrap it,
     * though, the statement will fail but Derby will
     * continue to run as normal. 
     */
    throw StandardException.newException(SQLState.LANG_XML_QUERY_ERROR, te,
        opName, te.getMessage());

  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:47,代码来源:SqlXmlHelperSun5.java

示例5: XPathExecutor

import com.sun.org.apache.xml.internal.utils.PrefixResolverDefault; //导入依赖的package包/类
/**
 * Creates a new instance of XPathExecutor.
 * 
 * @param context the document containing the context being queried.
 * @param namespaces the document containing the namespaces being referenced.
 */
public XPathExecutor(Node context, Node namespaces) {
    this.contextNode = context==null? createDocument() : context;
    this.namespaceNode = namespaces==null? contextNode : namespaces;
    this.functionsProvider = new XPathFunctionsProvider();
    this.xpathSupport = new XPathContext(functionsProvider);
    this.prefixResolver = new PrefixResolverDefault(
            (namespaceNode.getNodeType() == Node.DOCUMENT_NODE) ? 
                    ((org.w3c.dom.Document) namespaceNode)
                    .getDocumentElement() : namespaceNode);
}
 
开发者ID:cecid,项目名称:hermes,代码行数:17,代码来源:XPathExecutor.java

示例6: eval

import com.sun.org.apache.xml.internal.utils.PrefixResolverDefault; //导入依赖的package包/类
/**
 *  Evaluate XPath string to an XObject.
 *  XPath namespace prefixes are resolved from the namespaceNode.
 *  The implementation of this is a little slow, since it creates
 *  a number of objects each time it is called.  This could be optimized
 *  to keep the same objects around, but then thread-safety issues would arise.
 *
 *  @param contextNode The node to start searching from.
 * @param xpathnode
 *  @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces.
 *  @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null.
 *  @see com.sun.org.apache.xpath.internal.objects.XObject
 *  @see com.sun.org.apache.xpath.internal.objects.XNull
 *  @see com.sun.org.apache.xpath.internal.objects.XBoolean
 *  @see com.sun.org.apache.xpath.internal.objects.XNumber
 *  @see com.sun.org.apache.xpath.internal.objects.XString
 *  @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag
 *
 * @throws TransformerException
 */
public static XObject eval(
        Node contextNode, Node xpathnode, Node namespaceNode)
           throws TransformerException {

   // Since we don't have a XML Parser involved here, install some default support
   // for things like namespaces, etc.
   // (Changed from: XPathContext xpathSupport = new XPathContext();
   //    because XPathContext is weak in a number of areas... perhaps
   //    XPathContext should be done away with.)
   FuncHereContext xpathSupport = new FuncHereContext(xpathnode);

   // Create an object to resolve namespace prefixes.
   // XPath namespaces are resolved from the input context node's document element
   // if it is a root node, or else the current context node (for lack of a better
   // resolution space, given the simplicity of this sample code).
   PrefixResolverDefault prefixResolver =
      new PrefixResolverDefault((namespaceNode.getNodeType()
                                 == Node.DOCUMENT_NODE)
                                ? ((Document) namespaceNode)
                                   .getDocumentElement()
                                : namespaceNode);
   String str = getStrFromNode(xpathnode);

   // Create the XPath object.
   XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null);

   // Execute the XPath, and have it return the result
   // return xpath.execute(xpathSupport, contextNode, prefixResolver);
   int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode);

   return xpath.execute(xpathSupport, ctxtNode, prefixResolver);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:53,代码来源:XPathFuncHereAPI.java

示例7: ResolverContext

import com.sun.org.apache.xml.internal.utils.PrefixResolverDefault; //导入依赖的package包/类
public ResolverContext(Node xPathExpressionContext) {
    resolver = new PrefixResolverDefault(xPathExpressionContext);
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:4,代码来源:ResolverContext.java

示例8: XPathNodeFilter

import com.sun.org.apache.xml.internal.utils.PrefixResolverDefault; //导入依赖的package包/类
XPathNodeFilter(Element xpathElement,
                Node xpathnode, String str) {
    this.xpathnode=xpathnode;
    this.str=str;
    prefixResolver =new PrefixResolverDefault(xpathElement);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:7,代码来源:TransformXPath.java

示例9: eval

import com.sun.org.apache.xml.internal.utils.PrefixResolverDefault; //导入依赖的package包/类
/**
 *  Evaluate XPath string to an XObject.
 *  XPath namespace prefixes are resolved from the namespaceNode.
 *  The implementation of this is a little slow, since it creates
 *  a number of objects each time it is called.  This could be optimized
 *  to keep the same objects around, but then thread-safety issues would arise.
 *
 *  @param contextNode The node to start searching from.
 * @param xpathnode
 * @param str
 *  @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces.
 *  @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null.
 *  @see com.sun.org.apache.xpath.internal.objects.XObject
 *  @see com.sun.org.apache.xpath.internal.objects.XNull
 *  @see com.sun.org.apache.xpath.internal.objects.XBoolean
 *  @see com.sun.org.apache.xpath.internal.objects.XNumber
 *  @see com.sun.org.apache.xpath.internal.objects.XString
 *  @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag
 *
 * @throws TransformerException
 */
public XObject eval(Node contextNode, Node xpathnode, String str, Node namespaceNode)
        throws TransformerException {
   //  Create the XPath object.
   //String str = CachedXPathFuncHereAPI.getStrFromNode(xpathnode);

   // Since we don't have a XML Parser involved here, install some default support
   // for things like namespaces, etc.
   // (Changed from: XPathContext xpathSupport = new XPathContext();
   //    because XPathContext is weak in a number of areas... perhaps
   //    XPathContext should be done away with.)
   if (this._funcHereContext == null) {
      this._funcHereContext = new FuncHereContext(xpathnode,
                                                  this._dtmManager);
   }

   // Create an object to resolve namespace prefixes.
   // XPath namespaces are resolved from the input context node's document element
   // if it is a root node, or else the current context node (for lack of a better
   // resolution space, given the simplicity of this sample code).
   PrefixResolverDefault prefixResolver =
      new PrefixResolverDefault((namespaceNode.getNodeType()
                                 == Node.DOCUMENT_NODE)
                                ? ((Document) namespaceNode)
                                   .getDocumentElement()
                                : namespaceNode);

   // only check if string points to different object (for performance)
   if (str!=xpathStr) {
     if (str.indexOf("here()")>0) {
         _context.reset();
         _dtmManager=_context.getDTMManager();
     }
     xpath = createXPath(str, prefixResolver);
     xpathStr=str;
   }

   // Execute the XPath, and have it return the result
   // return xpath.execute(xpathSupport, contextNode, prefixResolver);
   int ctxtNode = this._funcHereContext.getDTMHandleFromNode(contextNode);

   return xpath.execute(this._funcHereContext, ctxtNode, prefixResolver);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:64,代码来源:CachedXPathFuncHereAPI.java


注:本文中的com.sun.org.apache.xml.internal.utils.PrefixResolverDefault类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。