Beginner Question About XSLT

I just started learning XSLT, now I am following some online tutorial and now I have a simple question:

Suppose we have an original xml file, do we need to write a stylish XSLT table, or just just transfer the xml file to some software such as Stylus Studio (Saxon Engine), then it will do all this stuff automatically for us?

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?

Thanks in advance!

+3
source share
3 answers

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="*"/>

  <!-- 
    This is an "identity" template.
    It copies whatever node from input to the output without changing it. 
    Learn it. Use it. Love it. -->
  <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>
            <!-- This is the first way to output an SVG; by referencing the graphic. -->
            <fo:external-graphic src="test.svg"/>
            <!-- This is the second way to output an SVG; by outputting the SVG XML directly. -->
            <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">
                <!-- CONTENT REMOVED FOR STACKOVERFLOW.COM EXAMPLE -->
              </svg>
            </fo:instream-foreign-object>
         </fo:block>
      </fo:flow>
   </fo:page-sequence>
</fo:root>

, .

+8

PDF, XSL: FO/FOP. FOP, xsl PDF. xsl XML, , , freemarker/velocity XSL.

: http://www.treebuilder.de/svg/extentSVG/artikel/tut.html

FOP, SVG, :

   <fo:table text-align="left" table-layout="fixed"
                                      background-image="SVG_file.svg">

, svg

+1

Svg - Xml . , XSLT, .

Google , .

-1

Source: https://habr.com/ru/post/1773570/


All Articles