public TextImpl(OMContainer parent, QName text, int nodeType, OMFactory factory) { this(((ElementImpl) parent).ownerNode, factory); if (text != null) { this.textNS = ((ElementImpl) parent).findNamespace(text.getNamespaceURI(), text.getPrefix()); } else { } this.textValue = new StringBuffer((text == null) ? "" : text.getLocalPart()); this.done = true; }
/** @see org.apache.axiom.om.OMElement#findNamespace(String, String) */ public OMNamespace findNamespace(String uri, String prefix) { // check in the current element OMNamespace namespace = findDeclaredNamespace(uri, prefix); if (namespace != null) { return namespace; } // go up to check with ancestors if (this.parentNode != null) { // For the OMDocumentImpl there won't be any explicit namespace // declarations, so going up the parent chain till the document // element should be enough. if (parentNode instanceof OMElement) { namespace = ((ElementImpl) parentNode).findNamespace(uri, prefix); } } if (namespace == null && uri != null && prefix != null && prefix.equals(OMConstants.XMLNS_PREFIX) && uri.equals(OMConstants.XMLNS_URI)) { declareNamespace(OMConstants.XMLNS_URI, OMConstants.XMLNS_PREFIX); namespace = findNamespace(uri, prefix); } return namespace; }
/** @see org.apache.axiom.om.OMElement#addAttribute (org.apache.axiom.om.OMAttribute) */ public OMAttribute addAttribute(OMAttribute attr) { OMNamespace namespace = attr.getNamespace(); if (namespace != null && namespace.getNamespaceURI() != null && !"".equals(namespace.getNamespaceURI()) && this.findNamespace(namespace.getNamespaceURI(), namespace .getPrefix()) == null) { this.declareNamespace(namespace.getNamespaceURI(), namespace.getPrefix()); } if (attr.getNamespace() != null) { // If the attr has a namespace return (AttrImpl) this.setAttributeNode((Attr) attr); } else { return (AttrImpl) this.setAttributeNodeNS((Attr) attr); } }
/** * The behaviour of this is the same as org.w3c.dom.Element#setAttributeNS * * @see org.apache.axiom.om.OMElement#addAttribute(String, String, org.apache.axiom.om.OMNamespace) */ public OMAttribute addAttribute(String attributeName, String value, OMNamespace ns) { if (ns != null && findNamespace(ns.getNamespaceURI(), ns.getPrefix()) != null) { declareNamespace(ns); } if (ns != null) { return this.addAttribute(ns.getNamespaceURI(), ns.getPrefix() + ":" + attributeName, value); } else { return this.addAttribute(null, attributeName, value); } }
&& findNamespace(attr.getNamespaceURI(), attr.getPrefix()) == null) {