Revision control
Copy as Markdown
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.2" baseProfile="tiny" xml:id="svg-root" width="100%" height="100%"
<handler type="application/ecmascript" xe:event="SVGLoad">
initTest(evt);
</handler>
<!--======================================================================-->
<!--= Copyright 2008 World Wide Web Consortium, (Massachusetts =-->
<!--= Institute of Technology, European Research Consortium for =-->
<!--= Informatics and Mathematics (ERCIM), Keio University). =-->
<!--= All Rights Reserved. =-->
<!--======================================================================-->
reviewer="AE" owner="CL" desc="test id and xml:id modification" status="accepted"
approved="yes"
version="$Revision: 1.8 $" testname="$RCSfile: struct-common-201-t.svg,v $">
<d:OperatorScript xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/" xmlns="http://www.w3.org/1999/xhtml">
<p>
Tests that reading of IDs and modification of id and xml:id is conformant to the SVG and xml:id specifications. The test passes if four green circles are shown.
</p>
<p>
The first circle has an id only; the second, xml:id only. The third circle has both, with the same values; and the fourth has both, with different values. All four circles have a red fill; on loading the document, a script
gets each of the circles by its ID and then sets the fill to green. Lastly, the script attempts
to get the fourth circle by ID, using the value of the id attribute; this must fail. If the fourth
circle is dark red, the implementation is not giving priority to the value of xml:id.
</p>
</d:OperatorScript>
</SVGTestCase>
<title xml:id="test-title">$RCSfile: struct-common-201-t.svg,v $</title>
<defs>
<font-face
font-family="SVGFreeSansASCII"
unicode-range="U+0-7F">
<font-face-src>
<font-face-uri xlink:href="../images/SVGFreeSans.svg#ascii"/>
</font-face-src>
</font-face>
</defs>
<g xml:id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
<script type="application/ecmascript">
<![CDATA[
var doc;
var oldid;
var newid;
var bothids;
var different;
//
// onload handler for top level svg element.
//
function initTest(evt)
{
// Get Document
var target = evt.target;
doc = target.ownerDocument;
// Get elements identified by id, by xml:id, and by both
oldid = doc.getElementById("cod");
newid= doc.getElementById("plaice");
bothids= doc.getElementById("flounder");
different= doc.getElementById("mackerel");
//Make all four elements green
oldid.setAttribute("fill", "green");
newid.setAttribute("fill", "green");
bothids.setAttribute("fill", "green");
different.setAttribute("fill", "green");
//Try to select on id, should fail
different= doc.getElementById("herring");
different.setAttribute("fill", "#700");
}
]]>
</script>
<circle cx="60" cy="100" r="50" fill="red" id="cod"/>
<circle cx="180" cy="100" r="50" fill="red" xml:id="plaice" />
<circle cx="300" cy="100" r="50" fill="red" id="flounder" xml:id="flounder"/>
<circle cx="420" cy="100" r="50" fill="red" id="herring" xml:id="mackerel"/>
<g font-family="SVGFreeSansASCII,sans-serif" font-size="16" text-anchor="middle">
<text x="60" y="190">id only</text>
<text x="180" y="190">xml:id only</text>
<text x="300" y="190">id and</text>
<text x="300" y="210">xml:id, same</text>
<text x="300" y="230">values</text>
<text x="420" y="190">id and</text>
<text x="420" dy="210">xml:id, different</text>
<text x="420" dy="230">values</text>
</g>
</g>
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
<text xml:id="revision" x="10" y="340" stroke="none"
fill="black">$Revision: 1.8 $</text>
</g>
<rect xml:id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
<!-- comment out this watermark once the test is approved -->
<!--
<g xml:id="draft-watermark">
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/>
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240"
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text>
</g>
-->
</svg>