NodeType nodeType = NodeType.fromString(getString(RecordEntry.TYPE));
NodeRecord record;
String tmp, rid;
ISXERecordFactory factory = document.getController().getRecordFactory();
String parentRid = getString(RecordEntry.PARENT);
if (parentRid == null) {
if (!document.isEmpty())
throw new MalformedRecordException(
"Received non-root record without parent: "
+ getString(RecordEntry.RID));
}
String name = getString(RecordEntry.NAME);
String ns = getString(RecordEntry.NS);
switch (nodeType) {
case ATTR:
String chdata = getString(RecordEntry.CHDATA);
AttributeRecord attribute = factory.createAttributeRecord(document,
ns, name, chdata);
if (chdata != null)
attribute.setChdata(chdata);
record = attribute;
break;
case ELEMENT:
if (parentRid == null)
record = factory.createRoot(document);
else
record = factory.createElementRecord(document, ns, name);
break;
default:
throw new RuntimeException("Unknown node type " + getRecordType());
}