List of usage examples for org.xml.sax.helpers AttributesImpl getURI
public String getURI(int index)
From source file:org.apache.axis.message.MessageElement.java
/** * remove an element/*from w ww . j a v a 2s . c o m*/ * @param attrName name of the element * @return true if the attribute was found and removed. * @see javax.xml.soap.SOAPElement#removeAttribute(javax.xml.soap.Name) */ public boolean removeAttribute(Name attrName) { AttributesImpl attributes = makeAttributesEditable(); boolean removed = false; for (int i = 0; i < attributes.getLength() && !removed; i++) { if (attributes.getURI(i).equals(attrName.getURI()) && attributes.getLocalName(i).equals(attrName.getLocalName())) { attributes.removeAttribute(i); removed = true; } } return removed; }
From source file:org.apache.axis.message.MessageElement.java
/** * remove a named attribute.// ww w.ja va2 s.c om * @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. *//*from w w w . ja v a2s. c om*/ 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; } }
From source file:org.apache.cocoon.template.script.Parser.java
public void startElement(String namespaceURI, String localName, String qname, Attributes attrs) throws SAXException { Event newEvent = null;/*from w w w .j av a 2s . co m*/ AttributesImpl elementAttributes = new AttributesImpl(attrs); int attributeCount = elementAttributes.getLength(); for (int i = 0; i < attributeCount; i++) { String attributeURI = elementAttributes.getURI(i); if (StringUtils.equals(attributeURI, JXTemplateGenerator.NS)) { // TODO: template properties should be allowed only on template // root getStartEvent().getTemplateProperties().put(elementAttributes.getLocalName(i), this.parsingContext .getStringTemplateParser().compileExpr(elementAttributes.getValue(i), null, locator)); elementAttributes.removeAttribute(i--); } } StartElement startElement = new StartElement(this.parsingContext, locator, namespaceURI, localName, qname, elementAttributes); InstructionFactory instructionFactory = this.parsingContext.getInstructionFactory(); if (instructionFactory.isInstruction(startElement)) newEvent = instructionFactory.createInstruction(this.parsingContext, startElement, attrs, stack); else newEvent = startElement; stack.push(newEvent); addEvent(newEvent); }
From source file:org.apache.cocoon.transformation.JPathTransformer.java
/** * Helper method to check for the existance of an attribute named * jpath:action. If existing the string 'id' is replaced with the * continuation id./* w w w. jav a2s.co m*/ * * @param a an {@link AttributesImpl} instance */ private void checkJPathAction(final AttributesImpl a) { // check for jpath:action attribute int idx = a.getIndex(JPATH_ACTION); if (idx != -1 && JPATH_NAMESPACE_URI.equals(a.getURI(idx))) { if (getLogger().isDebugEnabled()) { getLogger().debug("found jpath:action, adjusting"); } String value = a.getValue(idx); // REVISIT(MC): support for continuation level String id = m_kont.getContinuation(0).getId(); a.removeAttribute(idx); a.addAttribute("", "action", "action", "CDATA", m_re.subst(value, id)); } }