Java Reference
In-Depth Information
textandanyentityreferencenodesthatformitsvalue.Attributesnodesarenot
regarded as children of their associated element nodes.
•
CDATA section node
:thecontentsofaCDATAsection.Itsnameis
#cdata-
section
and its value is the CDATA section's text.
•
Comment node
:adocumentcomment.Itsnameis
#comment
anditsvalueis
thecommenttext.Acommentnodehasaparent,whichisthenodethatcontains
the comment.
•
Document fragment node
:analternative rootnode.Itsnameis
#document-
fragment
anditcontainsanythingthatanelementnodecancontain(suchas
otherelementnodesandevencommentnodes).Aparsernevercreatesthiskind
ofanode.However,anapplicationcancreateadocumentfragmentnodewhen
itextractspartofaDOMtreetobemovedsomewhereelse.Documentfragment
nodes let you work with subtrees.
•
Document node
:therootofaDOMtree.Itsnameis
#document
,italwayshas
a single element node child, and it will also have a document type child node
whenthedocumenthasadocumenttypedeclaration.Furthermore,itcanhave
additionalchildnodesdescribingcommentsorprocessinginstructionsthatap-
pearbeforeoraftertherootelement'sstarttag.Therecanbeonlyonedocument
node in the tree.
•
Document type node
:adocumenttypedeclaration.Itsnameisthenamespeci-
fiedbythedocumenttypedeclarationfortherootelement.Also,ithasa(pos-
siblynull)publicidentifier,arequiredsystemidentifier,aninternalDTDsubset
(which is possibly null), a parent (the document node that contains the docu-
ment type node), and lists of DTD-declared notations and general entities. Its
value is always set to null.
•
Element node
: a document's element. It has a name, a local name, a (possibly
null) prefix, and a namespace URI, which is null when the element doesn't
belong to any namespace. An element node contains children, including text
nodes, and even comment and processing instruction nodes.
•
Entity node
:theparsedandunparsedentitiesthataredeclaredinadocument's
DTD.WhenaparserreadsaDTD,itattachesamapofentitynodes(indexedby
entityname)tothedocumenttypenode.Anentitynodehasanameandasys-
temidentifier,andcanalsohaveapublicidentifierifoneappearsintheDTD.
Finally,whentheparserreadstheentity,theentitynodeisgivenalistofread-
only child nodes that contain the entity's replacement text.