Sorry for the incorrect explanation. I need to convert this .svg file to pdf, I'm just at the beginning of development, so I really got confused in the first step. Also I would like to know if my initial input is a .svg file, do I need to explicitly convert it to .xml before I start using XSLT?
An SVG file is an XML file in the SVG namespace. Regardless of whether you want to convert this XML, it depends on how you intend to use it. If you were going to do batch printing using something like Inkscape (an SVG editor), you would not.
- XSL-FO, . @Zoltan Hamori . XSLT ( XSL-FO), PDF XSL-FO XSL-FO-.
Zoltan FOP ( Apache), , FOP XSL-FO ; . - XSL-FO (XML fo). PDF XSL-FO , FOP, RenderX, Antenna House ..
:
- XML ( SVG )
- XSLT XSL-FO.
- XSL-FO PDF XSL-FO
XSL-FO , XSLT, , SVG PDF.
- SVG fo:external-graphic.
- SVG XML XSL-FO fo:instream-foreign-object.
XML - SVG XML, . , , .
. SVG, 2- PDF . SVG.
- SVG , Inkscape. ( SVG XML XSL-FO, .)
- XSLT- Saxon-HE 9.2.0.6.
- FO Apache FOP 0.95 ( RenderX).
- Saxon-HE Apache FOP .
- , SVG, XSL-FO. PDF .
XSLT 2.0
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:external-graphic src="test.svg"/>
<fo:instream-foreign-object>
<xsl:apply-templates/>
</fo:instream-foreign-object>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
XSL-FO ( Saxon SVG XSL)
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:external-graphic src="test.svg"/>
<fo:instream-foreign-object>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"
width="595.99438"
height="491.50516"
id="svg2675">
</svg>
</fo:instream-foreign-object>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
, .