本文整理汇总了Java中com.sun.org.apache.xml.internal.dtm.DTM.getLocalName方法的典型用法代码示例。如果您正苦于以下问题:Java DTM.getLocalName方法的具体用法?Java DTM.getLocalName怎么用?Java DTM.getLocalName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xml.internal.dtm.DTM
的用法示例。
在下文中一共展示了DTM.getLocalName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.sun.org.apache.xml.internal.dtm.DTM; //导入方法依赖的package包/类
/**
* Execute the function. The function must return
* a valid object.
* @param xctxt The current execution context.
* @return A valid XObject.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
{
int context = getArg0AsNode(xctxt);
if(DTM.NULL == context)
return XString.EMPTYSTRING;
DTM dtm = xctxt.getDTM(context);
String s = (context != DTM.NULL) ? dtm.getLocalName(context) : "";
if(s.startsWith("#") || s.equals("xmlns"))
return XString.EMPTYSTRING;
return new XString(s);
}
示例2: execute
import com.sun.org.apache.xml.internal.dtm.DTM; //导入方法依赖的package包/类
/**
* Tell what the test score is for the given node.
*
*
* @param xctxt XPath runtime context.
* @param context The node being tested.
*
* @return {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST},
* {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE},
* {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD},
* {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME}, or
* {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER}.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt, int context)
throws javax.xml.transform.TransformerException
{
DTM dtm = xctxt.getDTM(context);
short nodeType = dtm.getNodeType(context);
if (m_whatToShow == DTMFilter.SHOW_ALL)
return m_score;
int nodeBit = (m_whatToShow & (0x00000001 << (nodeType - 1)));
switch (nodeBit)
{
case DTMFilter.SHOW_DOCUMENT_FRAGMENT :
case DTMFilter.SHOW_DOCUMENT :
return SCORE_OTHER;
case DTMFilter.SHOW_COMMENT :
return m_score;
case DTMFilter.SHOW_CDATA_SECTION :
case DTMFilter.SHOW_TEXT :
// was:
// return (!xctxt.getDOMHelper().shouldStripSourceNode(context))
// ? m_score : SCORE_NONE;
return m_score;
case DTMFilter.SHOW_PROCESSING_INSTRUCTION :
return subPartMatch(dtm.getNodeName(context), m_name)
? m_score : SCORE_NONE;
// From the draft: "Two expanded names are equal if they
// have the same local part, and either both have no URI or
// both have the same URI."
// "A node test * is true for any node of the principal node type.
// For example, child::* will select all element children of the
// context node, and attribute::* will select all attributes of
// the context node."
// "A node test can have the form NCName:*. In this case, the prefix
// is expanded in the same way as with a QName using the context
// namespace declarations. The node test will be true for any node
// of the principal type whose expanded name has the URI to which
// the prefix expands, regardless of the local part of the name."
case DTMFilter.SHOW_NAMESPACE :
{
String ns = dtm.getLocalName(context);
return (subPartMatch(ns, m_name)) ? m_score : SCORE_NONE;
}
case DTMFilter.SHOW_ATTRIBUTE :
case DTMFilter.SHOW_ELEMENT :
{
return (m_isTotallyWild || (subPartMatchNS(dtm.getNamespaceURI(context), m_namespace) && subPartMatch(dtm.getLocalName(context), m_name)))
? m_score : SCORE_NONE;
}
default :
return SCORE_NONE;
} // end switch(testType)
}