List of usage examples for org.xml.sax.helpers AttributesImpl getQName
public String getQName(int index)
From source file:Writer.java
/** Returns a sorted list of attributes. */ protected Attributes sortAttributes(Attributes attrs) { AttributesImpl attributes = new AttributesImpl(); int len = (attrs != null) ? attrs.getLength() : 0; for (int i = 0; i < len; i++) { String name = attrs.getQName(i); int count = attributes.getLength(); int j = 0; while (j < count) { if (name.compareTo(attributes.getQName(j)) < 0) { break; }// w w w . jav a2 s.c o m j++; } attributes.insertAttributeAt(j, name, attrs.getType(i), attrs.getValue(i)); } return attributes; }
From source file:org.apache.axis.message.MessageElement.java
/** * remove a named attribute.//w w w . j a va 2 s . c o m * @see org.w3c.dom.Element#removeAttribute(String) * @param attrName name of the attributes * @throws DOMException */ public void removeAttribute(String attrName) throws DOMException { AttributesImpl impl = (AttributesImpl) attributes; int index = impl.getIndex(attrName); if (index >= 0) { AttributesImpl newAttrs = new AttributesImpl(); // copy except the removed attribute for (int i = 0; i < impl.getLength(); i++) { // shift after removal if (i != index) { String uri = impl.getURI(i); String local = impl.getLocalName(i); String qname = impl.getQName(i); String type = impl.getType(i); String value = impl.getValue(i); newAttrs.addAttribute(uri, local, qname, type, value); } } // replace it attributes = newAttrs; } }
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. */// w w w.java 2 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; } }