blob: ef3324db227ecc5fb420a049b758265964cff3dc [file]
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
"http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">
<!--
Copyright 2002 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- ====================================================================== -->
<!-- Modification of tspan children -->
<!-- -->
<!-- @author nicolas.socheleau@bitflash.com -->
<!-- @version $Id$ -->
<!-- ====================================================================== -->
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
<svg id="body" width="450" height="500" viewBox="0 0 450 500">
<title>&lt;tspan&gt; children 'onload'</title>
<text x="50%" y="45" class="title">&lt;tspan&gt; children in 'onload'</text>
<script type="text/ecmascript"><![CDATA[
function addText(evt){
insertText(evt,'the quick ','tspan1');
appendText(evt,'fox');
}
function addCDATAText(evt){
insertCDATAText(evt,'the quick ','tspan2');
appendCDATAText(evt,'fox');
}
function insertText(evt,text,nextsiblingID) {
var elt = evt.target;
var doc = elt.getOwnerDocument();
var next = doc.getElementById(nextsiblingID);
var textnode = doc.createTextNode(text);
elt.insertBefore(textnode,next);
}
function insertCDATAText(evt,text,nextsiblingID) {
var elt = evt.target;
var doc = elt.getOwnerDocument();
var next = doc.getElementById(nextsiblingID);
var textnode = doc.createCDATASection(text);
elt.insertBefore(textnode,next);
}
function appendText(evt, text){
var elt = evt.target;
var doc = elt.getOwnerDocument();
var textnode = doc.createTextNode(text);
elt.appendChild(textnode);
}
function appendCDATAText(evt, text){
var elt = evt.target;
var doc = elt.getOwnerDocument();
var textnode = doc.createCDATASection(text);
elt.appendChild(textnode);
}
function removeText(evt) {
var elt = evt.target;
while ( elt.hasChildNodes() ){
var child = elt.getFirstChild();
elt.removeChild( child )
}
}
]]>
</script>
<g id="test-content">
<g style="font-size:40" >
<text><tspan x="70" y="135" style="fill:orange"
onload="addText(evt)" >
<tspan id="tspan1" onload="appendText(evt,'brown')" style="fill:brown"></tspan>
</tspan></text>
<text><tspan x="70" y="175" style="fill:orange"
onload="addCDATAText(evt)" >
<tspan id="tspan2" onload="appendCDATAText(evt,'brown')" style="fill:brown"></tspan>
</tspan></text>
<text><tspan x="70" y="335" style="fill:gold"
onload="removeText(evt)" >
the quick brown fox
</tspan></text>
<text><tspan x="70" y="375" style="fill:gold"
onload="removeText(evt)" ><![CDATA[
the quick brown fox
]]></tspan></text>
</g>
<g style="stroke:black;fill:none;stroke-width:1;font-size:40">
<text><tspan x="70" y="135">
the quick <tspan>brown</tspan> fox
</tspan></text>
<text><tspan x="70" y="175">
the quick <tspan>brown</tspan> fox
</tspan></text>
<text><tspan x="70" y="335">
the quick brown fox
</tspan></text>
<text><tspan x="70" y="375">
the quick brown fox
</tspan></text>
</g>
<g style="fill:black; stroke:none; text-anchor:middle">
<text x="225" y="230" >insert nodes
<tspan style="font-size:8">( TEXT_NODE and CDATA_SECTION_NODE )</tspan>
</text>
<text x="225" y="430" >remove nodes
<tspan style="font-size:8">( TEXT_NODE and CDATA_SECTION_NODE )</tspan>
</text>
</g>
</g>
</svg>