Home arrow XML arrow Page 6 - 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 - 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.

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