Used for elements and text nodes element name is null for text nodes start and end are offsets into lexbuf which
contains the textual content of all elements in the parse tree. Parent and content allow traversal of the parse tree
in any direction. attributes are represented as a linked list of AttVal nodes which hold the strings for
attribute/value pairs.
ASP_TAG
public static final short ASP_TAG
node type: asp tag.
CDATA_TAG
public static final short CDATA_TAG
node type: CDATA.
COMMENT_TAG
public static final short COMMENT_TAG
node type: comment.
DOCTYPE_TAG
public static final short DOCTYPE_TAG
node type: doctype.
END_TAG
public static final short END_TAG
End tag.
JSTE_TAG
public static final short JSTE_TAG
node type: jste tag.
PHP_TAG
public static final short PHP_TAG
node type: php tag.
PROC_INS_TAG
public static final short PROC_INS_TAG
node type: .
ROOT_NODE
public static final short ROOT_NODE
node type: root.
SECTION_TAG
public static final short SECTION_TAG
node type: section tag.
START_END_TAG
public static final short START_END_TAG
Start of an end tag.
START_TAG
public static final short START_TAG
Start tag.
TEXT_NODE
public static final short TEXT_NODE
node type: text.
XML_DECL
public static final short XML_DECL
node type: doctype.
adapter
protected org.w3c.dom.Node adapter
DOM adapter.
attributes
protected AttVal attributes
Attribute/Value linked list.
closed
protected boolean closed
true if closed by explicit end tag.
content
protected Node content
Contained node.
element
protected String element
Tag name.
end
protected int end
end of span onto text array.
implicit
protected boolean implicit
true if inferred.
last
protected Node last
last node.
linebreak
protected boolean linebreak
true if followed by a line break.
next
protected Node next
next node.
parent
protected Node parent
parent node.
prev
protected Node prev
pevious node.
start
protected int start
start of span onto text array.
tag
protected Dict tag
tag's dictionary definition.
textarray
protected byte[] textarray
the text array.
type
protected short type
TextNode, StartTag, EndTag etc.
was
protected Dict was
old tag when it was changed.
addAttribute
public void addAttribute(String name,
String value)
Adds an attribute to the node.
name
- attribute namevalue
- attribute value
addClass
public void addClass(String classname)
Add a css class to the node. If a class attribute already exists adds the value to the existing attribute.
classname
- css class name
checkAttributes
public void checkAttributes(Lexer lexer)
Default method for checking an element's attributes.
checkNodeIntegrity
public boolean checkNodeIntegrity()
Checks for node integrity.
- false if node is not consistent
clone
protected Object clone()
Used to clone heading nodes when split by an hr.
cloneNode
protected Node cloneNode(boolean deep)
Clone this node.
deep
- if true deep clone the node (also clones all the contained nodes)
coerceNode
public static void coerceNode(Lexer lexer,
Node node,
Dict tag)
Coerce a node.
lexer
- Lexernode
- Nodetag
- tag dictionary reference
discardDocType
public void discardDocType()
Discard the doctype node.
discardElement
public static Node discardElement(Node element)
Remove node from markup tree and discard it.
escapeTag
protected static Node escapeTag(Lexer lexer,
Node element)
Escapes the given tag.
lexer
- Lexerelement
- node to be escaped
expectsContent
public boolean expectsContent()
Does the node expect contents?
false
if this node should be empty
findBody
public Node findBody(TagTable tt)
Find the body node.
findDocType
public Node findDocType()
Find the doctype element.
- doctype node or null if not found
findHEAD
public Node findHEAD(TagTable tt)
Find the head tag.
findHTML
public Node findHTML(TagTable tt)
Find the "html" element.
fixEmptyRow
public static void fixEmptyRow(Lexer lexer,
Node row)
If a table row is empty then insert an empty cell.This practice is consistent with browser behavior and avoids
potential problems with row spanning cells.
lexer
- Lexerrow
- row node
getAdapter
protected org.w3c.dom.Node getAdapter()
Returns a DOM Node which wrap the current tidy Node.
- org.w3c.dom.Node instance
getAttrByName
public AttVal getAttrByName(String name)
Returns an attribute with the given name in the current node.
- AttVal instance or null if no attribute with the iven name is found
hasOneChild
public boolean hasOneChild()
Does the node have one (and only one) child?
true
if the node has one child
insertDocType
public static void insertDocType(Lexer lexer,
Node element,
Node doctype)
The doctype has been found after other tags, and needs moving to before the html element.
lexer
- Lexerelement
- documentdoctype
- doctype node to insert at the beginning of element
insertMisc
public static boolean insertMisc(Node element,
Node node)
Insert a node at the end.
element
- parent nodenode
- will be inserted at the end of element
true
if the node has been inserted
insertNodeAfterElement
public void insertNodeAfterElement(Node node)
Insert node into markup tree after element.
node
- new node to insert
insertNodeAsParent
public static void insertNodeAsParent(Node element,
Node node)
Insert node into markup tree in pace of element which is moved to become the child of the node.
element
- child node. Will be inserted as a child of elementnode
- parent node
insertNodeAtEnd
public void insertNodeAtEnd(Node node)
Insert node into markup tree.
insertNodeAtStart
public void insertNodeAtStart(Node node)
Insert a node into markup tree.
insertNodeBeforeElement
public static void insertNodeBeforeElement(Node element,
Node node)
Insert node into markup tree before element.
element
- child node. Will be insertedbefore elementnode
- following node
isBlank
public boolean isBlank(Lexer lexer)
Is the node content empty or blank? Assumes node is a text node.
true
if the node content empty or blank
isDescendantOf
public boolean isDescendantOf(Dict tag)
Is this node contained in a given tag?
true
if node is contained in tag
isElement
public boolean isElement()
Is the node an element?
true
if type is START_TAG | START_END_TAG
isJavaScript
public boolean isJavaScript()
Used to check script node for script language.
true
if the script node contains javascript
isNewNode
public boolean isNewNode()
Is this a new (user defined) node? Used to determine how attributes without values should be printed. This was
introduced to deal with user defined tags e.g. Cold Fusion.
true
if this node represents a user-defined tag.
moveBeforeTable
public static void moveBeforeTable(Node row,
Node node,
TagTable tt)
Unexpected content in table row is moved to just before the table in accordance with Netscape and IE. This code
assumes that node hasn't been inserted into the row.
row
- Row nodenode
- Node which should be moved before the tablett
- tag table
removeAttribute
public void removeAttribute(AttVal attr)
Remove an attribute from node and then free it.
attr
- attribute to remove
removeNode
public void removeNode()
Extract this node and its children from a markup tree.
repairDuplicateAttributes
public void repairDuplicateAttributes(Lexer lexer)
The same attribute name can't be used more than once in each element. Discard or join attributes according to
configuration.
setType
protected void setType(short newType)
Setter for node type.
newType
- a valid node type constant
toString
public String toString()
java.lang.Object.toString()
trimEmptyElement
public static void trimEmptyElement(Lexer lexer,
Node element)
Trim an empty element.
lexer
- Lexerelement
- empty node to be removed
trimInitialSpace
public static void trimInitialSpace(Lexer lexer,
Node element,
Node text)
This maps <p> hello <em> world </em>
to <p> hello <em> world </em>
.
Trims initial space, by moving it before the start tag, or if this element is the first in parent's content, then
by discarding the space.
lexer
- Lexerelement
- parent nodetext
- text node
trimSpaces
public static void trimSpaces(Lexer lexer,
Node element)
Move initial and trailing space out. This routine maps: hello world to hello world and
hello world to hello world .
lexer
- Lexerelement
- Node
trimTrailingSpace
public static void trimTrailingSpace(Lexer lexer,
Node element,
Node last)
This maps hello world to hello world . If last child of
element is a text node then trim trailing white space character moving it to after element's end tag.
lexer
- Lexerelement
- nodelast
- last child of element