org.enhydra.xml.xmlc.html.parsers
Class HTMLDocBuilder

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

public class HTMLDocBuilder
extends Object

Class used by HTML parser to build a DOM.

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.


Constructor Summary
HTMLDocBuilder(XMLCDomFactory domFactory, InputSource input)
          Constructor.
 
Method Summary
 void addAttribute(String name, String value)
          Add an attribute to the element on the top of the stack.
 void addComment(String data)
          Add a Comment node.
 void addTextNode(String data)
          Add a Text node.
 void finishElement()
          Finish the element being constructed.
 void fixUnrecognizedTagNesting(String tagName)
          Used to correct nesting when handling an unknown tag.
 Node getCurrentNode()
          Get the node on the top of the stack during parsing.
 XMLCDocument getXMLCDocument()
          Get the XMLC document associated with this object.
 void popCurrentNode()
          Pop the current node off of the stack.
 void startElement(String tagName)
          Start a new Element.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTMLDocBuilder

public HTMLDocBuilder(XMLCDomFactory domFactory,
                      InputSource input)
               throws XMLCException
Constructor. Creates XMLCDocument object.
Method Detail

getXMLCDocument

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

startElement

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

addAttribute

public void addAttribute(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.

addTextNode

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

addComment

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

getCurrentNode

public Node getCurrentNode()
Get the node on the top of the stack during parsing. FIXME: Added to work around bugs in the 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: Added to work around bugs in the swing parser.

fixUnrecognizedTagNesting

public void fixUnrecognizedTagNesting(String tagName)
                               throws XMLCException
Used to correct nesting when handling an unknown tag. This is called when the end tag is encountered. The tree is walked backwards from the top of the stack to find the element pushed for the open tag. All of the siblings to the right of that element are moved to be children of the element. The stack is popped back until the parent of the element being closed is on top. This was put in to support the swing parser.


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