Nux 1.6

nux.xom.sandbox
Class TreeStructureCollector

java.lang.Object
  extended by nu.xom.NodeFactory
      extended by nux.xom.sandbox.TreeStructureCollector

public final class TreeStructureCollector
extends NodeFactory

Streaming demo that collects and prints a hierarchical statistics summary of element and attribute instances. In practice, the summary can be seen as a first approximation of a formal schema, though it is inferred from a schemaless document.

Time complexity is O(nrNodes), i.e. a single pass algorithm. Space complexity is O(maxTreeDepth) for real-world documents, i.e. memory consumption is negligible; the algorithm can be run over arbitrarily large input documents.

Author:
whoschek.AT.lbl.DOT.gov, $Author: hoschek3 $

Constructor Summary
TreeStructureCollector()
           
 
Method Summary
 Document collect(Document doc)
           
 Nodes finishMakingElement(Element elem)
          
static void main(String[] args)
           
 Nodes makeAttribute(String qname, String namespaceURI, String value, Attribute.Type type)
          
 Nodes makeComment(String data)
          
 Nodes makeDocType(String rootElementName, String publicID, String systemID)
          
 Nodes makeProcessingInstruction(String target, String data)
          
 Nodes makeText(String text)
          
 Document startMakingDocument()
          
 Element startMakingElement(String qname, String namespaceURI)
          
 
Methods inherited from class nu.xom.NodeFactory
finishMakingDocument, makeRootElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeStructureCollector

public TreeStructureCollector()
Method Detail

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception

collect

public Document collect(Document doc)

startMakingDocument

public Document startMakingDocument()

Overrides:
startMakingDocument in class NodeFactory

finishMakingElement

public Nodes finishMakingElement(Element elem)

Overrides:
finishMakingElement in class NodeFactory

startMakingElement

public Element startMakingElement(String qname,
                                  String namespaceURI)

Overrides:
startMakingElement in class NodeFactory

makeAttribute

public Nodes makeAttribute(String qname,
                           String namespaceURI,
                           String value,
                           Attribute.Type type)

Overrides:
makeAttribute in class NodeFactory

makeComment

public Nodes makeComment(String data)

Overrides:
makeComment in class NodeFactory

makeDocType

public Nodes makeDocType(String rootElementName,
                         String publicID,
                         String systemID)

Overrides:
makeDocType in class NodeFactory

makeProcessingInstruction

public Nodes makeProcessingInstruction(String target,
                                       String data)

Overrides:
makeProcessingInstruction in class NodeFactory

makeText

public Nodes makeText(String text)

Overrides:
makeText in class NodeFactory

Nux 1.6