This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: [docbook-apps] Weird callout issue
At 12:01 19.06.2004, DaveP wrote:
Anyone have the tools to get a full suite of images
of the right size?
I used an image grabber, then manually sized them
which is the source of the problem.
I've just played a bit with Ant + XSL/SVG/Rasterizer and got a script wich
does the following tasks:
- loop over a list of numbers 1..15
- applying a XSL transformation to a SVG-template (circle with empty text
element in the middle) that puts a value into the text element
- rasterize the SVG to PNG
(n.b. this needs the rasterize task from Apache Batik and the foreach task
from http://ant-contrib.sourceforge.net/ )
Alex
build.xml
--------------------------------------------------------
<?xml version="1.0"?>
<project default="main" basedir=".">
<property name="number.list" value="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15"/>
<target name="init">
<taskdef name="rasterize"
classname="org.apache.tools.ant.taskdefs.optional.RasterizerTask"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
</target>
<target name="main" depends="init">
<foreach list="${number.list}" delimiter="," param="number"
target="createSVGCallout" inheritall="true"/>
</target>
<target name="createSVGCallout">
<xslt in="number.xml"
out="number-${number}.svg"
style="callout-svg.xsl">
<param name="vext" expression="${number}"/>
</xslt>
<antcall target="doRasterize"/>
<!--<delete file="number-${number}.svg"/>-->
</target>
<target name="doRasterize">
<rasterize
result="image/png"
dest="number-${number}.png"
src="number-${number}.svg">
</rasterize>
</target>
</project>
number.xml (the text element is empty - it'll be filled by callout-svg.xsl)
--------------------------------------------------------
<?xml version="1.0"?>
<svg width="15" height="15" viewBox="0 0 15 15">
<g transform="translate(0,0)"
style="font-family:serif;font-size:13;font-weight:bold">
<circle cx="7.5" cy="7.5" r="7"
style="stroke:rgb(0,0,0);fill:black;stroke-width:1"/>
<g style="stroke:none;fill:white">
<text id="number" text-anchor="middle" x="7.5" y="11.5"></text>
</g>
</g>
</svg>
callout-svg.xsl (to convert number.xml to number-x.svg - variable $vext
is passed as parameter to the XSL processor)
--------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:param name="vext" select="'0'"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text[@id='number']">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:value-of select="$vext"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/.