• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DOM leaf nodes

 
sand zhang
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following nodes are leaf nodes:
attr
prcessing instruction
cdata
notation
I think attr is leaf node. But the whizlab says attr is not. Because Text and entityref are att's child nodes.
Who is right.
Thx
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is correct. attr Node has children.
This if a quote from the DOM Model Spec....

Document -- Element (maximum of one), ProcessingInstruction, Comment, DocumentType (maximum of one)
DocumentFragment -- Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
DocumentType -- no children
EntityReference -- Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
Element -- Element, Text, Comment, ProcessingInstruction, CDATASection, EntityReference
Attr -- Text, EntityReference
ProcessingInstruction -- no children
Comment -- no children
Text -- no children
CDATASection -- no children
Entity -- Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
Notation -- no children

Based on this we see that the other three Node types don't have children.
regds.
- m
[ February 22, 2004: Message edited by: Madhav Lakkapragada ]
 
sand zhang
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem, keep those questions coming....
- m
 
sand zhang
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I got another one.
I have a xml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE doc [
<!ELEMENT doc (#PCDATA |s|T|X)* >
<!ELEMENT s (#PCDATA)>
<!ATTLIST s attr1 ID #REQUIRED >
<!ELEMENT T (#PCDATA)>
<!ATTLIST T attr2 ID #REQUIRED >
<!ELEMENT X (#PCDATA)>
<!ATTLIST X attr3 IDREF #REQUIRED >
]>
<doc>
<s attr1="A">aaa</s>
<T attr2="B">aaa</T>
<X attr3="A">aaa</X>
</doc>
There are two IDs and one IDREF. IDREF can reference both IDS. Can distinguish these two IDs? Say attr3 only references attr1, not attr2. I guess not.
Thx
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic