public DataMetadata parse(XMLEventReader xmlEventReader, StartElement start)
throws GraphIOException {
try {
// Create the new port.
DataMetadata data = new DataMetadata();
// Parse the attributes.
Iterator iterator = start.getAttributes();
while (iterator.hasNext()) {
Attribute attribute = (Attribute) iterator.next();
String name = attribute.getName().getLocalPart();
String value = attribute.getValue();
if (data.getKey() == null && GraphMLConstants.KEY_NAME.equals(name)) {
data.setKey(value);
}
}
// Make sure the key has been set.
if (data.getKey() == null) {
throw new GraphIOException(
"Element 'data' is missing attribute 'key'");
}
while (xmlEventReader.hasNext()) {
XMLEvent event = xmlEventReader.nextEvent();
if (event.isStartElement()) {
StartElement element = (StartElement) event;
// Treat any child elements as unknown
getUnknownParser().parse(xmlEventReader, element);
}
if (event.isCharacters()) {
Characters characters = (Characters) event;
data.setValue(characters.getData());
}
if (event.isEndElement()) {
EndElement end = (EndElement) event;
verifyMatch(start, end);
break;