Home arrow XML arrow Page 5 - An Introduction to XSLT
XML

An Introduction to XSLT


XSLT allows you to create formatting structures which interpret and modify the existing XML elements. Learn about the syntax of XSLT elements, how the namespace attribute differs depending on the browser in use, and how to transform original XML elements.

Author Info:
By: Dan Wellman
Rating: 4 stars4 stars4 stars4 stars4 stars / 14
September 20, 2004
TABLE OF CONTENTS:
  1. · An Introduction to XSLT
  2. · Create Elements to Apply the Transformations
  3. · Another Template
  4. · Discussion of the Output
  5. · Page Masters
  6. · Block Level Elements

print this article
SEARCH DEVARTICLES

An Introduction to XSLT - Page Masters
(Page 5 of 6 )


 
In addition to this, there is the Formatting-Objects language, XSL (formerly know as XSL-FO) that we have not yet explored. These are reserved XML elements that are defined in the FO namespace. XSL documents contain an fo:root element which acts as the document root:

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

This document root then contains a layout element that defines the page layout (known as page masters):

<fo:layout-master-set>
</fo:layout-master-set>

Nested within the layout-master are the page master elements:

<fo:simple-page-master page-master-name="Intro">
</fo:simple-page-master>

The page master element can be used to set the size of the outputted document using the following syntax:

<fo:simple-page-master page-master-name="Intro" height="10.0in"

width="8.0in">
</fo:simple-page-master>

If these values are omitted, the processor will assign pre-defined values depending on the media the outputted document is displayed to. The page-master element can also be used to set page margins:

<fo:simple-page-master page-master-name="Intro" height="10.00in"

width="8.00in" margin-top="1.0in"
margin-bottom="1.0in" margin-left="1.0in" margin-right="1.0">
</fo:simple-page-master>
 
XSL-FO documents position content on a page according to the following hierarchy of areas:

  • Pages
  • Regions
  • Block Areas
  • Line Areas
  • Inline Areas

Area Containers contain either additional Area Containers or Block Areas. Block Areas contain either additional Block Areas or Line Areas. Area containers define the basic structure in which your XML is displayed. Block Areas are used to define paragraphs and lists, and they can contain text. Line Areas contain Inline Areas and Inline Spaces.  Line Areas are used to contain elements for graphics, mathematical equations or links.  Inline Areas are rectangular areas used to format and contain content such as graphics, text and horizontal rules. The page-masters that we examined a moment ago are constructed using area containers in the following way:

<fo:region-start extent="0.5in"/> Left edge of the page
<fo:region-before extent="0.5in"/> Top edge of the page
<fo:region-body/>   Main body of the page
<fo:region-end extent="0.5in"/>  Right edge of the page
<fo:region-after extent="0.5in"/> Bottom edge of the page

These region elements also have attributes to set properties, including:

  • Borders
  • Background
  • Padding
  • Margins
  • Overflow
  • Columns
  • Text orientation and direction

Page-masters can be applied to the content of your document using the page-sequence element:

<fo:page-squence>
</fo:page-sequence>

This element can then contain a further two elements:

<fo:static content>
<fo:flow>

The static content element is optional and can be used to display content that appears on every page in a sequence, such as headings.  The fo:flow element contains a list of the elements that appear in your document, in the order in which they appear. 

If your page is not big enough to contain all of the elements, additional pages are created.  This is how the overflow of elements is handled as fo:static elements cannot overflow.


blog comments powered by Disqus
XML ARTICLES

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials