Xml for SVG

Here should go questions about transforming XML with XSLT and FOP.
santhoshvkumar
Posts: 2
Joined: Sun May 16, 2010 12:59 pm

Xml for SVG

Post by santhoshvkumar »

Hi all,
I am practicing with some svg file I am trying to write a xslt for that and then to convert xslfo once again to convert it to pdf.
So I got a doubt here if I had
<polyline stroke-width="0.176" stroke-linecap="butt" points="56.667 41.167 57.515 42.097 58.362 42.859" />
<polyline stroke-width="0.176" stroke-linecap="butt" points="56.414 40.573 57.515 41.59 58.445 42.606" />
<path stroke-width="0.176" stroke-linecap="butt" d="M59.969 43.453L59.969 43.453C60.039 43.274 60.018 43.11 59.92 43.055C59.802 42.99 59.613 43.1 59.5 43.304C59.384 43.509 59.387 43.728 59.506 43.793C59.606 43.85 59.764 43.777 59.881 43.616" />
<path stroke-width="0.176" stroke-linecap="butt" d="M60.054 42.268L60.054 42.268C60.043 42.259 60.031 42.252 60.02 42.244C59.674 42.045 59.112 42.369 58.768 42.968C58.421 43.566 58.421 44.213 58.768 44.414" />

How can I write xml for this the pasted part here is the 1/2 of that work this is also consecutive please do let know some suggestion here.

Thanking You,
With Regards,
Santhosh Kumar V
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Xml for SVG

Post by adrian »

Hello,

I'm not sure if I understood correctly but if what you want is to obtain that SVG from transforming an XML with an XSLT then you can look at the SVG sample that comes with Oxygen: [oxygen-installation-folder]/samples/svg: sales.xml, sales.xsl

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
santhoshvkumar
Posts: 2
Joined: Sun May 16, 2010 12:59 pm

Re: Xml for SVG

Post by santhoshvkumar »

Hello Adrian,
I guess I am clear in my post since I got a .xml file which was an .svg file what I have to do is I have to write an .xsl for that also to convert to .xslfo to view the image. So there are following code as above I mentioned. I need to know how to get write coding for that .xsl files.

Thank you in advance,
Santhosh Kumar.V
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Xml for SVG

Post by adrian »

Hi,

FO supports embedded SVG so all your stylesheet has to do is copy the svg element from the source to the destination. You don't have to process the SVG content unless you actually want to modify it.

Code: Select all

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
<xsl:template match="svg:svg">
<xsl:element name="fo:instream-foreign-object">
<xsl:copy-of select="."/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
This sample code assumes that when the svg element is reached in the source you already are inside a fo:block in the output.

Not sure of the context you are using this in but SVG elements in FO are usually placed inside a "fo:instream-foreign-object" element that can in turn be placed in a 'fo:block'.

Afterwards when you process the FO with FOP it should handle the SVG by itself.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply