for (int i = 0; i < count; i++) {
KeyValuePair kvp = aFrame.getKeyValuePair(i);
boolean isIndexed = false;
FrameComponent val = kvp.getValue();
// read attributes
AttributesImpl attrs = new AttributesImpl();
Attributes vinciAttrs = null;
if (val instanceof AFrame) {
vinciAttrs = ((AFrame) val).getAttributes();
} else if (val instanceof AFrameLeaf) {
vinciAttrs = ((AFrameLeaf) val).getAttributes();
}
if (vinciAttrs != null) {
for (int j = 0; j < vinciAttrs.getKeyValuePairCount(); j++) {
KeyValuePair attr = vinciAttrs.getKeyValuePair(j);
String attrName = attr.getKey();
String attrVal = attr.getValueAsString();
attrs.addAttribute("", attrName, attrName, "CDATA", attrVal);
if (attrName.equals("_indexed")) {
isIndexed = true;
}
}
}
// Kludge: all annotations returned from Vinci service are "indexed"
// (but not array elements!)
if (!isIndexed && !kvp.getKey().equals("i")) {
attrs.addAttribute("", "_indexed", "_indexed", "CDATA", "true");
}
mHandler.startElement("", kvp.getKey(), kvp.getKey(), attrs);
if (val instanceof FrameLeaf) {
String leafString = ((FrameLeaf) val).toString();
mHandler.characters(leafString.toCharArray(), 0, leafString.length());
} else if (val instanceof VinciFrame) {
_parse((VinciFrame) val);
} else {
throw new SAXException("Expected FrameLeaf or VinciFrame, found " + val.getClass());
}
mHandler.endElement("", kvp.getKey(), kvp.getKey());
}
}