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


Java XPathContext.popNamespaceContext方法代码示例

本文整理汇总了Java中org.apache.xpath.XPathContext.popNamespaceContext方法的典型用法代码示例。如果您正苦于以下问题:Java XPathContext.popNamespaceContext方法的具体用法?Java XPathContext.popNamespaceContext怎么用?Java XPathContext.popNamespaceContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.xpath.XPathContext的用法示例。


在下文中一共展示了XPathContext.popNamespaceContext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTemplate

import org.apache.xpath.XPathContext; //导入方法依赖的package包/类
/**
 * Given a target element, find the template that best
 * matches in the given XSL document, according
 * to the rules specified in the xsl draft.
 *
 * @param xctxt
 * @param targetNode
 * @param mode A string indicating the display mode.
 * @param maxImportLevel The maximum importCountComposed that we should consider or -1
 *        if we should consider all import levels.  This is used by apply-imports to
 *        access templates that have been overridden.
 * @param endImportLevel The count of composed imports
 * @param quietConflictWarnings
 * @return Rule that best matches targetElem.
 * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
 * the error condition is severe enough to halt processing.
 *
 * @throws TransformerException
 */
public ElemTemplate getTemplate(XPathContext xctxt,
                              int targetNode,
                              QName mode,
                              int maxImportLevel, int endImportLevel,
                              boolean quietConflictWarnings,
                              DTM dtm)
          throws TransformerException
{

  TemplateSubPatternAssociation head = getHead(xctxt, targetNode, dtm);

  if (null != head)
  {
    // XSLT functions, such as xsl:key, need to be able to get to 
    // current ElemTemplateElement via a cast to the prefix resolver.
    // Setting this fixes bug idkey03.
    xctxt.pushNamespaceContextNull();
    xctxt.pushCurrentNodeAndExpression(targetNode, targetNode);
    try
    {
      do
      {
        if ( (maxImportLevel > -1) && (head.getImportLevel() > maxImportLevel))
        {
          continue;
        }
        if (head.getImportLevel()<= maxImportLevel - endImportLevel)
          return null;
        ElemTemplate template = head.getTemplate();        
        xctxt.setNamespaceContext(template);
        
        if ((head.m_stepPattern.execute(xctxt, targetNode) != NodeTest.SCORE_NONE)
                && head.matchMode(mode))
        {
          if (quietConflictWarnings)
            checkConflicts(head, xctxt, targetNode, mode);

          return template;
        }
      }
      while (null != (head = head.getNext()));
    }
    finally
    {
      xctxt.popCurrentNodeAndExpression();
      xctxt.popNamespaceContext();
    }
  }

  return null;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:71,代码来源:TemplateList.java

示例2: execute

import org.apache.xpath.XPathContext; //导入方法依赖的package包/类
/**
 * Execute the string expression and copy the text to the
 * result tree.
 * The required select attribute is an expression; this expression
 * is evaluated and the resulting object is converted to a string
 * as if by a call to the string function. The string specifies
 * the string-value of the created text node. If the string is
 * empty, no text node will be created. The created text node will
 * be merged with any adjacent text nodes.
 * @see <a href="http://www.w3.org/TR/xslt#value-of">value-of in XSLT Specification</a>
 *
 * @param transformer non-null reference to the the current transform-time state.
 *
 * @throws TransformerException
 */
public void execute(TransformerImpl transformer) throws TransformerException
{

  XPathContext xctxt = transformer.getXPathContext();
  SerializationHandler rth = transformer.getResultTreeHandler();

  try
  {
    // Optimize for "."
      xctxt.pushNamespaceContext(this);

      int current = xctxt.getCurrentNode();

      xctxt.pushCurrentNodeAndExpression(current, current);

      if (m_disableOutputEscaping)
        rth.processingInstruction(
          javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");

      try
      {
        Expression expr = m_selectExpression.getExpression();

          expr.executeCharsToContentHandler(xctxt, rth);
      }
      finally
      {
        if (m_disableOutputEscaping)
          rth.processingInstruction(
            javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");

        xctxt.popNamespaceContext();
        xctxt.popCurrentNodeAndExpression();
      }
  }
  catch (SAXException se)
  {
    throw new TransformerException(se);
  }
  catch (RuntimeException re) {
  	TransformerException te = new TransformerException(re);
  	te.setLocator(this);
  	throw te;
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:61,代码来源:ElemValueOf.java


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