private Attr bufferAttribute( Element element, Attribute attribute ) { QName name = attribute.getName(); String prefix = name.getPrefix(); String uri = name.getNamespaceURI(); Attr node; if( uri == null || uri.isEmpty() ) { node = document.createAttribute( name.getLocalPart() ); element.setAttributeNode( node ); } else { node = document.createAttributeNS( uri, name.getLocalPart() ); if( prefix != null && !prefix.isEmpty() ) { node.setPrefix( prefix ); } element.setAttributeNodeNS( node ); } node.setTextContent( attribute.getValue() ); return node; }
private Attr bufferAttribute( Element element, Attribute attribute ) { QName name = attribute.getName(); String prefix = name.getPrefix(); String uri = name.getNamespaceURI(); Attr node; if( uri == null || uri.isEmpty() ) { node = document.createAttribute( name.getLocalPart() ); element.setAttributeNode( node ); } else { node = document.createAttributeNS( uri, name.getLocalPart() ); if( prefix != null && !prefix.isEmpty() ) { node.setPrefix( prefix ); } element.setAttributeNodeNS( node ); } node.setTextContent( attribute.getValue() ); return node; }
/** * Add an attribute to the specified element * @param parent the element to which we add the attribute * @param ns the namespace of the attribute * @param attributeName the name of the attribute * @param value the value of the attribute * @return the attribute */ public static final Attr addAttribute(Element parent, String ns, String attributeName, String value) { Document doc = parent.getOwnerDocument(); Attr ret = doc.createAttributeNS(ns, attributeName); ret.setTextContent(value); ret.setPrefix(OJBC_NAMESPACE_CONTEXT.getPrefix(ns)); parent.setAttributeNode(ret); return ret; }
@Override public Attr writeAttribute(String prefix, String namespaceURI, String localName, String value) { Attr result = null; if (value != null) { if ("".equals(namespaceURI)) { // Map global namespace from StAX to DOM namespaceURI = null; } result = factory.createAttributeNS(namespaceURI, DOMUtils.getQNameString(prefix, localName)); result.setTextContent(value); if (! (currentNode instanceof Element)) { throw new IllegalStateException( "Attempting to add an attribute to something other than an element node. Node is " + currentNode.toString()); } ( (Element)currentNode).setAttributeNodeNS(result); } return result; }
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; NodeList elemList; Element elem; Attr attr; String textContent; doc = (Document) load("hc_staff", true); elemList = doc.getElementsByTagName("p"); elem = (Element) elemList.item(3); attr = elem.getAttributeNode("dir"); attr.setTextContent("NA"); textContent = attr.getTextContent(); assertEquals("nodesettextcontent05", "NA", textContent); } /**
rcDataVolumeAttr.setTextContent(this.rcDataVolume); dcOutputParametersElement.getAttributes().setNamedItem(rcDataVolumeAttr);
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; NodeList elemList; Element elem; Attr attr; Attr attrNode; String textContent; doc = (Document) load("hc_staff", true); elem = doc.createElementNS("http://www.w3.org/1999/xhtml", "p"); attr = doc.createAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:lang"); attrNode = elem.setAttributeNodeNS(attr); attr.setTextContent("NA"); textContent = attr.getTextContent(); assertEquals("nodesettextcontent06", "NA", textContent); } /**
private void addIsReferenceParameterMarkerAttribute(Element lastAdded, String namespaceURI) { String pfx = lastAdded.lookupPrefix(namespaceURI); if (StringUtils.isEmpty(pfx)) { //attributes cannot be in empty namespace... if (lastAdded.lookupNamespaceURI(JAXWSAConstants.WSA_PREFIX) == null) { pfx = JAXWSAConstants.WSA_PREFIX; Attr attr = lastAdded.getOwnerDocument() .createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:wsa"); attr.setValue(namespaceURI); lastAdded.setAttributeNodeNS(attr); } else if (lastAdded.lookupNamespaceURI(JAXWSAConstants.WSA_PREFIX).equals(namespaceURI)) { pfx = JAXWSAConstants.WSA_PREFIX; } else { int cnt = 1; while (lastAdded.lookupNamespaceURI(JAXWSAConstants.WSA_PREFIX + cnt) != null) { cnt++; } pfx = JAXWSAConstants.WSA_PREFIX + cnt; Attr attr = lastAdded.getOwnerDocument() .createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:wsa" + cnt); attr.setValue(namespaceURI); lastAdded.setAttributeNodeNS(attr); } } Attr isRefParamAttr = lastAdded.getOwnerDocument().createAttributeNS(namespaceURI, pfx + ":" + IS_REFERENCE_PARAM_ATTR_NAME); isRefParamAttr.setTextContent("1"); lastAdded.setAttributeNodeNS(isRefParamAttr); }
private void addIsReferenceParameterMarkerAttribute(Element lastAdded, String namespaceURI) { String pfx = lastAdded.lookupPrefix(namespaceURI); if (StringUtils.isEmpty(pfx)) { //attributes cannot be in empty namespace... if (lastAdded.lookupNamespaceURI(JAXWSAConstants.WSA_PREFIX) == null) { pfx = JAXWSAConstants.WSA_PREFIX; Attr attr = lastAdded.getOwnerDocument() .createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:wsa"); attr.setValue(namespaceURI); lastAdded.setAttributeNodeNS(attr); } else if (lastAdded.lookupNamespaceURI(JAXWSAConstants.WSA_PREFIX).equals(namespaceURI)) { pfx = JAXWSAConstants.WSA_PREFIX; } else { int cnt = 1; while (lastAdded.lookupNamespaceURI(JAXWSAConstants.WSA_PREFIX + cnt) != null) { cnt++; } pfx = JAXWSAConstants.WSA_PREFIX + cnt; Attr attr = lastAdded.getOwnerDocument() .createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:wsa" + cnt); attr.setValue(namespaceURI); lastAdded.setAttributeNodeNS(attr); } } Attr isRefParamAttr = lastAdded.getOwnerDocument().createAttributeNS(namespaceURI, pfx + ":" + IS_REFERENCE_PARAM_ATTR_NAME); isRefParamAttr.setTextContent("1"); lastAdded.setAttributeNodeNS(isRefParamAttr); }
Attr topicAttr = doc.createAttributeNS(WstopConstants.WS_TOPICS_NAMESPACE_URI, "topic"); topicAttr.setPrefix(WstopConstants.WS_TOPICS_PREFIX); topicAttr.setTextContent("true");
return getProxyReturnValueForMethod(proxy, method, Integer.valueOf(1)); attribute.setTextContent(valueToSet.toString()); return getProxyReturnValueForMethod(proxy, method, Integer.valueOf(1));
return getProxyReturnValueForMethod(proxy, method, Integer.valueOf(1)); attribute.setTextContent(valueToSet.toString()); return getProxyReturnValueForMethod(proxy, method, Integer.valueOf(1));