1 <?xml version=
"1.0" encoding=
"utf-8" standalone=
"no"?>
2 <!DOCTYPE svg PUBLIC
"-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3 <!--======================================================================-->
4 <!--= Copyright 2000 World Wide Web Consortium, (Massachusetts =-->
5 <!--= Institute of Technology, Institut National de Recherche en =-->
6 <!--= Informatique et en Automatique, Keio University). All Rights =-->
7 <!--= Reserved. See http://www.w3.org/Consortium/Legal/. =-->
8 <!--======================================================================-->
9 <!-- ===================================================================== -->
11 <!-- extend-multiNS-BE-01.svg -->
12 <!-- renamed for 1.1 suite to extend-namespace-01-f -->
14 <!-- Test the use of multiple namespaces. -->
15 <!-- Revised for 1.1: Chris Lilley, 15 Mar 2002 -->
17 <!-- Author : Jon Ferraiolo 06-Aug-2000 -->
18 <!-- Revised for 1.1 : Chris Lilley 14-Mar-2002 -->
19 <!--======================================================================-->
20 <svg version=
"1.1" xmlns=
"http://www.w3.org/2000/svg" xmlns:
xlink=
"http://www.w3.org/1999/xlink" id=
"svg-root" width=
"480" height=
"360" viewBox=
"0 0 480 360" onload=
"onLoad(evt)">
21 <SVGTestCase xmlns=
"http://www.w3.org/2000/02/svg/testsuite/description/">
23 <Paragraph>Test mixing a business data namespace with elements in SVG namespace.
25 <Paragraph>The test case uses a different namespace to hold fake sales data.
26 Using ECMAScript to make calls to the DOM, the test case extracts
27 the sales data and then makes calls to the SVG DOM to build up
28 a 'path' element and a 'text' element for each individual pie slice.
30 <Paragraph>The result should show four pie slices.
31 The first pie slice should be exploded, with a pink fill and a blue border.
32 The other pie slices should have various levels of gray fill and black borders.
33 The name of each region should appear in black towards the center of
38 <title id=
"test-title">extend-namespace-
01-f
</title>
40 Test the use of multiple namespaces.
42 <!--======================================================================-->
43 <!--Content of Test Case follows... =====================-->
44 <!--======================================================================-->
45 <g id=
"test-body-content">
46 <g xmlns:
bd=
"http://example.org/ExampleBusinessData">
48 <script type=
"text/ecmascript"><![CDATA[
49 var svg_ns =
"http://www.w3.org/2000/svg";
50 var bd_ns =
"http://example.org/ExampleBusinessData";
53 var svgElement = evt.target;
54 var doc = svgElement.ownerDocument;
56 var resultsElement = doc.getElementById('results');
57 var gElement = doc.getElementById('PieParent');
59 // Count the number of regions.
60 RegionNodeList = doc.getElementsByTagNameNS(bd_ns,
"Region");
61 regionCount = RegionNodeList.length;
63 // Get the region data.
64 RegionNameNodeList = doc.getElementsByTagNameNS(bd_ns,
"RegionName");
65 RegionResultNodeList = doc.getElementsByTagNameNS(bd_ns,
"RegionResult");
67 // Get the sum of the values of the regions.
69 for (regionIndex =
0; regionIndex < regionCount; regionIndex++)
70 total = total + Number(RegionResultNodeList.item(regionIndex).firstChild.nodeValue);
74 for (regionIndex =
0; regionIndex < regionCount; regionIndex++) {
75 regionName = RegionNameNodeList.item(regionIndex).firstChild.nodeValue;
76 regionResult = Number(RegionResultNodeList.item(regionIndex).firstChild.nodeValue);
78 // Build the pie slice.
79 textElement = doc.createElementNS(svg_ns,
"text");
80 textNode = doc.createTextNode(regionName);
81 textElement.appendChild(textNode);
82 pathElement = doc.createElementNS(svg_ns,
"path");
84 endAngle = startAngle - regionResult * Math.PI *
2 / total;
85 dAttribute =
"M240,170 L";
86 gray = Math.round(Number(
255 * (regionIndex+
2)) / (regionCount+
2));
87 midAngle = (startAngle + endAngle) /
2;
88 textElement.setAttributeNS(null,
"x", Math.round(
240+
65*Math.cos(midAngle)));
89 textElement.setAttributeNS(null,
"y", Math.round(
170+
65*Math.sin(midAngle)));
91 dAttribute = dAttribute + Math.round(
240+
100*Math.cos(startAngle));
92 dAttribute = dAttribute + ',';
93 dAttribute = dAttribute + Math.round(
170+
100*Math.sin(startAngle));
94 dAttribute = dAttribute + ' A100,
100 0 0,
0 ';
95 dAttribute = dAttribute + Math.round(
240+
100*Math.cos(endAngle));
96 dAttribute = dAttribute + ',';
97 dAttribute = dAttribute + Math.round(
170+
100*Math.sin(endAngle));
98 dAttribute = dAttribute + 'z';
99 pathElement.setAttributeNS(null,
"d", dAttribute);
100 pathElement.setAttributeNS(null,
"fill",
"rgb("+gray+
","+gray+
","+gray+
")");
101 pathElement.setAttributeNS(null,
"stroke",
"black");
102 pathElement.setAttributeNS(null,
"stroke-width",
"2");
104 // Temporary, for CSS styling.
105 pathElement.setAttributeNS(null,
"fill",
"rgb("+gray+
","+gray+
","+gray+
")");
106 pathElement.setAttributeNS(null,
"stroke",
"black");
107 pathElement.setAttributeNS(null,
"stroke-width",
"2");
109 if (regionIndex ==
0) {
110 var firstSliceOffset =
30;
111 var transformValue =
"translate(" +
112 Math.round(firstSliceOffset * Math.cos(midAngle)) +
114 Math.round(firstSliceOffset * Math.sin(midAngle)) +
116 pathElement.setAttributeNS(null,
"transform", transformValue);
117 textElement.setAttributeNS(null,
"transform", transformValue);
118 pathElement.setAttributeNS(null,
"fill",
"#FF6666");
119 pathElement.setAttributeNS(null,
"stroke",
"#0000FF");
120 pathElement.setAttributeNS(null,
"stroke-width",
"3");
122 // Temporary, for CSS styling.
123 pathElement.setAttributeNS(null,
"fill",
"#FF8888");
124 pathElement.setAttributeNS(null,
"stroke",
"#0000FF");
125 pathElement.setAttributeNS(null,
"stroke-width",
"3");
128 gElement.appendChild(pathElement);
129 gElement.appendChild(textElement);
130 startAngle = endAngle;
135 <bd:Results id=
"results">
137 <bd:RegionName>East
</bd:RegionName>
138 <bd:RegionResult>3</bd:RegionResult>
141 <bd:RegionName>North
</bd:RegionName>
142 <bd:RegionResult>4</bd:RegionResult>
145 <bd:RegionName>West
</bd:RegionName>
146 <bd:RegionResult>5</bd:RegionResult>
149 <bd:RegionName>Central
</bd:RegionName>
150 <bd:RegionResult>3.2</bd:RegionResult>
153 <bd:RegionName>South
</bd:RegionName>
154 <bd:RegionResult>6</bd:RegionResult>
157 <text font-family=
"Arial" font-size=
"16" text-anchor=
"middle" x=
"240" y=
"30">
158 Pie chart built from data in a different namespace.
161 <g id=
"PieParent" font-family=
"Arial" text-anchor=
"middle" font-size=
"14">
162 <desc>Pie chart is built within this 'g' element
</desc>
165 <text id=
"revision" x=
"10" y=
"340" font-size=
"40" stroke=
"none" fill=
"black">$Revision:
1.3 $
</text>
166 <rect id=
"test-frame" x=
"1" y=
"1" width=
"478" height=
"358" fill=
"none" stroke=
"#000000"/>