Debian Codegraph @

samples/tests/spec/scripting/text_children1.svg

raw
1 <?xml version="1.0" standalone="no"?>
2 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
3 "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">
4
5 <!--
6
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
21
22 -->
23 <!-- ====================================================================== -->
24 <!-- Modification of text children -->
25 <!-- -->
26 <!-- @author [email protected] -->
27 <!-- @version $Id$ -->
28 <!-- ====================================================================== -->
29
30 <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
31
32 <svg id="body" width="450" height="500" viewBox="0 0 450 500">
33 <title>&lt;text&gt; children 'onload'</title>
34
35 <text x="50%" y="45" class="title">&lt;text&gt; children in 'onload'</text>
36
37 <script type="text/ecmascript"><![CDATA[
38 function addText(evt){
39 insertText(evt,'the quick ','tspan1');
40 appendText(evt,'fox');
41 }
42
43 function addCDATAText(evt){
44 insertCDATAText(evt,'the quick ','tspan2');
45 appendCDATAText(evt,'fox');
46 }
47
48 function insertText(evt,text,nextsiblingID) {
49
50 var elt = evt.target;
51 var doc = elt.getOwnerDocument();
52
53 var next = doc.getElementById(nextsiblingID);
54
55 var textnode = doc.createTextNode(text);
56
57 elt.insertBefore(textnode,next);
58 }
59
60 function insertCDATAText(evt,text,nextsiblingID) {
61
62 var elt = evt.target;
63 var doc = elt.getOwnerDocument();
64
65 var next = doc.getElementById(nextsiblingID);
66
67 var textnode = doc.createCDATASection(text);
68
69 elt.insertBefore(textnode,next);
70 }
71
72 function appendText(evt, text){
73 var elt = evt.target;
74 var doc = elt.getOwnerDocument();
75
76 var textnode = doc.createTextNode(text);
77
78 elt.appendChild(textnode);
79 }
80
81 function appendCDATAText(evt, text){
82 var elt = evt.target;
83 var doc = elt.getOwnerDocument();
84
85 var textnode = doc.createCDATASection(text);
86
87 elt.appendChild(textnode);
88 }
89
90 function removeText(evt) {
91 var elt = evt.target;
92
93 while ( elt.hasChildNodes() ){
94
95 var child = elt.getFirstChild();
96
97 elt.removeChild( child )
98 }
99 }
100
101 ]]>
102 </script>
103
104 <g id="test-content">
105 <g style="font-size:40" >
106
107 <text x="70" y="135" style="fill:orange"
108 onload="addText(evt)" >
109 <tspan id="tspan1" onload="appendText(evt,'brown')" style="fill:brown"></tspan>
110 </text>
111
112 <text x="70" y="175" style="fill:orange"
113 onload="addCDATAText(evt)" >
114 <tspan id="tspan2" onload="appendCDATAText(evt,'brown')" style="fill:brown"></tspan>
115 </text>
116
117 <text x="70" y="335" style="fill:gold"
118 onload="removeText(evt)" >
119 the quick brown fox
120 </text>
121 <text x="70" y="375" style="fill:gold"
122 onload="removeText(evt)" ><![CDATA[
123 the quick brown fox
124 ]]></text>
125
126 </g>
127
128 <g style="stroke:black;fill:none;stroke-width:1;font-size:40">
129 <text x="70" y="135">
130 the quick <tspan>brown</tspan> fox
131 </text>
132 <text x="70" y="175">
133 the quick <tspan>brown</tspan> fox
134 </text>
135 <text x="70" y="335">
136 the quick brown fox
137 </text>
138 <text x="70" y="375">
139 the quick brown fox
140 </text>
141 </g>
142
143 <g style="fill:black; stroke:none; text-anchor:middle">
144 <text x="225" y="230" >insert nodes
145 <tspan style="font-size:8">( TEXT_NODE and CDATA_SECTION_NODE )</tspan>
146 </text>
147 <text x="225" y="430" >remove nodes
148 <tspan style="font-size:8">( TEXT_NODE and CDATA_SECTION_NODE )</tspan>
149 </text>
150 </g>
151 </g>
152 </svg>