أرشيف الوسوم: xsl-fo

Getting to know XSL-FO (Intro)

I had to introduce XSL-FO for myself  as I was given a task to style a PDF document with it. Task more specifically is to take data from a web page and style it with XSL-FO (and maybe XSLT) for PDF to be dowloaded from website. I’ll just do short introduction to subject now, but I will doing a practical tutorial about XSL-FO soon.

What is XSL-FO all about?

As you may allready have discovered it’s about formatting data for output, you could say it’s a bit like CSS. In this case we are formatting XML data. For detailed tutorial you can go to w3schools.com, but there’s not too much examples, so I’ll be doing a more illustrating “hands on” tutorial. To understand you need to know some XML and the concept of XML namespaces. It was introduced as a web standard in 15. October 2001 and is formally named XSL. Why is it formally named XSL? It’s because it’s XSL, but only the formatting part. FO stands for formatting. XSL covers both transforming and formatting so that’s why XSL-FO was introduced.

It’s structured so that if you know only HTML, you just need to know some basics about XML and then your good to go. Nevertheless the syntax in XSL-FO is different so you definetely have to learn that. What comes to styling part, or formatting to more precise, here knowledge about CSS&HTML will help you. As starters here’s a little example of the code for you:

<?xml version="1.0" encoding="ISO-8859-1"?>

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

 <fo:layout-master-set>
 <fo:simple-page-master master-name="A4">
 <fo:region-body />
 </fo:simple-page-master>
 </fo:layout-master-set>

 <fo:page-sequence master-reference="A4">
 <fo:flow flow-name="xsl-region-body">
 <fo:block>It works!</fo:block>
 </fo:flow>
 </fo:page-sequence>

 </fo:root>

The output will be “It works!”. Well that’s it for now hope to see you for tutorials :).