public void endNode() { try { if (!children) { Element element = new DefaultElement((String)elementStack.pop()); for (int i = 0; i < attributes.getLength(); ++i) { element.addAttribute(attributes.getQName(i), attributes.getValue(i)); } writer.write(element); attributes.clear(); children = true; // node just closed is child of node on top of stack started = true; } else { startElement(); writer.endElement("", "", (String)elementStack.pop()); } } catch (SAXException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
/** * Test method for {@link XmlGeneratorUtils#addAttribute(AttributesImpl, String, Object)}. */ @Test public void testAddAttributeAttributesImplStringObject() { final AttributesImpl attributes = new AttributesImpl(); assertEquals(0, attributes.getLength()); XmlGeneratorUtils.addAttribute(attributes, "localname", null); assertEquals(0, attributes.getLength()); XmlGeneratorUtils.addAttribute(attributes, "localname", "value"); assertEquals(1, attributes.getLength()); assertEquals("localname", attributes.getLocalName(0)); assertEquals("localname", attributes.getQName(0)); assertEquals(XMLConstants.NULL_NS_URI, attributes.getURI(0)); assertEquals("value", attributes.getValue(0)); }
/** * Test method for {@link XmlGeneratorUtils#addAttribute(AttributesImpl, String, String, Object)}. */ @Test public void testAddAttributeAttributesImplStringStringObject() { final AttributesImpl attributes = new AttributesImpl(); assertEquals(0, attributes.getLength()); XmlGeneratorUtils.addAttribute(attributes, "prefix", "localname", null); assertEquals(0, attributes.getLength()); XmlGeneratorUtils.addAttribute(attributes, "prefix", "localname", "value"); assertEquals(1, attributes.getLength()); assertEquals("localname", attributes.getLocalName(0)); assertEquals("prefix:localname", attributes.getQName(0)); assertEquals(NULL_NS_URI, attributes.getURI(0)); assertEquals("value", attributes.getValue(0)); }
String src = newAttrs.getValue(i); if(src.startsWith("embedded:")) { String filename = src.substring(src.indexOf(':')+1);
String src = newAttrs.getValue(i); if (src.startsWith("embedded:")) { String filename = src.substring(src.indexOf(':') + 1);
String v = newAttributes.getValue(att); if (v.startsWith("data:")) { newAttributes.setValue(att, "data:"); newAttributes.setValue(att, resolve(newAttributes.getValue(att))); } else if (isObject && "codebase".equals(normAttrName)) { newAttributes.setValue(att, codebase); newAttributes.setValue( att, resolve(codebase, newAttributes.getValue(att))); if ("img".equals(name) && newAttributes.getValue("", "alt") == null) { newAttributes.addAttribute("", "alt", "alt", "CDATA", "");
/** * Return true if list contains the given (raw) attribute name. * * @param name Raw name of attribute to look for * * @return true if an attribute is found with this name */ public boolean contains(String name) { return getValue(name) != null; } }
/** * Return true if list contains the given (raw) attribute name. * * @param name Raw name of attribute to look for * * @return true if an attribute is found with this name */ public boolean contains(String name) { return getValue(name) != null; } }
public String getValue(String qName) { return adjustedAttributes.getValue(qName); } }
@Override public String getAttributeValue(String uri, String localName) { switch (state) { case StartTag: case EndTag: return tagInfo.atts.getValue(uri, localName); case Payload: default: return payloadReader.getAttributeValue(uri, localName); } }
@Override public String getAttributeValue(int index) { switch (state) { case StartTag: case EndTag: return tagInfo.atts.getValue(index); case Payload: default: return payloadReader.getAttributeValue(index); } }
@Override public String getAttributeValue(int index) { switch (state) { case StartTag: case EndTag: return tagInfo.atts.getValue(index); case Payload: default: return payloadReader.getAttributeValue(index); } }
@Override public String getAttributeValue(String uri, String localName) { switch (state) { case StartTag: case EndTag: return tagInfo.atts.getValue(uri, localName); case Payload: default: return payloadReader.getAttributeValue(uri, localName); } }
@Override public String getAttributeValue(String uri, String localName) { switch (state) { case StartTag: case EndTag: return tagInfo.atts.getValue(uri, localName); case Payload: default: return payloadReader.getAttributeValue(uri, localName); } }
@Override public String getAttributeValue(int index) { switch (state) { case StartTag: case EndTag: return tagInfo.atts.getValue(index); case Payload: default: return payloadReader.getAttributeValue(index); } }
/** * Returns a value for an attribute from the source element. * @param qname The QName of the attribute to return. * @return The value of the attribute of name 'qname'. */ protected String getAttribute(String qname) { if (_attributes == null) { return EMPTYSTRING; } final String value = _attributes.getValue(qname); return (value == null || value.equals(EMPTYSTRING)) ? EMPTYSTRING : value; }
/** * Returns a value for an attribute from the source element. * @param qname The QName of the attribute to return. * @return The value of the attribute of name 'qname'. */ protected String getAttribute(String qname) { if (_attributes == null) { return EMPTYSTRING; } final String value = _attributes.getValue(qname); return (value == null || value.equals(EMPTYSTRING)) ? EMPTYSTRING : value; }
@Override public void startElement (String nsUri, String localname, String rawName, Attributes atts) throws SAXException { AttributesImpl linkAttributes = new AttributesImpl(atts); if (transform && A_TAG.equals(localname)) { for (int i=0; i < linkAttributes.getLength(); i++) { if (HREF_ATTRIBUTE.equals(linkAttributes.getLocalName(i))) { linkAttributes.setValue(i, transformHref(linkAttributes.getValue(i))); } } } super.startElement(nsUri, localname, rawName, linkAttributes); }
@Override protected void addAttributes(ChangeText txt, Attributes attributes) { AttributesImpl newAttrs = new AttributesImpl(attributes); String href = newAttrs.getValue("href"); if (href != null) { txt.addText(" " + getWithDestination().toLowerCase() + " " + href); newAttrs.removeAttribute(newAttrs.getIndex("href")); } super.addAttributes(txt, newAttrs); }