int dtmPos = getFirstFreeDTMID();
int documentID = dtmPos << IDENT_DTM_NODE_BITS;
if ((null != source) && source instanceof StAXSource) {
final StAXSource staxSource = (StAXSource)source;
StAXEvent2SAX staxevent2sax = null;
StAXStream2SAX staxStream2SAX = null;
if (staxSource.getXMLEventReader() != null) {
final XMLEventReader xmlEventReader = staxSource.getXMLEventReader();
staxevent2sax = new StAXEvent2SAX(xmlEventReader);
} else if (staxSource.getXMLStreamReader() != null) {
final XMLStreamReader xmlStreamReader = staxSource.getXMLStreamReader();
staxStream2SAX = new StAXStream2SAX(xmlStreamReader);
}
SAXImpl dtm;
if (size <= 0) {
dtm = new SAXImpl(this, source, documentID,
whiteSpaceFilter, null, doIndexing,
DTMDefaultBase.DEFAULT_BLOCKSIZE,
buildIdIndex, newNameTable);
} else {
dtm = new SAXImpl(this, source, documentID,
whiteSpaceFilter, null, doIndexing,
size, buildIdIndex, newNameTable);
}
dtm.setDocumentURI(source.getSystemId());
addDTM(dtm, dtmPos, 0);
try {
if (staxevent2sax != null) {
staxevent2sax.setContentHandler(dtm);
staxevent2sax.parse();
}
else if (staxStream2SAX != null) {
staxStream2SAX.setContentHandler(dtm);
staxStream2SAX.parse();
}