How to use XSL-FO in XML

In this article I will explain How to use XSL-FO in XMl and Describe example of XSL-FO
  • 1608

XSL-FO Document

  • XSL-FO focuses on style that works for both screen and print, such as PDF files.

  • XSL-FO allows you to create pages that look fantastic on any screen.

XSL-FO Example

<?xml version="1.0" encoding="utf-16"?>

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

  <fo:layout-master-set>

    <fo:simple-page-master page-height="297mm" page-width="210mm"

    margin="5mm 25mm 5mm 25mm" master-name="PageMaster">

      <fo:region-body margin="20mm 0mm 20mm 0mm"/>

    </fo:simple-page-master>

  </fo:layout-master-set>

  <fo:page-sequence master-name="PageMaster">

    <fo:flow flow-name="xsl-region-body">

      <fo:block>

        <fo:block>Welcome To! </fo:block>

        <fo:block>

          <fo:inline font-weight="bold">MCN SOLUTION PVT LTD</fo:inline>

        </fo:block>

      </fo:block>

    </fo:flow>

  </fo:page-sequence>

</fo:root>

 

Output of above XSL-FO is displayed as follows.

 

Welcome To!

MCN SOLUTION PVT LTD

 

Explain this example

  • Line 1 is the XML declaration.

  • Line 2 is the root element with the namespace listed.

  • Line 3 is the wrapper around all masters used in the document.

  • Line 4 I'm using a simple-page-master to define the geometry of the page and give it a name. My basic page will have a margin of  1 inch on all sides.

  • Line 8 I only need to define the sequence of one page

  • Line 9 I only defined one flow in my master, that's the one I should use - "xsl-region-body"

Further Readings

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2019 DotNetHeaven. All rights reserved.