XML
  Home arrow XML arrow Page 4 - Using XSL Formatting Objects
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Using XSL Formatting Objects
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-02-04

    Table of Contents:
  • Using XSL Formatting Objects
  • Creating a Hello world document
  • Processing a document
  • Page masters

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using XSL Formatting Objects - Page masters


    (Page 4 of 4 )

    Let's explore XSL-FO in more detail, starting with page masters. As mentioned earlier, page masters govern the geometry of pages. Pages created from content within a page-sequence element that references a given page master will use the page master's properties.

    In the first example, the text "Hello, world." was crammed into the top left-hand corner of the document, flush with the edge of the page. This is very unappealing. In order to fix this, we need to add some margins to the page. Before we do that, though, it helps to determine the size of the page itself. This can be done by setting the page-height and page-width attributes of the simple-page-master element. Let's create a letter-sized page (8.5" x 11") by modifying the simple-page-master element within helloworld.fo:


    <fo:simple-page-master master-name="BasicPage" page-width="8.5in" page-height="11in">


    With the page's dimensions defined, we can now set some margins. There are a few ways we can do this. The first is to define the margins uniformly, giving each side of the page the same margin. This can be done using the margin attribute. Let's make the page have a margin of one inch on all sides:


    <fo:simple-page-master master-name="BasicPage" page-width="8.5in" page-height="11in" margin="1in">


    Another way way is to set the margins individually. Margins for each side can be set using the margin-top, margin-bottom, margin-left and margin-right attributes. Suppose we wanted to specify margins of one inch on the top and the bottom and margins of three-quarters of an inch on the left and right. We'd do it like this:


    <fo:simple-page-master master-name="BasicPage" page-width="8.5in" page-height="11in" margin-top="1in" margin-bottom="1in" margin-left=".75in" margin-right=".75in">


    The above markup is a bit lengthy though. It's also possible to set the margins individually with the margin attribute. Margin sizes for each side can be passed in, separated by whitespace, just as they can with HTML. We can accomplish the same thing as above like this:


    <fo:simple-page-master master-name="BasicPage" page-width="8.5in" page-height="11in" margin="1in .75in 1in .75in">


    The first measurement passed in is the top margin. From there, it moves clockwise, so that the second measurement is the right margin, and so forth. We can simplify the above code even more, though. If we just pass in two measurements, then the first measurement will be used for the top and bottom margins, and the second measurement will be used for the left and right margins. The following markup would produce the same output:


    <fo:simple-page-master master-name="BasicPage" page-width="8.5in" page-height="11in" margin="1in .75in">


    Text isn't simply thrown onto the page in the same area, though. Later, we'll cover regions. Thanks for reading!


    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.

     

    XML ARTICLES

    - 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
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek