org.enhydra.xml.xmlc.parsers
Class DocBuilder

java.lang.Object
  |
  +--org.enhydra.xml.xmlc.parsers.DocBuilder

public class DocBuilder
extends Object

Class for building a Document DOM. Used by XMLC XML parsers to build a DOM as well as collect other information about the document.

The document builder functions assume they are being called in the order the document is parsed. They keep a current node where new child nodes are appended.


Field Summary
protected  Node fCurrentNode
          The current node that is being constructed.
 
Constructor Summary
DocBuilder(XMLCDomFactory domFactory)
          Constructor.
 
Method Summary
 void addAttribute(String namespaceURI, String name, String value)
          Add an attribute to the element on the top of the stack.
 void addCDATASection(String data)
          Add a CDATASection node.
 void addComment(String data)
          Add a Comment node.
 void addEntityReference(String name)
          Add an EntityReference object.
 void addIdAttribute(String elementName, String attributeName)
          Define an element id attribute.
 void addPCDataContentElement(String elementName)
          Flag a element as having #PCDATA as part of its content model.
 void addProcessingInstruction(String target, String data)
          Add a ProcessingInstruction node.
 void addTextNode(String data)
          Add a Text node.
 void endEntityReference()
          End an entity reference.
 void finish()
          Called at the end of parsing, to finish any pending tasks, default values, etc.
 void finishElement()
          Finish the element being constructed.
 Node getCurrentNode()
          Get the node on the top of the stack during parsing.
 XMLCDocument getDocument()
          Get the document associated with this object.
 void popCurrentNode()
          Pop the current node off of the stack.
 void setDocumentTypeName(String docTypeName)
          Set the document type name (rootElement).
 void setEncoding(String encoding)
          Set the encoding for the document.
 void setInternalSubset(String subsetStr)
          Add internal subset as a single string.
 void setPublicId(String publicId)
          Set the publicId.
 void setSystemId(String systemId)
          Set the systemId.
 void setXMLVersion(String xmlVersion)
          Set the XML version.
 void startElement(String namespaceURI, String tagName)
          Start a new Element.
 void startEntityReference(String entityName)
          Start an entity reference in the document (not DTD).
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fCurrentNode

protected Node fCurrentNode
The current node that is being constructed. This functions as a stack during document construction.
Constructor Detail

DocBuilder

public DocBuilder(XMLCDomFactory domFactory)
           throws XMLCException
Constructor.
Parameters:
domFactory - Factory class for Documents.
Method Detail

setXMLVersion

public void setXMLVersion(String xmlVersion)
Set the XML version.
Parameters:
xmlVersion - XML version string.

setEncoding

public void setEncoding(String encoding)
Set the encoding for the document.
Parameters:
encoding - The encoding for the document.

setDocumentTypeName

public void setDocumentTypeName(String docTypeName)
Set the document type name (rootElement).
Parameters:
docTypeName - The Document type name (also root node name).

setPublicId

public void setPublicId(String publicId)
Set the publicId.
Parameters:
publicId - Document type public id or null if standalone.

setSystemId

public void setSystemId(String systemId)
Set the systemId.
Parameters:
systemId - Document type system id or null if standalone.

setInternalSubset

public void setInternalSubset(String subsetStr)
Add internal subset as a single string.

addPCDataContentElement

public void addPCDataContentElement(String elementName)
Flag a element as having #PCDATA as part of its content model.

addIdAttribute

public void addIdAttribute(String elementName,
                           String attributeName)
Define an element id attribute.

getDocument

public XMLCDocument getDocument()
Get the document associated with this object.

getCurrentNode

public Node getCurrentNode()
Get the node on the top of the stack during parsing. FIXME: To support the broken swing parser.

popCurrentNode

public void popCurrentNode()
Pop the current node off of the stack. This is *only* used during error recover from a broken parser. FIXME: This and getCurrentNode() should go away when the with the broken swing parser.

startElement

public void startElement(String namespaceURI,
                         String tagName)
Start a new Element.

addAttribute

public void addAttribute(String namespaceURI,
                         String name,
                         String value)
Add an attribute to the element on the top of the stack.

finishElement

public void finishElement()
Finish the element being constructed.

startEntityReference

public void startEntityReference(String entityName)
Start an entity reference in the document (not DTD).

endEntityReference

public void endEntityReference()
End an entity reference.

addTextNode

public void addTextNode(String data)
Add a Text node.

addComment

public void addComment(String data)
Add a Comment node.

addCDATASection

public void addCDATASection(String data)
Add a CDATASection node.

addProcessingInstruction

public void addProcessingInstruction(String target,
                                     String data)
Add a ProcessingInstruction node.

addEntityReference

public void addEntityReference(String name)
Add an EntityReference object.

finish

public void finish()
Called at the end of parsing, to finish any pending tasks, default values, etc.


Copyright © 1999-2002 enhydra.org (Mark Diekhans, David Li, Richard Kunze). All Rights reserved.