Understanding and Customizing the XML+XSL Standard Edition Template

prevnext

Understanding the XSL file


The document.xsl file included in the XML+XSL Standard Edition template contains CSS information similar to the document.css file included in the XML+CSS template. However, it also contains XSL transformations (XSLT). XSL uses XSLT to transform information from one markup language to another, or in this case, from XML to HTML. Using the transformation information in the file, you can completely control how a browser or any other device displays XML.

Located in your project's support directory, the document.xsl file is also copied to the output directory when you generate your project. The XSL file is referenced at the top of your XML files:

 <?xml-stylesheet href="document.xsl" type="text/xsl"?>

The <?xml-stylesheet> tag is the only location where the XSL file is identified. But through the XML source, you'll find XML coding that reference components of the XSL file:

 <Body class="Body" id="1124277">
 This is body text.
 </Body>

The CLASS attribute refers to a paragraph style called Body. The first section of the XSL file defines each of the paragraph styles found in the XML+XSL Standard Edition template, and it includes the document defaults:

 <STYLE>
         a:active  { color: #0000CC}
         a:hoover  { color: #CC0033}
         a:link    { color: #3366CC}
         a:visited { color: #9999CC}
 
           { font-size: 0px;
             font-family: Verdana, Arial, Helvetica, sans-serif; }
         .Body
           { color: #000000;
            font-size: 12px; font-style: normal; font-weight: normal;
            margin-left: 0em; margin-top: 0.5em; margin-bottom: 0.5em;
            text-align: left; text-indent: 0em; text-decoration: none;
       	     white-space: normal }
 
         ...
 
         .TOC5
           { color: #000000;
            font-size: 10px; font-style: normal; font-weight: normal;
            margin-left: 10em; margin-top: 0em; margin-bottom: 0em;
             text-align: left; text-indent: 0em; text-decoration: none;
            white-space: normal }
       </STYLE>

As the preceding code shows, the Body style has a font size of 12 points, using the 000000 color (black), a font without highlighting, and a margin of half an em space from the previous paragraph (or tag). If you change any of these settings for Body in the XSL file, all the entities that use the CLASS=Body setting will automatically change.

Hierarchies in the XSL file

While the formatting aspects of styles in an XSL file are similar to what is in a CSS file, the XSL file also defines a hierarchy for elements. You can see this hierarchy when you view the XSL file in a web browser, as this section defining the TABLE element shows:

Refer to an XML reference for more information about how hierarchies and rules are set up in an XSL file.

prevnext



Quadralay Corporation
http://www.webworks.com
Voice: (512) 719-3399
Fax: (512) 719-3606
sales@webworks.com