1SVG::DOM(3)           User Contributed Perl Documentation          SVG::DOM(3)
2
3
4

NAME

6       SVG::DOM - A library of DOM (Document Object Model) methods for SVG
7       objects.
8

SUMMARY

10       SVG::DOM provides a selection of methods for accessing and manipulating
11       SVG elements through DOM-like methods such as getElements, getChildren,
12       getNextSibling and so on.
13

SYNOPSIS

15           my $svg=new SVG(id=>"svg_dom_synopsis", width=>"100", height=>"100");
16           my %attributes=$svg->getAttributes;
17
18           my $group=$svg->group(id=>"group_1");
19           my $name=$group->getElementName;
20           my $id=$group->getElementID;
21
22           $group->circle(id=>"circle_1", cx=>20, cy=>20, r=>5, fill=>"red");
23           my $rect=$group->rect(id=>"rect_1", x=>10, y=>10, width=>20, height=>30);
24           my $width=$rect->getAttribute("width");
25
26           my $has_children=$group->hasChildren();
27           my @children=$group->getChildren();
28
29           my $kid=$group->getFirstChild();
30           do {
31               print $kid->xmlify();
32           } while ($kid=$kid->getNextSibling);
33
34           my @ancestors=$rect->getParents();
35           my $is_ancestor=$group->isAncestor($rect);
36           my $is_descendant=$rect->isDescendant($svg);
37
38           my @rectangles=$svg->getElements("rect");
39           my $allelements_arrayref=$svg->getElements();
40
41               $group->insertBefore($newChild,$rect);
42               $group->insertAfter($newChild,$rect);
43               $rect = $group->replaceChild($newChild,$rect);
44               $group->removeChild($newChild);
45               my $newRect = $rect->cloneNode($deep);
46
47           ...and so on...
48

METHODS

50       @elements = $obj->getElements($element_name)
51
52       Return a list of all elements with the specified name (i.e. type) in
53       the document. If no element name is provided, returns a list of all
54       elements in the document.  In scalar context returns an array refer‐
55       ence.
56
57       @children = $obj->getChildren()
58
59       Return a list of all children defined on the current node, or undef if
60       there are no children.  In scalar context returns an array reference.
61
62       Alias: getChildElements(), getChildNodes()
63
64       @children = $obj->hasChildren()
65
66       Return 1 if the current node has children, or 0 if there are no chil‐
67       dren.
68
69       Alias: hasChildElements, hasChildNodes()
70
71       $ref = $obj->getFirstChild()
72
73       Return the first child element of the current node, or undef if there
74       are no children.
75
76       $ref = $obj->getLastChild()
77
78       Return the last child element of the current node, or undef if there
79       are no children.
80
81       $ref = $obj->getSiblings()
82
83       Return a list of all children defined on the parent node, containing
84       the current node.
85
86       $ref = $obj->getNextSibling()
87
88       Return the next child element of the parent node, or undef if this is
89       the last child.
90
91       $ref = $obj->getPreviousSibling()
92
93       Return the previous child element of the parent node, or undef if this
94       is the first child.
95
96       $index = $obj->getChildIndex()
97
98       Return the place of this element in the parent node's list of children,
99       starting from 0.
100
101       $element = $obj->getChildAtIndex($index)
102
103       Returns the child element at the specified index in the parent node's
104       list of children.
105
106       $ref = $obj->getParentElement()
107
108       Return the parent of the current node.
109
110       Alias: getParent()
111
112       @refs = $obj->getParentElements()
113
114       Return a list of the parents of the current node, starting from the
115       immediate parent. The last member of the list should be the document
116       element.
117
118       Alias: getParents()
119
120       $name = $obj->getElementName()
121
122       Return a string containing the name (i.e. the type, not the ID) of an
123       element.
124
125       Alias: getType(), getTagName(), getNodeName()
126
127       $ref = $svg->getElementByID($id)
128
129       Alias: getElementbyID()
130
131       Return a reference to the element which has ID $id, or undef if no ele‐
132       ment with this ID exists.
133
134       $id = $obj->getElementID()
135
136       Return a string containing the ID of the current node, or undef if it
137       has no ID.
138
139       $ref = $obj->getAttributes()
140
141       Return a hash reference of attribute names and values for the current
142       node.
143
144       $value = $obj->getAttribute($name);
145
146       Return the string value attribute value for an attribute of name $name.
147
148       $ref = $obj->setAt‐
149       tributes({name1=>$value1,name2=>undef,name3=>$value3})
150
151       Set a set of attributes. If $value is undef, deletes the attribute.
152
153       $value = $obj->setAttribute($name,$value);
154
155       Set attribute $name to $value. If $value is undef, deletes the
156       attribute.
157
158       $cdata = $obj->getCDATA()
159
160       Return the cannonical data (i.e. textual content) of the current node.
161
162       Alias: getCdata(), getData()
163
164       $boolean = $obj->isAncestor($element)
165
166       Returns 1 if the current node is an ancestor of the specified element,
167       otherwise 0.
168
169       $boolean = $obj->isDescendant($element)
170
171       Returns 1 if the current node is a descendant of the specified element,
172       otherwise 0.
173
174       $boolean = $obj->insertBefore( $element, $child );
175
176       Returns 1 if $element was successfully inserted before $child in $obj
177
178       $boolean = $obj->insertAfter( $element, $child );
179
180       Returns 1 if $element was successfully inserted after $child in $obj
181
182       $boolean = $obj->insertSiblingBefore( $element );
183
184       Returns 1 if $element was successfully inserted before $obj
185
186       $boolean = $obj->insertSiblingAfter( $element );
187
188       Returns 1 if $element was successfully inserted after $obj
189
190       $element = $obj->replaceChild( $element, $child );
191
192       Returns $child if $element successfully replaced $child in $obj
193
194       $element = $obj->removeChild( $child );
195
196       Returns $child if it was removed successfully from $obj
197
198       $element = $obj->cloneNode( $deep );
199
200       Returns a new $element clone of $obj, includes children if deep = 1
201

AUTHOR

203       Ronan Oger, ronan@roitsystems.com Martin Owens, doctormo@postmas‐
204       ter.co.uk
205

SEE ALSO

207       perl(1), SVG, SVG::XML, SVG::Element, SVG::Parser, SVG::Manual
208
209       <http://www.roitsystems.com/> ROIT Systems: Commercial SVG perl solu‐
210       tions <http://www.w3c.org/Graphics/SVG/> SVG at the W3C
211
212
213
214perl v5.8.8                       2008-04-21                       SVG::DOM(3)
Impressum