You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by ro...@vodafone.com on 2004/02/09 17:48:35 UTC

Dynamic SVG Creation

Hi Kieran,
Is it possible to put this code between xsp logic tags instead of a function
??
And when you have created the svgdoc and svgroot, how can you view it??   My
intention is to put the generated svg in a html body.
It would help if i saw a very tiny example of all files needed to fullfill
the job and maybe alterations in the sitemap if needed ?  could you give me
the code that generates a small blue rectangle with some dynamic text in it
and then how to view it in a html page?
Kind regards,
Robby





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Dynamic SVG Creation

Posted by Brent L Johnson <br...@bjohnson.net>.
Not sure if this is what you need.. but here goes:

Sitemap:

<map:match pattern="images/*/*.jpg">
    <map:generate src="skins/{global:skin}/svg/{1}.svg"/>
    <map:transform src="skins/{global:skin}/{1}Image.xsl">
        <map:parameter name="title" value="{2}"/>
    </map:transform>
    <map:serialize type="svg2jpeg"/>
</map:match>

SVG File:

<svg width="150" height="12">
    <ttf-font type="DieNasty"/>
    <rect x="0" y="0" width="150" height="12"
style="fill:rgb(255,236,145)"/>
    <text x="8px" y="11px"
style="text-anchor:start;fill:rgb(0,0,0);font-size:14;font-family:DieNas
ty;">Home</text>
</svg>

XSL File:

<xsl:include href="fonts.xsl"/>
<xsl:param name="title"/>

<xsl:template match="text">
    <text>
        <xsl:copy-of select="@*"/>
        <xsl:value-of
select="document('svg/blocks.xml')/images/image[@name=$title]"/>
    </text>
</xsl:template>

Description of how it works:

You can ignore the font stuff if you want.  I just created
an XSL file that has embedded fonts that get included when
the transform is complete.  That way I can use any TTF font
I want for my text (so it looks the same on all platforms
regardless of fonts installed on the server).

Also.. the svg/blocks.xml file basically converts the
image name to some useful title.  You can ignore this
too if you just want to use some static title.  This is
also not needed.. you can simply remove that {1}Image.xsl
transform from this example and your image will say "Home".

So where you want to display this image in HTML you would do:

<img src="/images/block/main.jpg"/>

It will then look for the file in skins/myskin/svg/block.svg.
(if myskin is global.. again you dont need this.. its just
what my sitemap looks like.. you can specify it as whatever
SVG file you want).

That's really it.. its pretty simple once you get
the hang of it!

Good luck,

- Brent

> -----Original Message-----
> From: robby.pelssers@vodafone.com 
> [mailto:robby.pelssers@vodafone.com] 
> Sent: Monday, February 09, 2004 11:49 AM
> To: users@cocoon.apache.org
> Subject: Dynamic SVG Creation 
> 
> 
> Hi Kieran,
> Is it possible to put this code between xsp logic tags 
> instead of a function ??
> And when you have created the svgdoc and svgroot, how can you 
> view it??   My
> intention is to put the generated svg in a html body.
> It would help if i saw a very tiny example of all files 
> needed to fullfill the job and maybe alterations in the 
> sitemap if needed ?  could you give me the code that 
> generates a small blue rectangle with some dynamic text in it 
> and then how to view it in a html page? Kind regards, Robby
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org