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


Java XPathContext.getNamespaceContext方法代码示例

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


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

示例1: getAttributeBooleanValue

import org.apache.xpath.XPathContext; //导入方法依赖的package包/类
private static final boolean getAttributeBooleanValue(XSLProcessorContext ctx, ElemExtensionCall call, String attr, boolean defaultValue) throws TransformerException {
	Node node = ctx.getContextNode();
	String expr = call.getAttribute(attr);
	if (expr == null || expr.isEmpty())
		return defaultValue;
	XPathContext xpctx = ctx.getTransformer().getXPathContext();
	XPath xp = new XPath(expr, call, xpctx.getNamespaceContext(), XPath.SELECT);
	XObject xobj = xp.execute(xpctx, node, call);
	String value = xobj.str();
	if (value == null)
		return defaultValue;
	if (value.equals("yes"))
		return true;
	if (value.equals("true"))
		return true;
	if (value.equals("no"))
		return false;
	if (value.equals("false"))
		return false;
	return defaultValue;
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:22,代码来源:XMLReader.java

示例2: setRoot

import org.apache.xpath.XPathContext; //导入方法依赖的package包/类
/**
 * Initialize the context values for this expression
 * after it is cloned.
 *
 * @param context The XPath runtime context for this
 * transformation.
 */
public void setRoot(int context, Object environment)
{

  m_context = context;
  
  XPathContext xctxt = (XPathContext)environment;
  m_execContext = xctxt;
  m_cdtm = xctxt.getDTM(context);
  
  m_currentContextNode = context; // only if top level?
  
  // Yech, shouldn't have to do this.  -sb
  if(null == m_prefixResolver)
  	m_prefixResolver = xctxt.getNamespaceContext();
      
  m_lastFetched = DTM.NULL;
  m_foundLast = false;
  m_pos = 0;
  m_length = -1;

  if (m_isTopLevel)
    this.m_stackFrame = xctxt.getVarStack().getStackFrame();
    
  // reset();
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:33,代码来源:LocPathIterator.java

示例3: getAttributeStringValue

import org.apache.xpath.XPathContext; //导入方法依赖的package包/类
private static final String getAttributeStringValue(XSLProcessorContext ctx, ElemExtensionCall call, String exprAttr, String valueAttr) throws TransformerException {
	Node node = ctx.getContextNode();
	String expr = call.getAttribute(exprAttr);
	if (expr == null || expr.isEmpty()) {
		return call.getAttribute(valueAttr);
	}
	XPathContext xpctx = ctx.getTransformer().getXPathContext();
	XPath xp = new XPath(expr, call, xpctx.getNamespaceContext(), XPath.SELECT);
	XObject xobj = xp.execute(xpctx, node, call);
	return xobj.str();
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:12,代码来源:XMLReader.java

示例4: getAttributeIntValue

import org.apache.xpath.XPathContext; //导入方法依赖的package包/类
private static final int getAttributeIntValue(XSLProcessorContext ctx, ElemExtensionCall call, String attr) throws TransformerException {
	Node node = ctx.getContextNode();
	String expr = call.getAttribute(attr);
	XPathContext xpctx = ctx.getTransformer().getXPathContext();
	XPath xp = new XPath(expr, call, xpctx.getNamespaceContext(), XPath.SELECT);
	XObject xobj = xp.execute(xpctx, node, call);
	return (int) xobj.num();
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:9,代码来源:XMLReader.java

示例5: executeFilterExpr

import org.apache.xpath.XPathContext; //导入方法依赖的package包/类
/**
 * Execute the expression.  Meant for reuse by other FilterExpr iterators 
 * that are not derived from this object.
 */
public static XNodeSet executeFilterExpr(int context, XPathContext xctxt, 
												PrefixResolver prefixResolver,
												boolean isTopLevel,
												int stackFrame,
												Expression expr )
  throws org.apache.xml.utils.WrappedRuntimeException
{
  PrefixResolver savedResolver = xctxt.getNamespaceContext();
  XNodeSet result = null;

  try
  {
    xctxt.pushCurrentNode(context);
    xctxt.setNamespaceContext(prefixResolver);

    // The setRoot operation can take place with a reset operation, 
    // and so we may not be in the context of LocPathIterator#nextNode, 
    // so we have to set up the variable context, execute the expression, 
    // and then restore the variable context.

    if (isTopLevel)
    {
      // System.out.println("calling m_expr.execute(getXPathContext())");
      VariableStack vars = xctxt.getVarStack();

      // These three statements need to be combined into one operation.
      int savedStart = vars.getStackFrame();
      vars.setStackFrame(stackFrame);

      result = (org.apache.xpath.objects.XNodeSet) expr.execute(xctxt);
      result.setShouldCacheNodes(true);

      // These two statements need to be combined into one operation.
      vars.setStackFrame(savedStart);
    }
    else
        result = (org.apache.xpath.objects.XNodeSet) expr.execute(xctxt);

  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix...
    throw new org.apache.xml.utils.WrappedRuntimeException(se);
  }
  finally
  {
    xctxt.popCurrentNode();
    xctxt.setNamespaceContext(savedResolver);
  }
  return result;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:57,代码来源:FilterExprIteratorSimple.java


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