XSL instructions

XSL formatting instructions are XML elements that contain the text they apply to. Attributes are frequently used to specify the styles to be applied to this text. For those familiar with CSS and other stylesheet languages, this is an unfamiliar concept. With these languages, the content is always separate from the styling instructions. The XSL approach more closely resembles traditional typesetting languages, where formatting instructions are embedded in the text.

XSL documents are therefore XML documents. Although no DTD is specified for XSL elements, one could be derived from the definitions in the draft XSL standard, and this DTD could be used to validate an XSL document. One possible reason why a DTD has not been defined could be to discourage that idea that XSL documents may be created directly by document authors. This would certainly be a bad idea, because XSL documents break the cardinal rule for XML documents; that they be self-describing. Instead, XSL documents should almost always be created from information in other formats, including other XML documents (but not excluding others forms, such as data stored in relational databases), and discarded after being used by an XSL formatting engine to create formatted output. Of course, one way to convert arbitrary XML documents into XSL documents would be to use XSLT.

The following example demonstrates the use of two of the most common instructions. It emulates the HTML fragment below:

<block>A <wrapper font-weight="bold">bold</wrapper>
statement.</block>

<P>A <B>bold</B> statement.</P>

XSL formatting instructions are known as 'formatting object' elements, or 'FO' elements for short. In the event that these elements are mixed with elements from other document types, there is a namespace defined for them. The FO namespace is http://www.w3.org/1999/XSL/Format, which is commonly mapped to a prefix of 'fo':

<fo:block>A
<fo:wrapper font-weight="bold">bold</fo:wrapper>
statement.</fo:block>

This namespace is referenced from XSLT stylesheets:

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

  <template match="para">
    <fo:block><apply-templates/></fo:block>
  </template>

Examples in this chapter dispense with the prefix, as they do not include elements from other namespaces and their absence makes the examples more legible. But it should not be forgotten that such prefixes are often necessary.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.244.153