You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by tk...@apache.org on 2001/11/08 10:49:12 UTC
cvs commit: xml-batik/xdocs domTutorial.xml
tkormann 01/11/08 01:49:12
Modified: xdocs domTutorial.xml
Log:
Add a new section to show how to create a SVG DOM tree from a URI, InputStream
or Reader.
Revision Changes Path
1.4 +47 -7 xml-batik/xdocs/domTutorial.xml
Index: domTutorial.xml
===================================================================
RCS file: /home/cvs/xml-batik/xdocs/domTutorial.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- domTutorial.xml 2001/04/15 14:57:06 1.3
+++ domTutorial.xml 2001/11/08 09:49:11 1.4
@@ -11,7 +11,7 @@
<!-- ========================================================================= -->
<!-- author tkormann@apache.org -->
-<!-- version $Id: domTutorial.xml,v 1.3 2001/04/15 14:57:06 tkormann Exp $ -->
+<!-- version $Id: domTutorial.xml,v 1.4 2001/11/08 09:49:11 tkormann Exp $ -->
<!-- ========================================================================= -->
<document>
@@ -74,12 +74,13 @@
<p>
Using the <code>DOMImplementation</code>, you are now able to create a
-<code>Document</code>. The following example illustrate how to create a SVG
-document. Note that the Batik's Document Object Model implementation can be used
-to represent either a SVG document fragment or any kind of XML document. The
-following code shows how to get a concrete <code>Document</code> object using a
-<code>DOMImplementation</code>. Note that by choosing the namespace URI and the
-local name of the root element of SVG, we are creating a SVG document.
+<code>Document</code>. The following example illustrates how to create a SVG
+document. Note that the Batik's Document Object Model implementation can be
+used to represent either a SVG document fragment or any kind of XML
+document. The following code shows how to get a concrete <code>Document</code>
+object using a <code>DOMImplementation</code>. Note that by choosing the
+namespace URI and the local name of the root element of SVG, we are creating a
+SVG document.
</p>
<source>
@@ -101,6 +102,7 @@
</s1>
+
<!-- ##################################################################### -->
<s1 title="Building a SVG Document">
@@ -151,6 +153,44 @@
<rect x="10" y="20" width="100" height="50" style="fill:red"/>
</svg>
</source>
+
+</s1>
+
+<!-- ##################################################################### -->
+<s1 title="Creating a Document from an SVG file">
+
+<p> With Batik, you can also create a SVG DOM tree from a URI, an
+<code>InputStream</code>, or a <code>Reader</code> - using the
+<code>SAXSVGDocumentFactory</code>. The following example illustrates how to
+create a SVG document. Note that the Batik's Document Object Model
+implementation can be used to represent either a SVG document fragment or any
+kind of XML document. The following code shows how to get a concrete
+<code>Document</code> object using the <code>SAXSVGDocumentFactory</code>.
+</p>
+
+<source>
+import java.io.IOException;
+
+import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
+import org.apache.batik.util.XMLResourceDescriptor;
+
+import org.w3c.dom.Document;
+
+try {
+ String parser = XMLResourceDescriptor.getXMLParserClassName();
+ SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
+ String uri = "http://...";
+ <strong>Document doc = f.createDocument(uri);</strong>
+} catch (IOException ex) {
+ // ...
+}
+</source>
+
+<p>
+As we have created a SVG <code>Document</code>, we can cast this document to an
+<code>SVGDocument</code> (defined in the <code>org.w3c.dom.svg</code> package)
+if needed.
+</p>
</s1>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org