VTD XML

VTD-XML (Virtual Token Descriptor for XML) is a group of cross-platform, non-extractive processing methods for XML. In traditional, extractive parsing, a lexical analyzer represents each token as a discrete string object copied out of the source. VTD-XML instead keeps the source document intact in memory and describes each token by its offset and length within that source - an approach its developers describe as "document-centric".

Because tokens are recorded as compact numeric records rather than materialized as separate string/object instances, VTD-XML skips the object-oriented modeling step used by parsers such as DOM, eliminating the associated object-creation and garbage-collection costs. This lets navigation stay fast even on large documents, and supports incremental updates - modifying a document in place without a full re-parse. The tradeoffs are that the in-memory representation increases the effective document size by roughly 30% to 50%, and VTD-XML is not compatible with DOM, SAX, external DTD entities, or certain validation techniques.

Navigation in VTD-XML is performed through a cursor object (commonly named VTDNav in the Java and C/C# implementations), with an AutoPilot helper class used to run XPath-like expressions over the indexed document.

Full nameVirtual Token Descriptor for XML
Processing modelNon-extractive; tokens recorded as offset/length pairs instead of extracted strings
Source documentKept intact in memory alongside the token index
Memory overheadApproximately 30% to 50% larger than the raw document size
CompatibilityNot compatible with DOM, SAX, external DTD entities, or certain validation techniques
Typical usesFast random access and incremental (in-place) updates without a full re-parse

VTDGen vg = new VTDGen();
if (vg.parseFile("books.xml", false)) {
    VTDNav vn = vg.getNav();
    AutoPilot ap = new AutoPilot(vn);
    ap.selectXPath("//book/@id");

    int i;
    while ((i = ap.evalXPath()) != -1) {
        System.out.println("Book id: " + vn.toString(i));
    }
}