本文整理汇总了Java中org.apache.xml.dtm.DTM.getNodeName方法的典型用法代码示例。如果您正苦于以下问题:Java DTM.getNodeName方法的具体用法?Java DTM.getNodeName怎么用?Java DTM.getNodeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xml.dtm.DTM
的用法示例。
在下文中一共展示了DTM.getNodeName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPath
import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
public static String getPath(DTM dtm, int node) {
String pre;
switch (dtm.getNodeType(node)) {
case Node.DOCUMENT_NODE:
return "/";
case Node.ELEMENT_NODE:
pre = getPath(dtm, dtm.getParent(node));
return (pre.equals("/") ? "" : pre) +
"/" + dtm.getNodeName(node) + "[" + getNumberSimple(dtm, node) + "]";
case Node.ATTRIBUTE_NODE:
return getPath(dtm, dtm.getParent(node)) + "/@" + dtm.getNodeNameX(node);
case Node.TEXT_NODE:
pre = getPath(dtm, dtm.getParent(node));
return (pre.equals("/") ? "" : pre) +
"/text()[" + getNumberSimple(dtm, node) + "]";
case Node.COMMENT_NODE:
pre = getPath(dtm, dtm.getParent(node));
return (pre.equals("/") ? "" : pre) +
"/comment()[" + getNumberSimple(dtm, node) + "]";
case Node.PROCESSING_INSTRUCTION_NODE:
pre = getPath(dtm, dtm.getParent(node));
return (pre.equals("/") ? "" : pre) +
"/processing-instruction()[" + getNumberSimple(dtm, node) + "]";
}
return "?";
}
示例2: nodeToString
import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
* Diagnostics.
*
* @param n Node to give diagnostic information about, or null.
*
* @return Informative string about the argument.
*/
protected String nodeToString(int n)
{
if(DTM.NULL != n)
{
DTM dtm = m_lpi.getXPathContext().getDTM(n);
return dtm.getNodeName(n) + "{" + (n+1) + "}";
}
else
{
return "null";
}
}
示例3: execute
import org.apache.xml.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);
String s;
if(context != DTM.NULL)
{
DTM dtm = xctxt.getDTM(context);
int t = dtm.getNodeType(context);
if(t == DTM.ELEMENT_NODE)
{
s = dtm.getNamespaceURI(context);
}
else if(t == DTM.ATTRIBUTE_NODE)
{
// This function always returns an empty string for namespace nodes.
// We check for those here. Fix inspired by Davanum Srinivas.
s = dtm.getNodeName(context);
if(s.startsWith("xmlns:") || s.equals("xmlns"))
return XString.EMPTYSTRING;
s = dtm.getNamespaceURI(context);
}
else
return XString.EMPTYSTRING;
}
else
return XString.EMPTYSTRING;
return ((null == s) ? XString.EMPTYSTRING : new XString(s));
}