Debian Codegraph @

documentation-sources/content/xdocs/dev/svg12.xml

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!--
4
5 Licensed to the Apache Software Foundation (ASF) under one or more
6 contributor license agreements. See the NOTICE file distributed with
7 this work for additional information regarding copyright ownership.
8 The ASF licenses this file to You under the Apache License, Version 2.0
9 (the "License"); you may not use this file except in compliance with
10 the License. You may obtain a copy of the License at
11
12 http://www.apache.org/licenses/LICENSE-2.0
13
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
19
20 -->
21
22 <!-- ========================================================================= -->
23 <!-- author [email protected] -->
24 <!-- version $Id$ -->
25 <!-- ========================================================================= -->
26
27 <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
28 <document>
29 <header>
30 <title>SVG 1.2 support</title>
31 </header>
32
33 <body>
34 <p>
35 This page details information atbout Batik’s implementation of
36 features from SVG 1.2, <a href="site:svg12t">Tiny</a> and
37 <a href="site:svg12">Full</a>. Note that the information on
38 this page is based on the code in the Subversion repository
39 trunk.
40 </p>
41
42 <section id="dom3">
43 <title>DOM Level 3</title>
44 <p>
45 DOM Level 3 <a href="site:dom3core">Core</a>,
46 <a href="site:dom3ev">Events</a> and <a href="site:dom3xpath">XPath</a>
47 are all supported. These features are available regardless of whether
48 the document has <code>version="1.1"</code> or
49 <code>version="1.2"</code> set on the root <code>svg</code> element.
50 </p>
51 <p>
52 There are a few issues with the DOM Level 3 Core implementation:
53 </p>
54 <ol>
55 <li>
56 The <code>Document.compareDocumentPosition</code> method does not give
57 the correct result when used on DTD notation or entity nodes in the
58 document.
59 </li>
60 <li>
61 <code>Node.renameNode</code> always creates a new node and replaces
62 the old node with it. This is technically allowed, but sub-optimal.
63 </li>
64 <li>
65 XML Schema information is never used. Batik does not implement XML
66 Schema, so any methods or attributes that would utilise or expose
67 schema information (such as the <code>schemaTypeInfo</code> attribute
68 on the <code>Attr</code> and <code>Element</code> interfaces) do not
69 do so.
70 </li>
71 <li>
72 <code>Document.normalizeDocument</code> ignores the
73 <code>"entities"</code> parameter in the document’s
74 <code>DOMConfiguration</code>.
75 </li>
76 </ol>
77
78 <section id="dom3java">
79 <title>Using DOM Level 3 functionality from Java</title>
80 <p>
81 JREs before 1.5 include the DOM Level 2 interfaces and this can cause
82 problems when trying to use the DOM Level 3 versions of these same interface
83 files (<code>org.w3c.dom.*</code>). Though the concrete Batik DOM
84 classes implement the DOM Level 3 functionality, you won’t be able to access
85 those methods through the <code>org.w3c.dom</code> interfaces on these
86 earlier JREs.
87 </p>
88 <p>
89 There are two ways to overcome this problem. The first
90 is to install the DOM Level 3 interfaces using the
91 <a href="http://java.sun.com/j2se/1.4.2/docs/guide/standards/">Endorsed
92 Standards Override Mechanism</a>. Copy the file
93 <code>lib/xml-apis-ext.jar</code> into the endorsed standards override
94 directory and the DOM Level 3 interfaces will be visible. You can then write
95 code against them (for example, call <code>Document.renameNode</code>
96 directly). However, this will mean that other people cannot run or
97 compile your code unless they have JRE 1.5 or later, or they have also
98 installed the <code>xml-apis-ext.jar</code> in the same way.
99 </p>
100 <p>
101 The second method, which requires less messing about with the JRE, is
102 to cast your DOM objects to the concrete Batik DOM objects and call
103 your DOM Level 3 methods directly on them. The Batik DOM classes are in the
104 <code>org.apache.batik.dom</code> package. The classes named
105 <code>Abstract*</code> implement the DOM interfaces, and also contain
106 the DOM Level 3 methods. The advantage of this method is that for your code
107 to compile and run in others’ environments, they need not install any
108 jars with the endorsed standards overrides.
109 </p>
110 <p>
111 Here is an example of using the second method to get access to DOM
112 Level 3 specific methods:
113 </p>
114 <source>import org.apache.batik.dom.AbstractDocument;
115 import org.apache.batik.dom.svg.SVGDOMImplementation;
116
117 import org.w3c.dom.DOMImplementation;
118 import org.w3c.dom.Document;
119 import org.w3c.dom.Element;
120
121 public class C {
122 public void f() {
123 // Create a new SVG document
124 DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
125 Document doc = impl.createDocument("http://www.w3.org/2000/svg", "svg", null);
126
127 // Create a 'g' element and append it to the root 'svg' element
128 Element e = doc.createElementNS("http://www.w3.org/2000/svg", "g");
129 doc.getDocumentElement().appendChild(e);
130
131 // Cast the document object to org.apache.batik.dom.AbstractDocument,
132 // so that DOM 3 methods will be guaranteed to be visible
133 <strong>AbstractDocument document = (AbstractDocument) doc;</strong>
134
135 // Now a DOM 3 method can be used
136 <strong>document.renameNode(e, "http://www.w3.org/2000/svg", "text");</strong>
137 }
138 }</source>
139
140 <p>
141 For cases where the DOM Level 3 versions of these interfaces contain
142 constants that you wish to use, the constants have been copied into
143 the Batik DOM classes. For example:
144 </p>
145
146 <source>import org.apache.batik.dom.AbstractNode;
147 import org.apache.batik.dom.svg.SVGDOMImplementation;
148
149 import org.w3c.dom.DOMImplementation;
150 import org.w3c.dom.Document;
151 import org.w3c.dom.Element;
152
153 public class C {
154 public void f() {
155 // Create a new SVG document
156 DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
157 Document doc = impl.createDocument("http://www.w3.org/2000/svg", "svg", null);
158
159 // Create a 'g' element and append it to the root 'svg' element
160 Element svg = doc.getDocumentElement();
161 Element e = doc.createElementNS("http://www.w3.org/2000/svg", "g");
162 svg.appendChild(e);
163
164 AbstractNode n1 = (AbstractNode) svg;
165 AbstractNode n2 = (AbstractNode) e;
166 int position = n1.compareDocumentPosition(n2);
167 if (position == <strong>AbstractNode.DOCUMENT_POSITION_PRECEDING</strong>
168 | <strong>AbstractNode.DOCUMENT_POSITION_CONTAINS</strong>) {
169 System.out.println("The svg element contains the g element.");
170 } else {
171 System.out.println("Something is wrong!");
172 }
173 }
174 }</source>
175
176 <p>
177 Note that using these org.apache.batik.dom interfaces is only needed
178 for the DOM Level 3 Core and Events interfaces. There were no earlier
179 versions of the DOM XPath interfaces to conflict with, so these can be
180 used directly (<code>org.w3c.dom.xpath</code>).
181 </p>
182 <p>
183 Of course, none of this matters if you are just using the DOM 3
184 functionality in ECMAScript, as the matter of interfaces is hidden
185 from the scripting environment.
186 </p>
187 </section>
188 </section>
189
190 <section id="sxbl">
191 <title>XML Binding Language for SVG (sXBL)</title>
192 <p>
193 sXBL is supported in documents with <code>version="1.2"</code>. However,
194 the following issues exist:
195 </p>
196 <ol>
197 <li>
198 sXBL cannot be used for
199 <a href="http://www.w3.org/TR/2004/WD-SVG12-20041027/binding.html#sXBL-bindings-for-svg">SVG
200 resources</a> or
201 <a href="http://www.w3.org/TR/2004/WD-SVG12-20041027/binding.html#sXBL-bindings-for-visual-effects">visual
202 effects</a>.
203 </li>
204 <li>
205 The <code>traitDef</code> element is not implemented.
206 </li>
207 <li>
208 The <a href="http://www.w3.org/TR/sXBL/#shadow0">handling of CSS</a>
209 is probably not quite correct.
210 </li>
211 </ol>
212 <p>
213 Two content selector languages are supported: XPath 1.0 Patterns and the
214 drastically reduced XPath subset. XPath Patterns is the default
215 language. To change the language used to the XPath subset, put an
216 attribute <code>batik:selectorLanguage="XPathSubset"</code> on the
217 <code>xbl:content</code> element or on the <code>svg</code> document
218 element. (The <code>batik</code> extension namespace prefix should be
219 declared with
220 <code>xmlns:batik="http://xml.apache.org/batik/ext"</code>.)
221 </p>
222 <p>
223 Note that sXBL is likely to be dropped in favor of
224 <a href="http://www.w3.org/TR/xbl2">XBL 2.0</a> in
225 <a href="site:svg12">SVG 1.2 Full</a>.
226 </p>
227 </section>
228
229 <section id="flowtext">
230 <title>Flowing text and graphics</title>
231 <p>
232 The <code>flowRoot</code>, <code>flowRegion</code>,
233 <code>flowDiv</code>, <code>flowPara</code>, <code>flowSpan</code>,
234 <code>flowRegionBreak</code> and <code>flowLine</code> elements
235 from <a href="site:svg12">SVG 1.2 Full</a>’s
236 <a href="http://www.w3.org/TR/2004/WD-SVG12-20041027/flow.html">Flowing
237 Text and Graphics</a> chapter are supported in documents with
238 <code>version="1.2"</code>.
239 </p>
240 <p>
241 The more recent <a href="site:svg12t">SVG 1.2 Tiny</a> draft specifies
242 a different syntax for (a more restricted version of) flowing text,
243 and the full flowing text syntax is therefore likely to change.
244 </p>
245 </section>
246
247 <section id="other">
248 <title>Other SVG 1.2 features</title>
249 <p>
250 The following other features from SVG 1.2 are supported:
251 </p>
252 <ul>
253 <li>
254 the <a href="http://www.w3.org/TR/SVGTiny12/painting.html#SolidColorElement"><code>solidColor</code>
255 paint server element,</a>
256 </li>
257 <li>
258 the <code>multiImage</code>, <code>subImageRef</code> and
259 <code>subImage</code> elements for
260 <a href="http://www.w3.org/TR/2004/WD-SVG12-20041027/media.html#multires">Alternate
261 content based on display resolutions</a>,
262 </li>
263 <li>
264 the XML Events
265 <a href="http://www.w3.org/TR/SVGTiny12/script.html#HandlerElement"><code>handler</code>
266 element</a>,
267 </li>
268 <li>
269 self-contained
270 <a href="http://www.w3.org/TR/2004/WD-SVG12-20041027/nonvisual.html#external-references">resource
271 documents</a>,
272 </li>
273 <li>
274 the mouse
275 <a href="http://www.w3.org/TR/2004/WD-SVG12-20041027/dom.html#wheelevent">wheel
276 event</a> (which is likely to be superseded by a similar event
277 developed by the W3C WebAPI WG),
278 </li>
279 <li>
280 the
281 <a href="http://www.w3.org/TR/2004/WD-SVG12-20041027/dom.html#shapemod">ShapeChange
282 and RenderedBBoxChange events</a> (though the
283 <code>boundingBox</code> attribute of the RenderedBBoxChange event is not
284 used), and
285 </li>
286 <li>
287 the <code>startMouseCapture</code> and <code>stopMouseCapture</code>
288 methods on the
289 <a href="http://www.w3.org/TR/2004/WD-SVG12-20041027/api.html#GlobalObject">global
290 object</a>.
291 </li>
292 </ul>
293 </section>
294 </body>
295 </document>