本文整理汇总了Java中org.apache.xml.dtm.DTM.getNamespaceURI方法的典型用法代码示例。如果您正苦于以下问题:Java DTM.getNamespaceURI方法的具体用法?Java DTM.getNamespaceURI怎么用?Java DTM.getNamespaceURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xml.dtm.DTM
的用法示例。
在下文中一共展示了DTM.getNamespaceURI方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNumberSimple
import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
private static int getNumberSimple(DTM dtm, int node) {
final String localName = dtm.getLocalName(node);
String uri = dtm.getNamespaceURI(node);
if (uri == null) uri = "";
final short type = dtm.getNodeType(node);
int i = 1;
int p = node;
while ((p = dtm.getPreviousSibling(p)) != DTM.NULL) {
if (dtm.getNodeType(p) == type) {
switch (type) {
case Node.TEXT_NODE:
case Node.COMMENT_NODE:
case Node.PROCESSING_INSTRUCTION_NODE:
i++;
break;
default:
if (localName.equals(dtm.getLocalName(p)) && uri.equals(dtm.getNamespaceURI(p))) {
i++;
}
}
}
}
return i;
}
示例2: addAttribute
import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
* Copy an DOM attribute to the created output element, executing
* attribute templates as need be, and processing the xsl:use
* attribute.
*
* @param handler SerializationHandler to which the attributes are added.
* @param attr Attribute node to add to SerializationHandler.
*
* @throws TransformerException
*/
public static void addAttribute(SerializationHandler handler, int attr)
throws TransformerException
{
TransformerImpl transformer =
(TransformerImpl) handler.getTransformer();
DTM dtm = transformer.getXPathContext().getDTM(attr);
if (SerializerUtils.isDefinedNSDecl(handler, attr, dtm))
return;
String ns = dtm.getNamespaceURI(attr);
if (ns == null)
ns = "";
// %OPT% ...can I just store the node handle?
try
{
handler.addAttribute(
ns,
dtm.getLocalName(attr),
dtm.getNodeName(attr),
"CDATA",
dtm.getNodeValue(attr), false);
}
catch (SAXException e)
{
// do something?
}
}
示例3: outputResultTreeFragment
import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
* Given a result tree fragment, walk the tree and
* output it to the SerializationHandler.
*
* @param obj Result tree fragment object
* @param support XPath context for the result tree fragment
*
* @throws org.xml.sax.SAXException
*/
public static void outputResultTreeFragment(
SerializationHandler handler,
XObject obj,
XPathContext support)
throws org.xml.sax.SAXException
{
int doc = obj.rtf();
DTM dtm = support.getDTM(doc);
if (null != dtm)
{
for (int n = dtm.getFirstChild(doc);
DTM.NULL != n;
n = dtm.getNextSibling(n))
{
handler.flushPending();
// I think. . . . This used to have a (true) arg
// to flush prefixes, will that cause problems ???
if (dtm.getNodeType(n) == DTM.ELEMENT_NODE
&& dtm.getNamespaceURI(n) == null)
handler.startPrefixMapping("", "");
dtm.dispatchToEvents(n, handler);
}
}
}
示例4: 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));
}
示例5: execute
import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
* The xsl:copy element provides an easy way of copying the current node.
* Executing this function creates a copy of the current node into the
* result tree.
* <p>The namespace nodes of the current node are automatically
* copied as well, but the attributes and children of the node are not
* automatically copied. The content of the xsl:copy element is a
* template for the attributes and children of the created node;
* the content is instantiated only for nodes of types that can have
* attributes or children (i.e. root nodes and element nodes).</p>
* <p>The root node is treated specially because the root node of the
* result tree is created implicitly. When the current node is the
* root node, xsl:copy will not create a root node, but will just use
* the content template.</p>
*
* @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();
try
{
int sourceNode = xctxt.getCurrentNode();
xctxt.pushCurrentNode(sourceNode);
DTM dtm = xctxt.getDTM(sourceNode);
short nodeType = dtm.getNodeType(sourceNode);
if ((DTM.DOCUMENT_NODE != nodeType) && (DTM.DOCUMENT_FRAGMENT_NODE != nodeType))
{
SerializationHandler rthandler = transformer.getSerializationHandler();
// TODO: Process the use-attribute-sets stuff
ClonerToResultTree.cloneToResultTree(sourceNode, nodeType, dtm,
rthandler, false);
if (DTM.ELEMENT_NODE == nodeType)
{
super.execute(transformer);
SerializerUtils.processNSDecls(rthandler, sourceNode, nodeType, dtm);
transformer.executeChildTemplates(this, true);
String ns = dtm.getNamespaceURI(sourceNode);
String localName = dtm.getLocalName(sourceNode);
transformer.getResultTreeHandler().endElement(ns, localName,
dtm.getNodeName(sourceNode));
}
}
else
{
super.execute(transformer);
transformer.executeChildTemplates(this, true);
}
}
catch(org.xml.sax.SAXException se)
{
throw new TransformerException(se);
}
finally
{
xctxt.popCurrentNode();
}
}