Debian Codegraph @

DOM

raw
1 $Id: DOM,v 1.3 1999/05/26 15:42:16 kmacleod Exp $
2
3 These are some notes relating XML::Grove to the core Document Object
4 Model <http://www.w3.org/DOM/> (REC-DOM-Level-1-19981001). In theory
5 it should be relatively easy to create a strict DOM interface that
6 closely matches the DOM spec, I will keep such an interface in mind to
7 avoid conflicting designs.
8
9 On the left are DOM classes and methods and on the right are
10 equivalent XML::Grove classes, methods, and notes. Equivalents marked
11 with an asterisk (*) are available with the XML::Grove extensions
12 Data::Grove::Parent, XML::Grove::Normalize, or
13 XML::Grove::GetElementsByTagName.
14
15 DOMImplementation No Equivalent
16 boolean hasFeature(feature, version)
17
18 DocumentFragment Any XML::Grove object can be
19 a document fragment.
20
21 Document XML::Grove::Document
22 doctype not yet implemented
23 implementation not yet implemented
24 documentElement $grove->root (*)
25 createXXX XXX->new
26 getElementsByTagName $grove->get_elements_by_tag_name (*)
27
28 `Node' in DOM is a superclass of all other nodes in DOM, `XML::Grove'
29 is the superclass of all objects in the XML::Grove module.
30
31 Node XML::Grove
32 nodeName $element->{Name}
33 nodeValue $element->{Value}
34 nodeType use `ref()' and pattern matching
35 (match /.*::TYPE(::.*)?$/)
36 parentNode $obj->{Parent} (*)
37 childNodes $obj->{Contents}
38 firstChild $obj->{Contents}[0]
39 lastChild $obj->{Contents}[-1]
40 previousSibling no equivalent
41 nextSibling no equivalent
42 attributes $element->{Attributes}
43 ownerDocument $obj->root->{Parent} (*)
44 insertBefore splice(@{$node->{Contents}},
45 $index, 0, $new_child)
46 replaceChild splice(@{$node->{Contents}},
47 $index, 1, $new_child)
48 removeChild splice(@{$node->{Contents}},
49 $index, 1)
50
51 appendChild push(@{$node->{Contents}}, $new_child)
52 hasChildNodes $#{$node->{Contents}} != -1
53 cloneNode $new = $obj->clone()
54
55 NodeList NodeLists are Perl arrays
56
57 NamedNodeMap NamedNodeMap are Perl hashes
58
59 CharacterData
60 data $characters->{Data}
61
62 Attr Attr are stored in Perl hashes,
63 unspecified values are undef
64
65 Element XML::Grove::Element
66 getAttribute $element->{Attributes}{$name}
67 setAttribute $element->{Attributes}{$name} = $value
68 removeAttribute undef $element{Attributes}{$name}
69 getAttributeNode no equivalent
70 setAttributeNode no equivalent
71 removeAttributeNode delete $element{Attributes}{$name}
72 getElementsByTagName $elem->get_elements_by_tag_name (*)
73 normalize $elem->normalize (*)
74
75 Text
76 data $characters->{Data}
77
78 Comment XML::Grove::Comment
79 data $comment->{Data}
80
81 CDATASection XML::Grove::CData
82
83 DocumentType see XML::Grove::Document
84
85 Notation XML::Grove::Notation
86 nodeName $notation->{Name}
87 publicId $notation->{PublicId}
88 systemId $notation->{SystemId}
89
90 Entity XML::Grove::ExtEntity
91 nodeName $ext_entity->{Name}
92 publicId $ext_entity->{PublicId}
93 systemId $ext_entity->{SystemId}
94 notationName $ext_entity->{Notation}{Name}
95
96 EntityReference XML::Grove::Entity
97 nodeName $entity->{Name}
98 nodeValue $entity->{Data}
99
100 ProcessingInstruction XML::Grove::PI
101 target $pi->{Target}
102 data $pi->{Data}