Added the src attribute to the svg tag
authorArjen Baart <arjen@andromeda.nl>
Thu, 26 Apr 2012 11:12:31 +0000 (13:12 +0200)
committerArjen Baart <arjen@andromeda.nl>
Thu, 26 Apr 2012 11:12:31 +0000 (13:12 +0200)
  This includes SVG drawings from an external file.

doc/block.xml
doc/filter.svg [new file with mode: 0644]
doc/glossary.xml
doc/guide.xml
html.xsl

index 4c05987..91459b6 100644 (file)
@@ -240,6 +240,48 @@ The two attributes are used in either HTML or LaTeX.
 </section>
 
 <section>
+<heading><label name='svg'/>Scalable Vector Graphics</heading>
+
+<para>
+Scalable vector graphics can be included in the document or
+from an external (SVG) file.
+With a <strong>src</strong> attribute, the <strong>svg</strong> element
+will load the SVG drawing from an external file:
+<example>
+   &lt;svg src='filter.svg'/&gt;
+</example>
+<svg src='filter.svg'/>
+</para>
+<para>
+When the <strong>src</strong> attribute is omitted, all available SVG
+elements can be used within the XML document:
+
+<example>
+   &lt;svg&gt;
+      &lt;clipPath id="a"&gt;
+         &lt;circle cy="90" cx="100" r="60"/&gt;
+      &lt;/clipPath&gt;
+      &lt;circle fill="#AAAAAA" cy="90" cx="190"
+                 r="60" style="clip-path:url(#a)"/&gt;
+      &lt;circle stroke="black" fill="none" cy="90" cx="100" r="60"/&gt;
+      &lt;circle stroke="blue" fill="none" cy="90" cx="190" r="60"/&gt;
+   &lt;/svg&gt;
+</example>
+<svg>
+   <clipPath id="a">
+      <circle cy="90" cx="100" r="60"/>
+   </clipPath>
+   <circle fill="#AAAAAA" cy="90" cx="190"
+              r="60" style="clip-path:url(#a)"/>
+   <circle stroke="black" fill="none" cy="90" cx="100" r="60"/>
+   <circle stroke="blue" fill="none" cy="90" cx="190" r="60"/>
+</svg>
+
+</para>
+
+</section>
+
+<section>
 <heading><label name='table'/>Tables</heading>
 <para>
 Creating tables in XMLDoc is much like creating tables in HTML.
diff --git a/doc/filter.svg b/doc/filter.svg
new file mode 100644 (file)
index 0000000..43e2e41
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<svg width="800" height="200" version="1.1"
+     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+  <defs>
+      <radialGradient id="MyGradient" gradientUnits="userSpaceOnUse"
+                      cx="200" cy="100" r="150" fx="200" fy="100">
+        <stop offset="0%" stop-color="red" />
+        <stop offset="50%" stop-color="blue" />
+        <stop offset="100%" stop-color="red" />
+      </radialGradient>
+      <filter id="GreyOut">
+        <feColorMatrix type="saturate" in="SourceGraphic" values="0.05"/>
+      </filter>
+  </defs>
+
+  <rect fill="url(#MyGradient)" stroke="black"
+        x="40" y="40" width="300" height="160"/>
+
+  <g  transform="translate(380,0)" filter="url(#GreyOut)">
+  <rect fill="url(#MyGradient)" stroke="black"
+        x="40" y="40" width="300" height="160"/>
+  </g>
+
+</svg>
index bf6963a..edfb5b1 100644 (file)
    <sup>superscript</sup> text.
   </item>
 
+  <item tag='svg'>
+   <ref to='svg'>Scalable vector graphics</ref>
+  </item>
+
   <item tag='table'>
    Creates <ref to='table'>tabular</ref> content.
   </item>
index 60fa01d..0a53dc4 100644 (file)
@@ -123,7 +123,6 @@ The content of the <code>page</code> element is only renedered in LaTeX output.
 <heading>Other XML applications</heading>
 <section>
 <heading>MathML</heading>
-</section>
 <math>
   <mrow>
     <msup>
@@ -152,20 +151,6 @@ The content of the <code>page</code> element is only renedered in LaTeX output.
     </msub>
   </mrow>
 </math>
-<section>
-<heading>SVG</heading>
-
-<svg>
-   <clipPath id="a">
-      <circle cy="90" cx="100" r="60"/>
-   </clipPath>
-   <circle fill="#AAAAAA" cy="90" cx="190"
-              r="60" style="clip-path:url(#a)"/>
-   <circle stroke="black" fill="none" cy="90" cx="100" r="60"/>
-   <circle stroke="black" fill="none" cy="90" cx="190" r="60"/>
-</svg>
-
-
 </section>
 </chapter>
 
index 43841a8..155db6a 100644 (file)
--- a/html.xsl
+++ b/html.xsl
 </xsl:template>
 
 <xsl:template match="svg">
-<svg>
-<xsl:attribute name="xmlns">http://www.w3.org/2000/svg</xsl:attribute>
-<xsl:copy-of select='./*'/>
-</svg>
+<xsl:if test='@src'>
+   <xsl:copy-of select="document(@src)"/>
+</xsl:if>
+<xsl:if test='not(@src)'>
+   <svg>
+   <xsl:attribute name="xmlns">http://www.w3.org/2000/svg</xsl:attribute>
+   <xsl:copy-of select='./*'/>
+   </svg>
+</xsl:if>
 </xsl:template>
 
-</xsl:stylesheet>
 
+
+</xsl:stylesheet>