[oXygen-user] SVG rasterizer

Wendell Piez
Mon Jun 13 10:26:01 CDT 2011


Kurt,

Please do. Let me know what improvements you make. (The variables, of 
course, are superfluous, and help only legibility.)

Here's an XSLT 1.0 version (passing the value of the path to the SVG in 
as a parameter):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:param name="svg-file" select="''"/>

<xsl:variable name="svg" select="document($svg-file)"/>
<xsl:variable name="height" select="$svg/*/@height"/>
<xsl:variable name="width" select="$svg/*/@width"/>

<xsl:template match="/">
   <fo:root xsl:version="2.0">

     <fo:layout-master-set>
       <fo:simple-page-master master-name="svg"
         page-height="{$height}" page-width="{$width}">
         <fo:region-body/>
       </fo:simple-page-master>
     </fo:layout-master-set>
     <fo:page-sequence master-reference="svg">
       <fo:flow flow-name="xsl-region-body">
         <fo:block>
           <fo:external-graphic src="{$svg-file}"/>
         </fo:block>
       </fo:flow>
     </fo:page-sequence>
   </fo:root>
</xsl:template>

</xsl:stylesheet>

Cheers,
Wendell

On 6/10/2011 7:32 PM, Kurt Cagle wrote:
> Wendell,
>
> This is just too cool - would you mind if I were to use a variation of
> it for my SVG book?
>
> Kurt Cagle
> Invited Expert, XForms Working Group, W3C
> Managing Editor, XMLToday.org
>  <mailto:>
> 443-837-8725

-- 
======================================================================
Wendell Piez                            mailto:
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================



More information about the oXygen-user mailing list