Using XSLT to Create FO - Exercise

Contact Us or call 1-877-932-8228
Using XSLT to Create FO - Exercise

Using XSLT to Create FO

Duration: 15 to 25 minutes.

In this exercise, you will generate the FO document we have been working with in this lesson from an XML document using XSLT.

  1. Open FoBasics/Exercises/HelloWorld.xml. You will see that it is a very simple XML document.
  2. Open FoBasics/Exercises/HelloWorld.xsl for editing.
  3. Finish this XSLT document so that it transforms FoBasics/Exercises/HelloWorld.xml to output the equivalent of FoBasics/Demos/ shown earlier.
  4. To test your solution, transform FoBasics/Exercises/HelloWorld.xml against FoBasics/Exercises/HelloWorld.xsl and then run the result through an FO engine.


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
	<xsl:output method="xml" indent="yes"/>
	<xsl:template match="/Document">
		<fo:root xmlns:fo="">

			<fo:simple-page-master master-name="hello"
						  page-height="11in"  page-width="8.5in" margin-top="1in" 
						  margin-bottom="1in" margin-left="1in" margin-right="1in">
				<fo:region-body margin-top="1in" margin-bottom=".5in"/>
		<fo:page-sequence master-reference="hello">
			<fo:flow flow-name="xsl-region-body">
				<fo:block font-size="18pt" text-align="center" font-weight="bold">
					<xsl:value-of select="Heading"/>