Strategy origStrategy = null;
if(profile != null) {
origStrategy = profile.getStrategy();
profile.setStrategy(Strategy.serialization);
}
final IDocumentTable doctbl = _store;
doctbl.ensureOpen();
switch(doctbl.getNodeKindAt(nodeid)) {
case NodeKind.DOCUMENT:
receiver.evStartDocument();
final long firstChild = doctbl.firstChild(nodeid);
if(firstChild != -1L) {
export(firstChild, receiver);
long nextSib = doctbl.nextSibling(firstChild);
while(nextSib != 0L) {
export(nextSib, receiver);
nextSib = doctbl.nextSibling(firstChild);
}
}
receiver.evEndDocument();
break;
case NodeKind.ELEMENT:
final QualifiedName qname = doctbl.getName(nodeid);
receiver.evStartElement(nodeid, qname);
// namespace decl
final int nsdeclCnt = doctbl.getNamespaceCountAt(nodeid);
for(int i = 0; i < nsdeclCnt; i++) {
final long nsid = doctbl.getNamespaceDecl(nodeid, i);
final QualifiedName nsName = doctbl.getAttributeName(nsid);
final String uri = doctbl.getText(nsid);
receiver.evNamespace(nsid, nsName, uri);
}
// attribute
final int attrCnt = doctbl.getAttributeCountAt(nodeid);
for(int i = 0; i < attrCnt; i++) {
final long attid = doctbl.getAttribute(nodeid, i);
final QualifiedName attName = doctbl.getAttributeName(attid);
final String attValue = doctbl.getText(attid);
receiver.evAttribute(attid, attName, attValue);
}
final long elemFirstChild = doctbl.firstChild(nodeid);
if(elemFirstChild != -1L) {
export(elemFirstChild, receiver);
long nextSib = doctbl.nextSibling(elemFirstChild);
while(nextSib != 0L) {
export(nextSib, receiver);
nextSib = doctbl.nextSibling(nextSib);
}
}
receiver.evEndElement(nodeid, qname);
break;
case NodeKind.ATTRIBUTE:
receiver.evAttribute(nodeid, doctbl.getAttributeName(nodeid), doctbl.getText(nodeid));
break;
case NodeKind.NAMESPACE:
receiver.evNamespace(nodeid, doctbl.getAttributeName(nodeid), doctbl.getText(nodeid));
break;
case NodeKind.TEXT:
receiver.evText(nodeid, doctbl.getText(nodeid));
break;
case NodeKind.COMMENT:
receiver.evComment(nodeid, doctbl.getText(nodeid));
break;
case NodeKind.PROCESSING_INSTRUCTION:
final QualifiedName pi = doctbl.getName(nodeid);
receiver.evProcessingInstruction(nodeid, pi.getLocalPart(), pi.getNamespaceURI());
break;
default:
throw new IllegalStateException("Invalid node kind '"
+ NodeKind.resolveName(doctbl.getNodeKindAt(nodeid)) + "' for node#"
+ nodeid);
}
if(profile != null) {
profile.setStrategy(origStrategy);
}