List of usage examples for org.w3c.dom NamedNodeMap setNamedItemNS
public Node setNamedItemNS(Node arg) throws DOMException;
namespaceURI
and localName
. From source file:Main.java
/** * Puts all Nodes of the source NamedNodeMap into the destination NamedNodeMap * /* w ww.j a v a 2 s . co m*/ * @param dst the destination NamedNodeMap * @param src the source NamedNodeMap **/ public final static void putAll(final NamedNodeMap dst, final NamedNodeMap src) { final int size = size(src); for (int i = 0; i < size; i++) { dst.setNamedItemNS(src.item(i)); } }
From source file:de.escidoc.core.test.EscidocTestBase.java
/** * Adds the provided new attribute node to the element selected by the xPath in the given node. * //from w w w . jav a 2 s . co m * @param node * The node. * @param xPath * The xPath. * @param attributeNode * The new attribute node. * @return The resulting node after the substitution. * @throws Exception * If anything fails. */ public static Node addAttribute(final Node node, final String xPath, final Attr attributeNode) throws Exception { Node result = node; Node element = selectSingleNodeAsserted(result, xPath); NamedNodeMap attributes = element.getAttributes(); attributes.setNamedItemNS(attributeNode); return result; }
From source file:org.apache.axis.message.NodeImpl.java
/** * The internal representation of Attributes cannot help being changed * It is because Attribute is not immutible Type, so if we keep out value and * just return it in another form, the application may chnae it, which we cannot * detect without some kind back track method (call back notifying the chnage.) * I am not sure which approach is better. *///from www . ja v a2 s. co m protected NamedNodeMap convertAttrSAXtoDOM(Attributes saxAttr) { try { org.w3c.dom.Document doc = org.apache.axis.utils.XMLUtils.newDocument(); AttributesImpl saxAttrs = (AttributesImpl) saxAttr; NamedNodeMap domAttributes = new NamedNodeMapImpl(); for (int i = 0; i < saxAttrs.getLength(); i++) { String uri = saxAttrs.getURI(i); String qname = saxAttrs.getQName(i); String value = saxAttrs.getValue(i); if (uri != null && uri.trim().length() > 0) { // filterring out the tricky method to differentiate the null namespace // -ware case if (NULL_URI_NAME.equals(uri)) { uri = null; } Attr attr = doc.createAttributeNS(uri, qname); attr.setValue(value); domAttributes.setNamedItemNS(attr); } else { Attr attr = doc.createAttribute(qname); attr.setValue(value); domAttributes.setNamedItem(attr); } } return domAttributes; } catch (Exception ex) { log.error(Messages.getMessage("saxToDomFailed00"), ex); return null; } }