in jelly-tags/xml/src/main/java/org/apache/commons/jelly/tags/xml/ElementTag.java [90:172]
public void doTag(XMLOutput output) throws JellyTagException {
int idx = name.indexOf(':');
final String localName = (idx >= 0)
? name.substring(idx + 1)
: name;
outputAttributes = false;
XMLOutput newOutput = new XMLOutput(output) {
// add an initialize hook to the core content-generating methods
@Override
public void startElement(
String uri,
String localName,
String qName,
Attributes atts)
throws SAXException {
initialize();
super.startElement(uri, localName, qName, atts);
}
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
initialize();
super.endElement(uri, localName, qName);
}
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
initialize();
super.characters(ch, start, length);
}
@Override
public void ignorableWhitespace(char[] ch, int start, int length)
throws SAXException {
initialize();
super.ignorableWhitespace(ch, start, length);
}
@Override
public void objectData(Object object)
throws SAXException {
initialize();
super.objectData(object);
}
@Override
public void processingInstruction(String target, String data)
throws SAXException {
initialize();
super.processingInstruction(target, data);
}
/**
* Ensure that the outer start element is generated
* before any content is output.
*/
protected void initialize() throws SAXException {
if (!outputAttributes) {
super.startElement(namespace, localName, name, attributes);
outputAttributes = true;
}
}
};
invokeBody(newOutput);
try {
if (!outputAttributes) {
output.startElement(namespace, localName, name, attributes);
outputAttributes = true;
}
output.endElement(namespace, localName, name);
attributes.clear();
} catch (SAXException e) {
throw new JellyTagException(e);
}
}