An Introduction to XSLT - Block Level Elements
(Page 6 of 6 )
Content is organized in the stylesheet as descendants of either the fo:flow or fo:static content elements, and appear in the resulting document as block level containers, rectangular areas preceded and followed by line breaks. Example of block-level elements include:
- fo:block
- fo:list
- fo:list-item
The basic syntax of block-level elements is as follows:
<fo:flow>
<fo:block>
<xsl:apply-templates select="article"/>
</fo:block>
</fo:flow>
Think of these block-level containers as the same as the <div> tag in HTML. The block-level containers all have a similar set of properties with which you can control how they appear in the resulting document; there are font properties, margin and padding properties, alignments, columns, backgrounds and borders. They are set in the following way:
<fo:block font-size="12pt">
An example of an extremely basic XSL (XSL-FO) document is:
<?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="mypage">
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="mypage">
<fo:flow flow-name="xsl-region-body">
<fo:block>DevShed Rocks!</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Save this file as formatting.xml in the same directory as news.xml, then in news.xml, change the stylesheet href to:
<?xml-stylesheet type="text/xsl" href="formatting.xml"?>
Save this file again with the filename news3.xml. Now open news3.xml and it should simply say 'DevShed Rocks!' The original content of news.xml is not displayed, but as you can use XSLT to do this, it doesn't really matter. There are many properties and attributes that can be set to these elements, far too many to list them all here. I hope that I have given you enough information to make use of XSLT and to understand the basics of XSL (the formatting language).
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |