}
} else {
// write start tag for attribute if desired
outputStartElement(aContentHandler, matchingNode, aNamespace, aXmlElementName, aXmlElementName, EMPTY_ATTRIBUTES);
CharacterValidatingContentHandler cc = maybeGetCharacterValidatingContentHandler(aContentHandler);
if (null != cc) {
cc.lastOutputNodeAddLevel();
}
try {
// iterate over entries in the Map
for (Map.Entry<String, Object> curEntry : theMap.entrySet()) {
String key = curEntry.getKey();
// write a tag for the value, with a "key" attribute
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute("", aKeyXmlAttribute, aKeyXmlAttribute, null, key); // are these nulls OK?
Node innerMatchingNode = findMatchingSubElement(aContentHandler, aValueTagName);
outputStartElement(aContentHandler, innerMatchingNode, aNamespace, aValueTagName, aValueTagName, attrs);
// write the value (must be XMLizable or an array of XMLizable)
Object val = curEntry.getValue();
if (val.getClass().isArray()) {
Object[] arr = (Object[]) val;
for (int j = 0; j < arr.length; j++) {
XMLizable elem = (XMLizable) arr[j];
elem.toXML(aContentHandler);
}
} else {
if (null != cc) {
cc.lastOutputNodeAddLevel();
}
try {
((XMLizable) val).toXML(aContentHandler);
} finally {
if (null != cc) {
cc.lastOutputNodeClearLevel();
}
}
}
// write end tag for the value
outputEndElement(aContentHandler, innerMatchingNode, aNamespace, aValueTagName, aValueTagName);
}
} finally {
if (null != cc) {
cc.lastOutputNodeClearLevel();
}
}
// if we wrote start tag for attribute, now write end tag
outputEndElement(aContentHandler, matchingNode, aNamespace, aXmlElementName, aXmlElementName);