[yelp-xsl] [mal2html-svg.xsl] First pass at embedding SVG into Mallard pages



commit 137fbdf0d6f9c65b0fb5da921a34ca5c9f24d6f5
Author: Shaun McCance <shaunm gnome org>
Date:   Mon Mar 1 23:14:01 2010 -0600

    [mal2html-svg.xsl] First pass at embedding SVG into Mallard pages

 xslt/mallard/html/Makefile.am      |    1 +
 xslt/mallard/html/mal2html-svg.xsl |   78 ++++++++++++++++++++++++++++++++++++
 xslt/mallard/html/mal2html.xsl     |    1 +
 xslt/mallard/html/mal2xhtml.xsl    |    1 +
 4 files changed, 81 insertions(+), 0 deletions(-)
---
diff --git a/xslt/mallard/html/Makefile.am b/xslt/mallard/html/Makefile.am
index 28e3583..b8dfbe8 100644
--- a/xslt/mallard/html/Makefile.am
+++ b/xslt/mallard/html/Makefile.am
@@ -7,6 +7,7 @@ xsl_DATA =				\
 	mal2html-list.xsl		\
 	mal2html-media.xsl		\
 	mal2html-page.xsl		\
+	mal2html-svg.xsl		\
 	mal2html-table.xsl		\
 	mal2html.xsl			\
 	mal2xhtml.xsl
diff --git a/xslt/mallard/html/mal2html-svg.xsl b/xslt/mallard/html/mal2html-svg.xsl
new file mode 100644
index 0000000..e507c80
--- /dev/null
+++ b/xslt/mallard/html/mal2html-svg.xsl
@@ -0,0 +1,78 @@
+<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
+<!--
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option) any
+later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program; see the file COPYING.LGPL.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+-->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+                xmlns:mal="http://projectmallard.org/1.0/";
+                xmlns:svg="http://www.w3.org/2000/svg";
+                xmlns:xlink="http://www.w3.org/1999/xlink";
+                xmlns:exsl="http://exslt.org/common";
+                xmlns="http://www.w3.org/1999/xhtml";
+                extension-element-prefixes="exsl"
+                exclude-result-prefixes="mal svg xlink"
+                version="1.0">
+
+<!--!!==========================================================================
+Mallard to HTML - SVG
+
+REMARK: Describe this module
+-->
+
+<xsl:template mode="mal2html.svg.mode" match="svg:*">
+  <xsl:choose>
+    <xsl:when test="@mal:xref">
+      <xsl:variable name="target">
+        <xsl:call-template name="mal.link.target">
+          <xsl:with-param name="node" select="."/>
+          <xsl:with-param name="xref" select="@mal:xref"/>
+        </xsl:call-template>
+      </xsl:variable>
+      <svg:a xlink:href="{$target}">
+        <xsl:copy>
+          <xsl:for-each select="@*">
+            <xsl:copy/>
+          </xsl:for-each>
+          <xsl:apply-templates mode="mal2html.svg.mode" select="node()"/>
+        </xsl:copy>
+      </svg:a>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:copy>
+        <xsl:for-each select="@*">
+          <xsl:copy/>
+        </xsl:for-each>
+        <xsl:apply-templates mode="mal2html.svg.mode" select="node()"/>
+      </xsl:copy>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template mode="mal2html.svg.mode" match="text()">
+  <xsl:copy-of select="."/>
+</xsl:template>
+
+<xsl:template mode="mal2html.block.mode" match="svg:svg">
+  <xsl:variable name="id" select="generate-id(.)"/>
+  <div>
+    <img src="{$id}.svg"/>
+  </div>
+  <exsl:document href="{$id}.svg">
+    <xsl:apply-templates mode="mal2html.svg.mode" select="."/>
+  </exsl:document>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/xslt/mallard/html/mal2html.xsl b/xslt/mallard/html/mal2html.xsl
index cf68a2c..e2cfd2d 100644
--- a/xslt/mallard/html/mal2html.xsl
+++ b/xslt/mallard/html/mal2html.xsl
@@ -56,6 +56,7 @@ REMARK: Describe this module
 <xsl:include href="mal2html-list.xsl"/>
 <xsl:include href="mal2html-media.xsl"/>
 <xsl:include href="mal2html-page.xsl"/>
+<xsl:include href="mal2html-svg.xsl"/>
 <xsl:include href="mal2html-table.xsl"/>
 
 <xsl:include href="../../common/utils.xsl"/>
diff --git a/xslt/mallard/html/mal2xhtml.xsl b/xslt/mallard/html/mal2xhtml.xsl
index 73230d8..f52352c 100644
--- a/xslt/mallard/html/mal2xhtml.xsl
+++ b/xslt/mallard/html/mal2xhtml.xsl
@@ -55,6 +55,7 @@ REMARK: Describe this module
 <xsl:include href="mal2html-list.xsl"/>
 <xsl:include href="mal2html-media.xsl"/>
 <xsl:include href="mal2html-page.xsl"/>
+<xsl:include href="mal2html-svg.xsl"/>
 <xsl:include href="mal2html-table.xsl"/>
 
 <xsl:include href="../../common/utils.xsl"/>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]