/** * Retrieves an attribute node by local name and namespace URI. * * @see org.w3c.dom.Element#getAttributeNodeNS(String, String) */ public Attr getAttributeNodeNS(String namespaceURI, String localName) { if (OMConstants.XMLNS_NS_URI.equals(namespaceURI)) { OMNamespace ns = this.findNamespaceURI(localName); String nsuri = ns != null ? ns.getNamespaceURI() : ""; AttrImpl namespaceAttr = new AttrImpl(this.ownerNode, localName, nsuri, this.factory); NamespaceImpl xmlNs = new NamespaceImpl(OMConstants.XMLNS_NS_URI); namespaceAttr.setOMNamespace(xmlNs); return namespaceAttr; } return (this.attributes == null) ? null : (Attr) this.attributes .getNamedItemNS(namespaceURI, localName); }
/** * Sets the attribute value. * * @see org.apache.axiom.om.OMAttribute#setAttributeValue(String) */ public void setAttributeValue(String value) { if (isReadonly()) { String msg = DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null); throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg); } this.attrValue = (TextImpl) this.getOwnerDocument().createTextNode( value); }
/** * Returns the owner element. * * @see org.w3c.dom.Attr#getOwnerElement() */ public Element getOwnerElement() { // Owned is set to an element instance when the attribute is added to an // element return (Element) (isOwned() ? parent : null); }
if (attr.isOwned()) { // If the attribute is owned then: if (attr.getOwnerElement() != this.ownerNode) throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, DOMMessageFormatter.formatMessage( attr.isOwned(true); // To indicate that this attr belong to an element int i = findNamePoint(attr.getNamespaceURI(), attr.getLocalName()); AttrImpl previous = null; previous.ownerNode = (DocumentImpl) this.ownerNode .getOwnerDocument(); previous.isOwned(false); previous.isSpecified(true); } else { i = findNamePoint(attr.getNodeName(), 0); if (i >= 0) { previous = (AttrImpl) nodes.elementAt(i); if (!attr.isNormalized()) { ownerNode.isNormalized(false);
if (attr.isOwned()) { // If the attribute is owned then: if (attr.getOwnerElement() != this.ownerNode) // the owner must be attr.isOwned(true); // To indicate that this attr belong to an element attr.setUsed(true); // Setting used to true int i = findNamePoint(attr.getNodeName(), 0); nodes.setElementAt(attr, i); previous.parent = this.ownerNode; previous.isOwned(false); previous.isSpecified(true); } else { i = -1 - i; // Insert point (may be end of list) if (!attr.isNormalized()) { ownerNode.isNormalized(false);
if (attributeNode != null) { AttrImpl tempAttr = ((AttrImpl) attributeNode); tempAttr.setOMNamespace(new NamespaceImpl(namespaceURI, DOMUtil .getPrefix(qualifiedName))); tempAttr.setAttributeValue(value); this.attributes.setNamedItem(tempAttr); return tempAttr; NamespaceImpl ns = new NamespaceImpl(namespaceURI, DOMUtil .getPrefix(qualifiedName)); AttrImpl attr = new AttrImpl((DocumentImpl) this .getOwnerDocument(), DOMUtil .getLocalName(qualifiedName), ns, value, this.factory); if (attributeNode != null) { AttrImpl tempAttr = ((AttrImpl) attributeNode); tempAttr.setAttributeValue(value); this.attributes.setNamedItem(tempAttr); return tempAttr; } else { AttrImpl attr = new AttrImpl((DocumentImpl) this .getOwnerDocument(), qualifiedName, value, this.factory); this.attributes.setNamedItem(attr);
AttrImpl attrImpl = (AttrImpl) attr; if (attrImpl.isOwned()) {// check for ownership if (!this.getOwnerDocument().equals(attr.getOwnerDocument())) { String msg = DOMMessageFormatter.formatMessage( if (attrImpl.isUsed()) { String msg = DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "INUSE_ATTRIBUTE_ERR",
public void setLang(String lang) { langAttr = new AttrImpl(this.ownerNode, SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME, langNamespace, lang, this.factory); this.addAttribute(langAttr); }
/** * Sets the value of the attribute. * * @see org.w3c.dom.Attr#setValue(String) */ public void setValue(String value) throws DOMException { this.attrValue = (TextImpl) this.getOwnerDocument().createTextNode( value); }
public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException { if (this.isReadonly()) { String msg = DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null); throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg); } //find the attr Iterator attrIter = this.getAllAttributes(); AttrImpl tempAttr = null; while (attrIter.hasNext()) { AttrImpl attr = (AttrImpl) attrIter.next(); if (attr.equals(idAttr)) { tempAttr = attr; break; } } if (tempAttr == null) { String msg = DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null); throw new DOMException(DOMException.NOT_FOUND_ERR, msg); } this.updateIsId(isId, tempAttr); }
AttrImpl attrImpl = (AttrImpl) attr; if (attrImpl.isOwned()) {// check for ownership if (!this.getOwnerDocument().equals(attr.getOwnerDocument())) { String msg = DOMMessageFormatter.formatMessage( if (attrImpl.isUsed()) { String msg = DOMMessageFormatter .formatMessage(DOMMessageFormatter.DOM_DOMAIN,
public OMAttribute createOMAttribute(String localName, OMNamespace ns, String value) { return new AttrImpl(this.getDocument(), localName, ns, value, this); }
&& !prefix.equals(OMConstants.XMLNS_NS_PREFIX)) { OMNamespace ns = (OMNamespace) this.namespaces.get(prefix); AttrImpl attr = new AttrImpl(this.ownerNode, prefix, ns .getNamespaceURI(), this.factory); attr.setOMNamespace(new NamespaceImpl( OMConstants.XMLNS_NS_URI, OMConstants.XMLNS_NS_PREFIX)); AttrImpl attr = new AttrImpl(this.ownerNode, "xmlns", this.namespace.getNamespaceURI(), this.factory); attr.setOMNamespace(new NamespaceImpl( OMConstants.XMLNS_NS_URI, OMConstants.XMLNS_NS_PREFIX));
public Attr createAttribute(String name) throws DOMException { if (!DOMUtil.isQualifiedName(name)) { String msg = DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null); throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg); } return new AttrImpl(this, name, this.factory); }
/** * Adds a new attribute. * * @see org.w3c.dom.Element#setAttributeNS(String, String, String) */ public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException { if (namespaceURI != null && !"".equals(namespaceURI)) { if (namespaceURI.equals(OMConstants.XMLNS_NS_URI)) { this.declareNamespace(value, DOMUtil .getLocalName(qualifiedName)); } else { AttrImpl attr = new AttrImpl(this.ownerNode, DOMUtil .getLocalName(qualifiedName), value, this.factory); attr.setOMNamespace(new NamespaceImpl(namespaceURI, DOMUtil .getPrefix(qualifiedName))); this.setAttributeNodeNS(attr); } } else { // When the namespace is null, the attr name given better not be // a qualified name // But anyway check and set it this.setAttribute(DOMUtil.getLocalName(qualifiedName), value); } }
public Attr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException { String localName = DOMUtil.getLocalName(qualifiedName); String prefix = DOMUtil.getPrefix(qualifiedName); if (!OMConstants.XMLNS_NS_PREFIX.equals(localName)) { this.checkQName(prefix, localName); } else { return this.createAttribute(localName); } return new AttrImpl(this, localName, new NamespaceImpl( namespaceURI, prefix), this.factory); }
/** * @param attributeName * @param attrValue * @param soapEnvelopeNamespaceURI */ protected void setAttribute(String attributeName, String attrValue, String soapEnvelopeNamespaceURI) { OMAttribute omAttribute = this.getAttribute( new QName(soapEnvelopeNamespaceURI, attributeName)); if (omAttribute != null) { omAttribute.setAttributeValue(attrValue); } else { OMAttribute attribute = new AttrImpl(this.ownerNode, attributeName, new NamespaceImpl(soapEnvelopeNamespaceURI, SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX), attrValue, this.factory); this.addAttribute(attribute); } }
public void setAttribute(String name, String value) throws DOMException { // Check for invalid charaters if (!DOMUtil.isQualifiedName(name)) { String msg = DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null); throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg); } if (name.startsWith(OMConstants.XMLNS_NS_PREFIX + ":")) { // This is a ns declaration this.declareNamespace(value, DOMUtil.getLocalName(name)); } else if (name.equals(OMConstants.XMLNS_NS_PREFIX)) { this.declareDefaultNamespace(value); } else { this.setAttributeNode(new AttrImpl(this.ownerNode, name, value, this.factory)); } }
private void internalSerializeLocal(XMLStreamWriter writer2) throws XMLStreamException { MTOMXMLStreamWriter writer = (MTOMXMLStreamWriter) writer2; if (!this.isBinary) { writeOutput(writer); } else { if (writer.isOptimized()) { if (contentID == null) { contentID = writer.getNextContentId(); } // send binary as MTOM optimised this.attribute = new AttrImpl(this.ownerNode, "href", new NamespaceImpl("", ""), "cid:" + getContentID(), this.factory); this.serializeStartpart(writer); writer.writeOptimized(this); writer.writeEndElement(); } else { writer.writeCharacters(this.getText()); } } }