[CONTACT]

[ABOUT]

[POLICY]

[ADVERTISE]

DOCTYPE html PUBLIC DTD HTML

Found at: ftp.icm.edu.pl:70/packages/normos/w3c/NOTE-XSL-970910

<!DOCTYPE  html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML>
<HEAD>
  <TITLE>A Proposal for XSL</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
<H1>
  <IMG HEIGHT="48" ALT="W3C" BORDER="0" WIDTH="72" SRC="http://www.w3.org/Icons/WWW/w3c_home">
</H1>
<P ALIGN="right">
<B><BIG>NOTE-XSL.html</BIG></B>
<H1 ALIGN="center">
  A Proposal for XSL
</H1>
<P>
<B><BIG>&#183; <A HREF="http://www.w3.org/Submission/1997/13/Overview.html">Submitted to
W3C </A> on 27 August 1997 &#183;</BIG></B>
<P>
<DL>
  <DT>
    This version:
  <DD>
    <A HREF="NOTE-XSL.html" W3MIRHREF="http://www.w3.org/TR/NOTE-XSL.html">http://www.w3.org/TR/NOTE-XSL.html</A>
</DL>
<DL>
  <DT>
    Latest version:
  <DD>
    <A HREF="NOTE-XSL.html" W3MIRHREF="http://www.w3.org/TR/NOTE-XSL.html">http://www.w3.org/TR/NOTE-XSL.html</A>
</DL>
<DL>
  <DT>
    Authors:
  <DD>
    <A HREF="mailto:/sca@eps.inso.com">Sharon Adler</A>, Inso Corporation<BR>
    <A HREF="mailto:/alb@ibm.net">Anders Berglund</A>, Inso Corporation<BR>
    <A HREF="mailto:/jjc@jclark.com">James Clark</A><BR>
    <A HREF="mailto:/istvanc@microsoft.com">Istvan Cseri</A>, Microsoft
    Corporation<BR>
    <A HREF="mailto:/paul@arbortext.com">Paul Grosso</A>, ArborText<BR>
    <A HREF="mailto:/jmarsh@microsoft.com">Jonathan Marsh</A>, Microsoft
    Corporation<BR>
    <A HREF="mailto:/gtn@eps.inso.com">Gavin Nicol</A>, Inso Corporation<BR>
    <A HREF="mailto:/jeanpa@microsoft.com">Jean Paoli</A>, Microsoft Corporation<BR>
    <A HREF="mailto:/davidsch@microsoft.com">David Schach</A>, Microsoft
    Corporation<BR>
    <A HREF="mailto:/ht@cogsci.ed.ac.uk">Henry S. Thompson</A>, University of
    Edinburgh<BR>
    <A HREF="mailto:/cwilso@microsoft.com">Chris Wilson</A>, Microsoft
    Corporation<BR>
</DL>
<P>
<BR>
  <HR>
<H2>
  Status of this Document
</H2>
<P>
This document is a NOTE made available by the World Wide Web Consortium for
discussion only. This indicates no endorsement of its content, nor that the
Consortium has, is, or will be allocating any resources to the issues addressed
by the NOTE. A list of current NOTEs can be found at:
<A HREF="./" W3MIRHREF="http://www.w3.org/TR/">http://www.w3.org/TR/</A>.
<P>
This document is part of a complete <A HREF="http://www.w3.org/Submission/">submission</A>
to the W3C. The full submission has been acknowledged by W3C and is available
at
<A HREF="http://www.w3.org/Submission/1997/13/Overview.html">http://www.w3.org/Submission/1997/13/Overview.html</A>
<P>
Note: since working drafts are subject to frequent change, you are advised
to reference the above URL, rather than the URLs for working drafts themselves.
<P>
  <HR>
<P>
<FONT SIZE="3"> August 21, 1997 </FONT>
<DIV>
  <DIV>
    <H2>
      <A NAME="1">1. Introduction</A>
    </H2>
    <DIV>
      <H3>
	<A NAME="1.1">1.1. Status</A>
      </H3>
      <P>
      This is a working document. It is not meant to represent a completed proposal
      for XSL. Details of the flow objects and their characteristics need to be
      specified in detail; for now refer to the DSSSL standard and the HTML and
      CSS specifications.
    </DIV>
    <DIV>
      <H3>
	<A NAME="1.2">1.2. Purpose</A>
      </H3>
      <P>
      This is a proposal for XSL (Extensible Style Language) that is the deliverable
      for Phase III of the <A HREF="http://www.w3.org/Markup/Activity">SGML, XML,
      and Structured Document Interchange Activity</A> of the W3C. The charter
      for this activity specifies the use of ISO/IEC 10179 Document Style Semantics
      and Specification Language (
      <A HREF="http://www.oml.gov/sgml/WG8/wg8home.htm">DSSSL</A>) for the stylesheet
      language component. XSL is based on DSSSL.
      <P>
      XSL is a stylesheet language designed for the Web community. It provides
      functionality beyond CSS (e.g. element reordering). We expect that CSS will
      be used to display simply-structured XML documents and XSL will be used where
      more powerful formatting capabilities are required or for formatting highly
      structured information such as XML structured data or XML documents that
      contain structrued data.
      <P>
      Web authors create content at three different levels of sophistication:
      <UL>
	<LI>
	  markup: relies solely on a declarative syntax
	<LI>
	  script: additionally uses code &#147;snippets&#148; for more complex behaviors
	<LI>
	  program: uses a full programming language
      </UL>
      <P>
      XSL is intended to be accessible to the &#147;markup&#148; level user by
      providing a declarative solution to most data description and rendering
      requirements. Less common tasks are accommodated through a graceful escape
      to a familiar scripting environment. This approach is familiar to the Web
      publishing community as it is modeled after the HTML/JavaScript environment.
      <P>
      The powerful capabilities provided by XSL allow:
      <UL>
	<LI>
	  formatting of source elements based on ancestry/descendency, position, and
	  uniqueness
	<LI>
	  the creation of formatting constructs including generated text and graphics
	<LI>
	  the definition of reusable formatting macros
	<LI>
	  writing-direction independent stylesheets
	<LI>
	  extensible set of formatting objects
      </UL>
    </DIV>
    <DIV>
      <H3>
	<A NAME="1.3">1.3. Relationship to DSSSL</A>
      </H3>
      <P>
      XSL is based on DSSSL and is compatible with the fundamental design principles
      and processing model of this standard. However, the development of XSL has
      identified usability issues with the current DSSSL standard which has led
      XSL to diverge in various ways.
      <P>
      Therefore, in parallel with the development of the XSL specification, a proposal
      for an amendment to DSSSL will be developed so that with the amendment it
      would be a superset of XSL. The amended standard would be compatible with
      current DSSSL but would have three kinds of additions:
      <UL>
	<LI>
	  an alternative syntax compatible with the XSL syntax;
	<LI>
	  extensions to the flow object tree construction language to support the features
	  of XSL not in DSSSL; these features would be available both with the current
	  syntax and the alternative syntax;
	<LI>
	  new flow object classes and characteristics to support formatting functionality
	  necessary for the Web.
      </UL>
      <P>
      XSL incorporates the subset of DSSSL flow object classes and characteristics
      that was specified in
      <A HREF="http://sunsite.unc.edu/pub/sun-info/standards/dsssl/dssslo/do960816.htm">
      DSSSL-O</A>.
    </DIV>
    <DIV>
      <H3>
	<A NAME="1.4">1.4. Relationship to HTML and CSS</A>
      </H3>
      <P>
      XSL supports all of the functionality of CSS so that an accurate mechanical
      translation from CSS to XSL is possible. In order to provide this level of
      compatibility, cascading styles, specificity, and flow object and characteristic
      mapping need to be addressed by XSL. For the purposes of this document, CSS
      is defined by the W3C recommendation
      <A HREF="REC-CSS1" W3MIRHREF="http://www.w3.org/TR/REC-CSS1">Cascading stylesheets, level 1</A>
      and W3C working drafts <A HREF="WD-print" W3MIRHREF="http://www.w3.org/TR/WD-print"> CSS Printing
      Extensions</A> and <A HREF="WD-positioning" W3MIRHREF="http://www.w3.org/TR/WD-positioning"> Positioning
      HTML with Cascading Stylesheets</A>.
      <P>
      There are two levels of support for CSS styles and the CSS formatting model.
      To provide HTML authors a migration path and for HTML/CSS object model
      compatibility, XSL provides a set of HTML/CSS core flow objects with HTML
      attributes and CSS properties as characteristics. For DSSSL core flow objects,
      CSS properties are mapped via flow object macros and script code to the
      appropriate flow objects and characteristics.
      <P>
      CSS functionality is described throughout this document, notably in section
      3.2 (<A HREF="#item-3.2" W3MIRHREF="http://www.w3.org/TR/NOTE-XSL-970910#item-3.2">Patterns</A>), section 3.2.4 (<A HREF="#item-3.2.4" W3MIRHREF="http://www.w3.org/TR/NOTE-XSL-970910#item-3.2.4">ID
      and CLASS Attributes</A>), section 3.2.6
      (<A HREF="#item-3.2.6" W3MIRHREF="http://www.w3.org/TR/NOTE-XSL-970910#item-3.2.6">Conflicts</A>), section 4
      (<A HREF="#item-4" W3MIRHREF="http://www.w3.org/TR/NOTE-XSL-970910#item-4">Styles</A>), and section 6.2 (<A HREF="#item-6.2" W3MIRHREF="http://www.w3.org/TR/NOTE-XSL-970910#item-6.2">HTML/CSS
      Core Flow Objects</A>).
    </DIV>
    <DIV>
      <H3>
	<A NAME="1.5">1.5. Design Principles</A>
      </H3>
      <P>
      The following design principles have been used to guide the development of
      the XSL format described in this document, ordered from most important to
      least important.
      <OL>
	<LI>
	  XSL should be straightforwardly usable over the Internet.
	<LI>
	  XSL should be expressed in XML syntax.
	<LI>
	  XSL should provide a declarative language to do all common formatting tasks.
	<LI>
	  XSL should provide an &#147;escape&#148; into a scripting language to accommodate
	  more sophisticated formatting tasks and to allow for extensibility and
	  completeness.
	<LI>
	  XSL will be a subset of DSSSL with the proposed amendment.
	<LI>
	  A mechanical mapping of a CSS stylesheet into an XSL stylesheet should be
	  possible.
	<LI>
	  XSL should be informed by user experience with the FOSI stylesheet language.
	<LI>
	  The number of optional features in XSL should be kept to a minimum.
	<LI>
	  XSL stylesheets should be human-legible and reasonably clear.
	<LI>
	  The XSL design should be prepared quickly.
	<LI>
	  XSL stylesheets shall be easy to create.
	<LI>
	  Terseness in XSL markup is of minimal importance.
      </OL>
    </DIV>
  </DIV>
  <DIV>
    <H2>
      <A NAME="2">2. Stylesheet Structure</A>
    </H2>
    <DIV>
      <H3>
	<A NAME="2.1">2.1. Overview</A>
      </H3>
      <P>
      XSL enables formatting information to be associated with elements in the
      source document to produce formatted output. The formatted output is created
      by formatting a tree of <I>flow objects</I>. A flow object has a class, which
      represents a kind of formatting task. A flow object also has a set of named
      characteristics, which further specify the formatting. A core set of flow
      object classes is outlined later in this document.
      <P>
      The association of elements in the source tree to flow objects is through
      <I>construction rules</I>. The construction rules contain a <I>pattern</I>
      to identify specific elements in the source tree, and an <I>action</I> to
      specify a resulting sub-tree of flow objects. The stylesheet processor
      recursively processes source elements to produce a complete flow object tree.
      <P>
      In addition to construction rules XSL also supports <I>style rules</I> which
      allow the merging of characteristics. While only one construction rule can
      be invoked for a particular source element, <I>all</I> applicable style rules
      are invoked, allowing per-characteristic merging as in CSS.
      <P>
      An XSL stylesheet describes this formatting process through a small set of
      XML elements. An XSL stylesheet contains an <CODE>XSL</CODE> document element.
      This element can contain <CODE>rule</CODE> elements representing construction
      rules, and <CODE>style-rule</CODE> elements representing style merging rules.
      These elements will be described later in this document.
      <P>
      This example contains a <I>root</I> rule which creates the top-level
      <CODE>HTML</CODE> and <CODE>BODY</CODE> flow objects, a rule which creates
      a <CODE>DIV</CODE> with certain style characteristics for each
      <CODE>orders</CODE> element in the source, and a style-rule which applies
      the &#147;bold&#148; style to all <CODE>customer</CODE> elements.
      <BLOCKQUOTE>
	<PRE>&lt;xsl&gt;
  &lt;rule&gt;
    &lt;root/&gt;

		
    &lt;HTML&gt;
      &lt;BODY&gt;
        &lt;children/&gt;
      &lt;/BODY&gt;
    &lt;/HTML&gt;
  &lt;/rule&gt;
  
  &lt;rule&gt;
    &lt;target-element type="orders"/&gt;

		
    &lt;DIV font-size="14pt" font-family="serif"&gt;
      &lt;children/&gt;
    &lt;/DIV&gt;
  &lt;/rule&gt;

		
  &lt;style-rule&gt;
    &lt;target-element type="customer"/&gt;

		
    &lt;apply font-weight="bold"/&gt;
  &lt;/style-rule&gt;
&lt;/xsl&gt;
</PRE>
      </BLOCKQUOTE>
      <P>
      <SMALL><I>Note: This example uses HTML/CSS core flow objects.</I></SMALL>
      <P>
      The <CODE>xsl</CODE> element can also contain <CODE>import</CODE> elements
      to import other XSL stylesheets, <CODE>define-macro</CODE> elements representing
      flow object macro definitions, <CODE>define-script</CODE> elements representing
      common functions and definitions, and <CODE>id</CODE> and <CODE>class</CODE>
      elements representing the identification of source attributes as individual
      element identifiers or as class element identifiers. These elements are also
      described later in this document.
    </DIV>
    <DIV>
      <H3>
	<A NAME="2.2">2.2. Referring to a Stylesheet from XML</A>
      </H3>
      <P>
      The XML WG is defining mechanisms to associate XML documents with stylesheets.
      Until this work has been completed, it is recommended that XSL implementations
      use the <CODE>xml-stylesheet</CODE> processing instruction proposal. For
      example, this line would be included in the XML source file:
      <BLOCKQUOTE>
	<PRE>&lt;?xml-stylesheet href="article.xsl" type="text/xsl" ?&gt;
</PRE>
      </BLOCKQUOTE>
    </DIV>
    <DIV>
      <H3>
	<A NAME="2.3">2.3. Import</A>
      </H3>
      <P>
      An XSL stylesheet may import other XSL stylesheets, by using an
      <CODE>import</CODE> element with an <CODE>href</CODE> attribute:
      <BLOCKQUOTE>
	<PRE>&lt;import href="article.xsl"/&gt;
</PRE>
      </BLOCKQUOTE>
      <P>
      Using an <CODE>import</CODE> element is exactly equivalent to textually including
      the resource located by the value of the <CODE>href</CODE> attribute.
    </DIV>
  </DIV>
  <DIV>
    <H2>
      <A NAME="3">3. Rules</A>
    </H2>
    <DIV>
      <H3>
	<A NAME="3.1">3.1. Overview</A>
      </H3>
      <P>
      A rule is specified with the <CODE>rule</CODE> element. The <CODE>rule</CODE>
      element contains a <I>pattern</I> that identifies the source element to which
      this rule applies. The <CODE>rule</CODE> also contains an <I>action</I> that
      specifies the flow objects to construct.
      <P>
      For example, an XML document contains the following:
      <BLOCKQUOTE>
	<PRE>This is an &lt;emph&gt;important&lt;/emph&gt; point.
</PRE>
      </BLOCKQUOTE>
      <P>
      The following XSL rule contains a pattern which identifies elements of type
      <CODE>emph</CODE> and an action which produces a <CODE>SPAN</CODE> flow object
      with the characteristic <CODE>font-weight="bold"</CODE>.
      <BLOCKQUOTE>
	<PRE>&lt;rule&gt;
  &lt;!-- pattern --&gt;
  &lt;target-element type="emph"/&gt;
  
  &lt;!-- action --&gt;
  &lt;SPAN font-weight="bold"&gt;
    &lt;children/&gt;
  &lt;/SPAN&gt;
&lt;/rule&gt;
</PRE>
      </BLOCKQUOTE>
      <P>
      <SMALL><I>Note: this example uses HTML/CSS core flow objects.</I></SMALL>
      <P>
      As detailed later in this document, the <CODE>children</CODE> element recursively
      processes the children of the source element.
      <P>
      A rule may have multiple patterns associated with a single action. This example
      constructs a <CODE>SPAN</CODE> for either <CODE>emph</CODE> or
      <CODE>strong</CODE> element patterns:
      <BLOCKQUOTE>
	<PRE>&lt;rule&gt;
  &lt;target-element type="emph"/&gt;
  &lt;target-element type="strong"/&gt;
  &lt;SPAN font-weight="bold"&gt;
    &lt;children/&gt;
  &lt;/SPAN&gt;
&lt;/rule&gt;
</PRE>
      </BLOCKQUOTE>
      <P>
      <SMALL><I>Note: this example uses HTML/CSS core flow objects.</I></SMALL>
    </DIV>
    <DIV>
      <H3>
	<A NAME="3.2">3.2. Patterns</A>
      </H3>
      <DIV>
	<H4>
	  <A NAME="3.2.1">3.2.1. Elements</A>
	</H4>
	<P>
	The pattern part of a construction rule must contain a
	<CODE>target-element</CODE> element which indicates the source element to
	which the rule applies. The pattern also allows identifying applicable elements
	by their context within the source, including:
	<OL>
	  <LI>
	    element ancestry;
	  <LI>
	    element descendants;
	  <LI>
	    wildcards in the ancestry/descendant hierarchy (arbitrary ancestors/descendants);
	  <LI>
	    attributes on an element;
	  <LI>
	    position of an element relative to its siblings;
	  <LI>
	    uniqueness of an element relative to its siblings.
	</OL>
	<P>
	Element ancestry can be represented within the pattern by mirroring the hierarchy
	found in the source document. The <CODE>element</CODE> element has identical
	attributes to the <CODE>target-element</CODE>, but implies that the source
	element named by its <CODE>type</CODE> attribute is part of the context of
	the applicable element in the source rather than the element to which this
	rule will be applied. The containment hierarchy of the <CODE>element</CODE>
	elements in the pattern indicate their contextual relationship to the
	<CODE>target-element</CODE> element in the source.
	<P>
	For example, the following pattern matches <CODE>title</CODE> source elements
	that have a <CODE>section</CODE> element as a parent and a
	<CODE>chapter</CODE> element as a grandparent:
	<BLOCKQUOTE>
	  <PRE>&lt;element type="chapter"&gt;
  &lt;element type="section"&gt;
    &lt;target-element type="title"/&gt;
  &lt;/element&gt;
&lt;/element&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	Children of the applicable source document element can be specified in a
	similar fashion. The following pattern matches <CODE>table</CODE> source
	elements that have a <CODE>title</CODE> child:
	<BLOCKQUOTE>
	  <PRE>&lt;target-element type="table"&gt;
  &lt;element type="title"/&gt;
&lt;/target-element&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	Multiple <CODE>element</CODE> elements can be placed inside a
	<CODE>target-element</CODE> element. This indicates only that all these elements
	must be present, not in any particular order. The following pattern matches
	<CODE>employee</CODE> elements that contain both an <CODE>exempt</CODE> element,
	and an <CODE>high-paid</CODE> element:
	<BLOCKQUOTE>
	  <PRE>&lt;target-element type="employee"&gt;
  &lt;element type="exempt"/&gt;
  &lt;element type="high-paid"/&gt;
&lt;/target-element&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	The root of the source document tree can be identified within the special
	root pattern <CODE>&lt;root/&gt;</CODE>.
	<BLOCKQUOTE>
	  <PRE>&lt;rule&gt;
  &lt;root/&gt;
  &lt;HTML&gt;
    &lt;BODY&gt;
      &lt;children/&gt;
    &lt;/BODY&gt;
  &lt;/HTML&gt;
&lt;/rule&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	<SMALL><I>Note: this example uses HTML/CSS core flow objects.</I></SMALL>
      </DIV>
      <DIV>
	<H4>
	  <A NAME="3.2.2">3.2.2. Wildcards</A>
	</H4>
	<P>
	Ancestry or descendancy beyond an unbroken sequence of immediate parents
	or immediate children can also be specified as part of the context for
	determining whether a rule applies to a given source element. Wildcards can
	be specified within the pattern with the <CODE>any</CODE> element. The
	<CODE>any</CODE> element matches zero or more elements within the source
	element hierarchy.
	<P>
	This example applies to a <CODE>para</CODE> element that has a
	<CODE>appendix</CODE> ancestor, and also has a <CODE>changed</CODE> descendant.
	<BLOCKQUOTE>
	  <PRE>&lt;element type="appendix"&gt;
  &lt;any&gt;
    &lt;target-element type="para"&gt;
      &lt;any&gt;
        &lt;element type="changed"/&gt;
      &lt;/any&gt;
    &lt;/target-element&gt;
  &lt;/any&gt;
&lt;/element&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	Both <CODE>target-element</CODE> and <CODE>element</CODE> elements can be
	used as wildcards by omitting the <CODE>type</CODE> attribute. In this case,
	these elements match exactly one element in the source element hierarchy.
	The following pattern matches elements that have a grandparent of type
	<CODE>data-samples</CODE>, regardless of the type of the target element or
	the parent element.
	<BLOCKQUOTE>
	  <PRE>&lt;element type="data-samples"&gt;
  &lt;element&gt;
    &lt;target-element/&gt;
  &lt;/element&gt;
&lt;/element&gt;
</PRE>
	</BLOCKQUOTE>
      </DIV>
      <DIV>
	<H4>
	  <A NAME="3.2.3">3.2.3. Attributes</A>
	</H4>
	<P>
	Attributes on the source element or any of its ancestor or descendant elements
	can also be used to determine whether a particular construction rule applies.
	The <CODE>attribute</CODE> element is included in an <CODE>element</CODE>
	or <CODE>target-element</CODE> element to test the value of a source attribute.
	<P>
	The following example matches an <CODE>item</CODE> element that has for its
	parent a <CODE>list</CODE> element whose <CODE>liststyle</CODE> attribute
	has the value <CODE>enum</CODE>:
	<BLOCKQUOTE>
	  <PRE>&lt;element type="list"&gt;
  &lt;attribute name="liststyle" value="enum"/&gt;
  &lt;target-element type="item"/&gt;
&lt;/element&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	Simple presence or absence of an attribute can also be tested. When the
	<CODE>has-value</CODE> attribute has the value <CODE>yes</CODE>, a source
	element matches the pattern when the attribute in question has been given
	a value in the source (either by an explicit assignment or by receiving a
	default value). When the <CODE>has-value</CODE> attribute has the value
	<CODE>no</CODE>, a source element matches the pattern when the default value
	of the source attribute is <CODE>#IMPLIED</CODE> and the source attribute
	has no explicit assignment. If the <CODE>value</CODE> attribute has been
	assigned, the <CODE>has-value</CODE> attribute is ignored.
	<P>
	The following example matches an <CODE>item</CODE> element that has for its
	parent a <CODE>list</CODE> element whose <CODE>compact</CODE> attribute has
	some value (as opposed to being left unassigned and implied):
	<BLOCKQUOTE>
	  <PRE>&lt;element type="list"&gt;
  &lt;attribute name="compact" has-value="yes"/&gt;
  &lt;target-element type="item"/&gt;
&lt;/element&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	Multiple attribute elements can be applied to a single
	<CODE>target-element</CODE> or <CODE>element</CODE> element.
	<BLOCKQUOTE>
	  <PRE>&lt;target-element type="reference"&gt;
  &lt;attribute type="href" has-value="yes"/&gt;
  &lt;attribute type="used-as" value="direct-quote"/&gt;
&lt;/target-element&gt;
</PRE>
	</BLOCKQUOTE>
      </DIV>
      <DIV>
	<H4>
	  <A NAME="3.2.4">3.2.4. ID and CLASS Attributes</A>
	</H4>
	<P>
	Like CSS, XSL gives special treatment to two categories of attribute,
	<I>id</I> attributes and <I>class</I> attributes.
	<P>
	A source element attribute is in the id category if it was declared as an
	<CODE>ID</CODE> in the source DTD. XSL must work with XML documents that
	do not have a DTD; therefore XSL also allows stylesheets to specify source
	element attributes that should be in the id category. This is done using
	an <CODE>id</CODE> element, with an <CODE>attribute</CODE> attribute specifying
	the name of the attribute that should be in the id category. The following
	would put a <CODE>name</CODE> attribute on any element in the id category.
	<BLOCKQUOTE>
	  <PRE>&lt;id attribute="name"/&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	A <CODE>target-element</CODE> or <CODE>element</CODE> element can specify
	an <CODE>id</CODE> attribute. This will match a source element that has an
	attribute in the id category with the same value.
	<P>
	In a stylesheet a <CODE>class</CODE> element is used to declare the name
	of an attribute that should be in the class category. For example, the following
	would put a <CODE>family</CODE> attribute on any element in the class category:
	<BLOCKQUOTE>
	  <PRE>&lt;class attribute="family"/&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	An <CODE>element</CODE> or <CODE>target-element</CODE> element can specify
	a <CODE>class</CODE> attribute. This will match a source element that has
	an attribute in the class category with the same value.
      </DIV>
      <DIV>
	<H4>
	  <A NAME="3.2.5">3.2.5. Qualifiers</A>
	</H4>
	<P>
	There are two qualifiers, <CODE>position</CODE> and <CODE>only</CODE>, each
	expressed as an attribute on the <CODE>element</CODE> and
	<CODE>target-element</CODE> elements.
	<P>
	The <CODE>position</CODE> qualifier specifies the position of an element
	among its siblings. The values of the <CODE>position</CODE> qualifier are:
	<UL>
	  <LI>
	    <CODE>first-of-type</CODE>. The element must be the first sibling of its
	    type.
	  <LI>
	    <CODE>last-of-type</CODE>. The element must be the last sibling of its type.
	  <LI>
	    <CODE>first-of-any</CODE>. The element must be the first sibling of any type.
	  <LI>
	    <CODE>last-of-any</CODE>. The element must be the last sibling of any type.
	</UL>
	<P>
	The <CODE>only</CODE> qualifier specifies whether the source element has
	any siblings or not. Its values are:
	<UL>
	  <LI>
	    <CODE>of-type</CODE>. The element must have no element siblings of the same
	    type.
	  <LI>
	    <CODE>of-any</CODE>. The element must have no element siblings at all.
	</UL>
	<P>
	The following pattern matches the <I>first</I> <CODE>item</CODE> in a
	<CODE>list</CODE>:
	<BLOCKQUOTE>
	  <PRE>&lt;element type="list"&gt;
  &lt;target-element type="item" position="first-of-type"/&gt;
&lt;/element&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	The following pattern matches the <I>only</I> <CODE>item</CODE> in a
	<CODE>list</CODE>:
	<BLOCKQUOTE>
	  <PRE>&lt;element type="list"&gt;
  &lt;target-element type="item" only="of-type"/&gt;
&lt;/element&gt;
</PRE>
	</BLOCKQUOTE>
      </DIV>
      <DIV>
	<H4>
	  <A NAME="3.2.6">3.2.6. Conflicts</A>
	</H4>
	<P>
	It is possible for a source element to match patterns in several different
	rules. XSL has an algorithm for determining which rules should be invoked
	in this situation. It also allows the stylesheet to override this by specifying
	<CODE>importance</CODE> and <CODE>priority</CODE> attributes on the
	<CODE>rule</CODE> and <CODE>style-rule</CODE> elements.
	<P>
	When an element matches more than one pattern, then the <I>most specific</I>
	pattern will be used. The precedence order for establishing the most specific
	pattern is:
	<OL>
	  <LI>
	    the pattern with the highest importance; the importance of a pattern is the
	    value of the <CODE>importance</CODE> attribute on the rule that contains
	    it; this allows the CSS <CODE>!important</CODE> feature to be supported
	  <LI>
	    the pattern with the greater number of <CODE>id</CODE> attributes
	  <LI>
	    the pattern with the greater number of <CODE>class</CODE> attributes
	  <LI>
	    the pattern with the greater number of <CODE>element</CODE> or
	    <CODE>target-element</CODE> elements that have a <CODE>type</CODE> attribute
	  <LI>
	    the pattern with fewer wildcards; a wildcard is an <CODE>any</CODE> element,
	    an <CODE>element</CODE> element without a <CODE>type</CODE> attribute, or
	    a <CODE>target-element</CODE> element without a <CODE>type</CODE> attribute
	  <LI>
	    the pattern with the higher specified priority; the priority of a pattern
	    is the priority of the rule that contains it; the priority of a pattern is
	    the value of the <CODE>priority</CODE> attribute on the rule that contains
	    it
	  <LI>
	    the pattern with the greater number of <CODE>only</CODE> qualifiers
	  <LI>
	    the pattern with the greater number of <CODE>position</CODE> qualifiers
	  <LI>
	    the pattern with the greater number of <CODE>attribute</CODE> specifications
	</OL>
	<P>
	When determining which of two matching patterns is the more specific, the
	above criteria are applied in order until one of the criteria identifies
	exactly one of the patterns as most specific.
	<P>
	For construction rules, it is an error if, for any source element, there
	is not a unique matching pattern that is more specific than all other matching
	patterns.
      </DIV>
    </DIV>
    <DIV>
      <H3>
	<A NAME="3.3">3.3. Actions</A>
      </H3>
      <DIV>
	<H4>
	  <A NAME="3.3.1">3.3.1. Overview</A>
	</H4>
	<P>
	When the rule that is to be applied to the source element has been identified,
	the <I>action</I> part of the rule is invoked. The structure of the elements
	comprising the action represents the structure of flow objects to create.
	<P>
	Flow object elements may be combined with literal text (which generates character
	flow objects) and programmatically generated text (<CODE>eval</CODE> element)
	to create a flow object sub-tree.
	<BLOCKQUOTE>
	  <PRE>&lt;rule&gt;
  &lt;!-- pattern --&gt;
  &lt;target-element type="chapter"/&gt;

		
  &lt;!-- action --&gt;
  &lt;sequence&gt;
    &lt;horizontal-rule/&gt;
    &lt;paragraph space-before="2pt"&gt;
      Chapter
      &lt;eval&gt;formatNumber(element.childNumber(),'001')&lt;/eval&gt;
      :
      &lt;children/&gt;
    &lt;/paragraph&gt;
    &lt;horizontal-rule/&gt;
  &lt;/sequence&gt;
&lt;/rule&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	<SMALL><I>Note: this example uses DSSSL core flow objects.</I></SMALL>
      </DIV>
      <DIV>
	<H4>
	  <A NAME="3.3.2">3.3.2. Characteristics as Attributes</A>
	</H4>
	<P>
	The characteristics of the flow objects are applied as attributes of the
	element representing the flow object. For the HTML core flow objects, CSS
	properties can be directly applied as attributes without the use of the HTML
	<CODE>STYLE</CODE> attribute, as in this example:
	<BLOCKQUOTE>
	  <PRE>&lt;rule&gt;
  &lt;target-element type="para"/&gt;
  &lt;DIV font-family="Courier"
       font-size="12pt"
       font-style="normal"
       text-align="justify"
       margin-top="10pt"
       margin-bottom="6pt"&gt;
    &lt;children/&gt;
  &lt;/DIV&gt;
&lt;/rule&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	<SMALL><I>Note: this example uses HTML/CSS core flow objects.</I></SMALL>
	<P>
	All attributes of flow object elements are of type <I>string</I>.
      </DIV>
      <DIV>
	<H4>
	  <A NAME="3.3.3">3.3.3. Selection within an Action</A>
	</H4>
	<P>
	Selection within an action controls which source elements are processed after
	a rule fires. There are two elements used, the <CODE>children</CODE> element
	and the <CODE>select</CODE> element. The <CODE>children</CODE> element processes
	the immediate children of the source element while the <CODE>select</CODE>
	element processes either the children or the descendants of the source element,
	and provides powerful filtering through the use of patterns.
	<P>
	This example creates a display-group for a <CODE>chapter</CODE> element and
	then processes its immediate children.
	<BLOCKQUOTE>
	  <PRE>&lt;rule&gt;
  &lt;target-element type="chapter"/&gt;
  &lt;display-group&gt;
    &lt;children/&gt;
  &lt;/display-group&gt;
&lt;/rule&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	<SMALL><I>Note: this example uses DSSSL core flow objects.</I></SMALL>
	<P>
	The above example could also be written using the <CODE>select</CODE> element
	with the <CODE>from</CODE> attribute set to <CODE>children</CODE>.
	<BLOCKQUOTE>
	  <PRE>&lt;rule&gt;
  &lt;target-element type="chapter"/&gt;
  &lt;display-group&gt;
    &lt;select from="children"/&gt;
  &lt;/display-group&gt;
&lt;/rule&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	<SMALL><I>Note: this example uses DSSSL core flow objects.</I></SMALL>
	<P>
	The values of the <CODE>from</CODE> attribute are:
	<UL>
	  <LI>
	    <CODE>children</CODE>. The children of the element are processed, the default.
	  <LI>
	    <CODE>descendants</CODE>. The descendants of the element are processed.
	</UL>
	<P>
	The <CODE>select</CODE> element, by default, processes the immediate children
	of the source element. To process all of the descendants of the source element
	the <CODE>from</CODE> attribute can be set to <CODE>descendants</CODE>. This
	example processes all of the <CODE>heading</CODE> elements contained in the
	<CODE>book</CODE> element.
	<BLOCKQUOTE>
	  <PRE>&lt;rule&gt;
  &lt;target-element type="book"/&gt;
  &lt;paragraph&gt;
    &lt;select from="descendants"&gt;
      &lt;target-element type="heading"/&gt;
    &lt;/select&gt;
  &lt;/paragraph&gt;
&lt;/rule&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	<SMALL><I>Note: this example uses DSSSL core flow objects.</I></SMALL>
	<P>
	Filters can be added to the <CODE>select</CODE> element to further control
	which elements are processed. Only elements that match the filter pattern
	are processed. The filter pattern uses the same syntax as the pattern part
	of the rule. In this example, after creating a paragraph for the
	<CODE>employee</CODE> element, the <CODE>exempt</CODE> children are selected
	for processing.
	<BLOCKQUOTE>
	  <PRE>&lt;rule&gt;
  &lt;target-element type="employee"/&gt;
  &lt;paragraph&gt;
    &lt;select&gt;
      &lt;target-element type="exempt"/&gt;
    &lt;/select&gt;
  &lt;/paragraph&gt;
&lt;/rule&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	<SMALL><I>Note: this example uses DSSSL core flow objects.</I></SMALL>
	<P>
	Multiple <CODE>children</CODE> or <CODE>select</CODE> elements can be used
	within a single action to do simple reordering. The following example creates
	two tables. The first table is filled with domestic sales while the second
	table is filled with foreign sales.
	<BLOCKQUOTE>
	  <PRE>&lt;rule&gt;
  &lt;target-element type="product"/&gt;
  
  &lt;display-group&gt;
    &lt;table&gt;
      &lt;select from="descendants"&gt;
        &lt;element type="sales"&gt;
          &lt;target-element type="domestic"/&gt;
        &lt;/element&gt;
      &lt;/select&gt;
    &lt;/table&gt;
    &lt;table&gt;
      &lt;select from="descendants"&gt;
        &lt;element type="sales"&gt;
          &lt;target-element type="foreign"/&gt;
        &lt;/element&gt;
      &lt;/select&gt;
    &lt;/table&gt;
  &lt;/display-group&gt;
&lt;/rule&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	<SMALL><I>Note: this example uses DSSSL core flow objects.</I></SMALL>
	<P>
	By default, the <CODE>children</CODE> element and the <CODE>select</CODE>
	element process children of the element matched by the rule's pattern. The
	<CODE>ancestor</CODE> attribute is used to process children relative to an
	element higher up in the document. This example finds an employee's department
	and then processes the <CODE>group</CODE> children of the
	<CODE>department</CODE>.
	<BLOCKQUOTE>
	  <PRE>&lt;rule&gt;
  &lt;target-element type="employee"/&gt;
  &lt;paragraph&gt;
    &lt;select ancestor="department"/&gt;
      &lt;target-element type="group"/&gt;
    &lt;/select&gt;
  &lt;/paragraph&gt;
&lt;/rule&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	<SMALL><I>Note: this example uses DSSSL core flow objects.</I></SMALL>
      </DIV>
      <DIV>
	<H4>
	  <A NAME="3.3.4">3.3.4. Flow Object Macros</A>
	</H4>
	<P>
	Actions can also be factored out of similar rules into macros for reuse.
	Macros allow authors to create aggregate flow objects and refer to the composite
	as if it were a single flow object. In this example, a macro is defined for
	a boxed paragraph with the word &#147;Warning!&#148; preceding the contents.
	The macro is referenced from a rule for <CODE>warning</CODE> elements.
	<BLOCKQUOTE>
	  <PRE>&lt;define-macro name="warning-para"&gt;
  &lt;box&gt;
    &lt;paragraph&gt;
      Warning!
      &lt;contents/&gt;
    &lt;/paragraph&gt;
  &lt;/box&gt;
&lt;/define-macro&gt;

		
&lt;rule&gt;
  &lt;target-element type="warning"/&gt;
  &lt;warning-para font-size="14pt"&gt;
    &lt;children/&gt;
  &lt;/warning-para&gt;
&lt;/rule&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	<SMALL><I>Note: this example uses DSSSL core flow objects.</I></SMALL>
	<P>
	The <CODE>contents</CODE> element in the macro refers to the contents of
	the macro reference (in this case the <CODE>children</CODE> element).
	<P>
	Macros allow arguments and argument defaults to be specified with the
	<CODE>arg</CODE> element. Defaults can be assigned to the arguments. The
	arguments can be accessed inside the macro with the expression syntax
	(&#147;=&#148; + <I>argument name</I>). This example defines a macro for
	a <CODE>list-item</CODE> with arguments controlling the indent and the string
	to use as a marker (i.e. bullet).
	<BLOCKQUOTE>
	  <PRE>&lt;define-macro name="list-item"&gt;
  &lt;arg name="marker" default=""/&gt;
  &lt;arg name="indent" default="0.25in"/&gt;
  &lt;paragraph
      first-line-start-indent="=-indent"
      start-indent="=indent"&gt;
    &lt;line-field field-width="=indent"&gt;
      &lt;eval&gt;marker&lt;/eval&gt;
    &lt;/line-field&gt;
    &lt;contents/&gt;
  &lt;/paragraph&gt;
&lt;/define-macro&gt;

		
&lt;rule&gt;
  &lt;target-element type="item"/&gt;
  &lt;list-item marker="+"&gt;
    &lt;children/&gt;
  &lt;/list-item&gt;
&lt;/rule&gt;
</PRE>
	</BLOCKQUOTE>
	<P>
	<SMALL><I>Note: this example uses DSSSL core flow objects.</I></SMALL>
	<P>
	For users that wish to create stylesheets that are valid with respect to
	a single, fixed DTD for all XSL stylesheets, there is an alternative syntax
	for macro invocation.
	<BLOCKQUOTE>
	  <PRE>&lt;rule&gt;
  &lt;target-element type="item"/&gt;
  &lt;invoke macro="list-item"&gt;
    &lt;arg name="marker" value="+"&gt;
    &lt;children/&gt;
  &lt;/invoke&gt;
&lt;/rule&gt;
</PRE>
	</BLOCKQUOTE>
      </DIV>
    </DIV>
    <DIV>
      <H3>
	<A NAME="3.4">3.4. Default Construction Rule</A>
      </H3>
      <P>
      There is a built-in default construction rule to allow recursive processing
      to continue in the absence of a successful pattern match. The author is free
      to override the default rule by specifying his own default rule.
      <BLOCKQUOTE>
	<PRE>&lt;rule&gt;
  &lt;target-element/&gt;
  &lt;children/&gt;
&lt;/rule&gt;
</PRE>
      </BLOCKQUOTE>
    </DIV>
  </DIV>
  <DIV>
    <H2>
      <A NAME="4">4. Styles</A>
    </H2>
    <P>
    An XML element can be associated with flow object characteristics through
    <I>style rules</I>. Style rules, like construction rules, consist of a pattern
    and an action. The pattern selects the element from the source document while
    the action specifies flow object characteristics.
    <P>
    Here is an example of a simple style rule that makes all <CODE>emph</CODE>
    elements <CODE>bold</CODE>:
    <BLOCKQUOTE>
      <PRE>&lt;style-rule&gt;
  &lt;target-element type="emph"/&gt;
  &lt;apply font-weight="bold"/&gt;
&lt;/style-rule&gt;
</PRE>
    </BLOCKQUOTE>
    <P>
    An important distinction between style rules and construction rules is that
    style rules do not create flow objects.
    <P>
    Style rules support the CSS feature that more than one stylesheet rule can
    contribute properties (characteristics) to an element's presentation. For
    example, the following CSS rules would make the font-weight of
    <CODE>strong</CODE> elements inside of <CODE>h1</CODE> elements
    &#147;bold&#148; as well as making their color &#147;red&#148;.
    <BLOCKQUOTE>
      <PRE>h1 {font-weight:bold; color:blue}
h1 strong {color:red}
</PRE>
    </BLOCKQUOTE>
    <P>
    The above CSS could be written in XSL as:
    <BLOCKQUOTE>
      <PRE>&lt;style-rule&gt;
  &lt;target-element type="h1"/&gt;
  &lt;apply font-weight="bold" color="blue"/&gt;
&lt;/style-rule&gt;

		
&lt;style-rule&gt;
  &lt;element type="h1"&gt;
    &lt;any&gt;
      &lt;target-element type="strong"/&gt;
    &lt;/any&gt;
  &lt;/element&gt;

		
  &lt;apply color="red"/&gt;
&lt;/style-rule&gt;
</PRE>
    </BLOCKQUOTE>
    <DIV>
      <H3>
	<A NAME="4.1">4.1. Named Styles</A>
      </H3>
      <P>
      A style object contains a set of characteristics. The definition of a style
      object creates a named style. A flow object element can specify a style name
      as the value of the <CODE>use</CODE> attribute. A style rule can use an element
      with the style name instead of <CODE>apply</CODE> as its action. This allows
      augmenting a named style with characteristics from the style rule.
      <P>
      The following example creates a style named &#147;title-style&#148; and uses
      it in a style rule and in a construction rule.
      <BLOCKQUOTE>
	<PRE>&lt;define-style name="title-style"
              font-size="12pt"
              font-weight="bold"/&gt;

		
&lt;style-rule&gt;
  &lt;target-element type="title"/&gt;
  &lt;title-style quadding="center"/&gt;
&lt;/style-rule&gt;

		
&lt;rule&gt;
  &lt;element type="chapter"&gt;
    &lt;target-element type="heading"/&gt;
  &lt;/element&gt;
  &lt;paragraph use="title-style" quadding="start"&gt;
    &lt;children/&gt;
  &lt;/paragraph&gt;
&lt;/rule&gt;
</PRE>
      </BLOCKQUOTE>
      <P>
      <SMALL><I>Note: this example uses DSSSL core flow objects.</I></SMALL>
      <P>
      For users that wish to create XSL that is valid with respect to a single,
      fixed DTD for all XSL stylesheets, there is an alternative syntax for using
      named styles.
      <BLOCKQUOTE>
	<PRE>&lt;style-rule&gt;
  &lt;target-element type="title"/&gt;
  &lt;apply use="title-style" quadding="center"/&gt;
&lt;/style-rule&gt;
</PRE>
      </BLOCKQUOTE>
    </DIV>
    <DIV>
      <H3>
	<A NAME="4.2">4.2. Inline Style</A>
      </H3>
      <P>
      For the rare cases where it is inconvenient to fully define the formatting
      style in the stylesheet, XSL provides two mechanisms for source document
      overrides of style characteristics:
      <UL>
	<LI>
	  Adding formatting attributes to an element instance and a style attribute
	  that references these in the rule for that element type in the stylesheet.
	<LI>
	  Adding an id attribute on a particular element instance and adding a rule
	  at the beginning of the instance with a pattern matching the value of this
	  id.
      </UL>
      <P>
      Inherited characteristics can be specified on a particular instance of an
      element type in the source document. They are qualified by the xsl namespace.
      (The viability of this solution depends on the XML namespace proposal submitted
      to the W3C).
      <BLOCKQUOTE>
	<PRE>&lt;para xsl::font-weight="bold"&gt;
</PRE>
      </BLOCKQUOTE>
      <P>
      <SMALL><I>Note: This example illustrates source document markup, not XSL
      stylesheet markup.</I></SMALL>
      <P>
      The stylesheet rule for the element type may include a <CODE>use</CODE> attribute
      on a flow object element with a value <CODE>#source</CODE> to apply any
      attributes on the source element in the xml namespace whose name matches
      an inherited DSSSL characteristic.
      <BLOCKQUOTE>
	<PRE>&lt;rule&gt;
  &lt;target-element type="para"/&gt;
  &lt;DIV use="#source"&gt;
    &lt;children/&gt;
  &lt;/DIV&gt;
&lt;/rule&gt;
</PRE>
      </BLOCKQUOTE>
      <P>
      <SMALL><I>Note: this example uses HTML/CSS core flow objects.</I></SMALL>
      <P>
      In this case, the characteristics specified on the instance will override
      any characteristics specified in the stylesheet.
      <P>
      A document instance may contain XSL rules at the beginning. These rules may
      have patterns identifying elements with specific ids.
      <BLOCKQUOTE>
	<PRE>&lt;rule&gt;
  &lt;target-element id="myoverride"/&gt;
  &lt;DIV font-weight="bold"&gt;
    &lt;children/&gt;
  &lt;/DIV&gt;
&lt;/rule&gt;
...
&lt;para id="myoverride"&gt;
</PRE>
      </BLOCKQUOTE>
      <P>
      <SMALL><I>Note: this example uses HTML/CSS core flow objects.</I></SMALL>
    </DIV>
  </DIV>
  <DIV>
    <H2>
      <A NAME="5">5. Modes</A>
    </H2>
    <P>
    Sometimes source elements need to be displayed in several different places.
    For example, a <CODE>title</CODE> element may need to be displayed in a table
    of contents as well as in the body. In each place the source element may
    need to be formatted differently.
    <P>
    This can be achieved in XSL using a <I>mode</I>. An element may be processed
    with respect to a named mode. A rule can be associated with a named mode
    using the <CODE>mode</CODE> attribute on a rule. Such a rule can only be
    invoked when an element is being processed using the rule's mode. The
    <CODE>children</CODE> and <CODE>select</CODE> elements can change to a named
    mode by specifying a <CODE>mode</CODE> attribute.
    <BLOCKQUOTE>
      <PRE>&lt;rule&gt;
  &lt;root/&gt;
  &lt;HTML&gt;
    &lt;BODY&gt;
      &lt;DIV name="table-of-contents"&gt;
       &lt;children mode="toc-mode"/&gt;
     &lt;/DIV&gt;
     &lt;children/&gt;
    &lt;/BODY&gt;
  &lt;/HTML&gt;
&lt;/rule&gt;

		
&lt;rule&gt;
  &lt;target-element type="title"/&gt;
  &lt;DIV font-size="14pt" font-weight="bold"&gt;
    &lt;children/&gt;
  &lt;/DIV&gt;
&lt;/rule&gt;

		
&lt;rule mode="toc-mode"&gt;
  &lt;target-element type="title"/&gt;
  &lt;DIV font-size="12pt"&gt;
     &lt;children/&gt;
  &lt;/DIV&gt;
&lt;/rule&gt;
</PRE>
    </BLOCKQUOTE>
    <P>
    <SMALL><I>Note: this example uses HTML/CSS core flow objects.</I></SMALL>
  </DIV>
  <DIV>
    <H2>
      <A NAME="6">6. Flow Objects</A>
    </H2>
    <DIV>
      <H3>
	<A NAME="6.1">6.1. DSSSL Core Flow Objects</A>
      </H3>
      <P>
      DSSSL flow objects support a powerful and extensible formatting model. The
      model is internationalized so that a single stylesheet can be used to format
      documents in natural languages with different writing directions. The following
      are the subset of DSSSL flow objects that are proposed for use in XSL. Refer
      to the DSSSL standard for more information on these flow objects and their
      characteristics.
      <UL>
	<LI>
	  scroll&#151;used for online display
	<LI>
	  paragraph, paragraph-break&#151;used for paragraphs
	<LI>
	  character&#151;used for text
	<LI>
	  line-field&#151;used for lists
	<LI>
	  external-graphic&#151;used for including graphic images
	<LI>
	  horizontal-rule, vertical-rule&#151;used for horizontal rules (note that
	  the DSSSL &#147;rule&#148; flow object will be split into these two rules
	  to eliminate the name conflict). (like HR in HTML) and vertical rules
	<LI>
	  score&#151;used for underlining and scoring
	<LI>
	  embedded-text&#151;used for bi-directional text
	<LI>
	  box&#151;used for borders
	<LI>
	  flow objects for tables
	  <UL>
	    <LI>
	      table
	    <LI>
	      table-part
	    <LI>
	      table-column
	    <LI>
	      table-row
	    <LI>
	      table-cell
	    <LI>
	      table-border
	  </UL>
	<LI>
	  sequence&#151;used for specifying inherited characteristics
	<LI>
	  display-group&#151;used for controlling the positioning of groups of displayed
	  flow objects
	<LI>
	  simple-page-sequence&#151;used for simple page layout
	<LI>
	  link&#151;used for hypertext links
      </UL>
    </DIV>
    <DIV>
      <H3>
	<A NAME="6.2">6.2. HTML/CSS Core Flow Objects</A>
      </H3>
      <P>
      To reduce the initial barriers to adoption, a core set of HTML flow objects
      is recommended in addition to the core DSSSL flow objects. The HTML/CSS
      formatting model is smewhat different from the DSSSL model, and the inclusion
      of the HTML/CSS flow objects will make it possible to use XSL with HTML and
      CSS. It simplifies the targeting of HTML as the output format, and retains
      consistency of the object model and dynamic behaviors.
      <P>
      The characteristics on the flow objects consist of the sum of the CSS property
      set plus the original HTML attributes where the functionality is not provided
      by the former. Refer to the HTML 3.2 and CSS specifications for more information.
      <UL>
	<LI>
	  SCRIPT
	<LI>
	  PRE
	<LI>
	  HTML
	  <UL>
	    <LI>
	      TITLE
	    <LI>
	      META
	    <LI>
	      BASE
	  </UL>
	<LI>
	  BODY
	<LI>
	  DIV
	<LI>
	  BR
	<LI>
	  SPAN
	<LI>
	  TABLE
	  <UL>
	    <LI>
	      CAPTION
	    <LI>
	      COL
	    <LI>
	      COLGROUP
	    <LI>
	      THEAD
	    <LI>
	      TBODY
	    <LI>
	      TFOOT
	    <LI>
	      TR
	    <LI>
	      TD
	  </UL>
	<LI>
	  A
	<LI>
	  FORM
	  <UL>
	    <LI>
	      INPUT
	    <LI>
	      SELECT
	    <LI>
	      TEXTAREA
	  </UL>
	<LI>
	  HR
	<LI>
	  IMG
	  <UL>
	    <LI>
	      MAP
	    <LI>
	      AREA
	  </UL>
	<LI>
	  OBJECT
	  <UL>
	    <LI>
	      PARAM
	    <LI>
	      FRAMESET
	  </UL>
      </UL>
      <P>
      The following example shows a rule for simple lists using the HTML/CSS core
      flow objects. The first rule provides margins and indenting for the entire
      list; the second provides margins for individual list items. A negative indent
      and fixed width <CODE>SPAN</CODE> on a list item allow the item number to
      be generated and placed to the left of each item.
      <BLOCKQUOTE>
	<PRE>&lt;rule&gt;
  &lt;target-element type="list"/&gt;
  &lt;DIV margin-left="36pt" margin-top="12pt"&gt;
    &lt;children/&gt;
  &lt;/DIV&gt;
&lt;/rule&gt;

		
&lt;rule&gt;
  &lt;element type="list"&gt;
    &lt;attribute name="type" value="enum"/&gt;
    &lt;target-element type="item"/&gt;
  &lt;/element&gt;
  &lt;DIV margin-top="4pt"
       margin-bottom="4pt"
       text-indent="-24pt"&gt;
    &lt;SPAN width="24pt" height="12pt"&gt;
      &lt;eval&gt;
        formatNumber(childNumber(element),"1") + "."
      &lt;/eval&gt;
    &lt;/SPAN&gt;
    &lt;children/&gt;
  &lt;/DIV&gt;
&lt;/rule&gt;
</PRE>
      </BLOCKQUOTE>
      <P>
      <SMALL><I>Note: this example uses HTML/CSS core flow objects.</I></SMALL>
    </DIV>
    <DIV>
      <H3>
	<A NAME="6.3">6.3. Extensibility</A>
      </H3>
      <P>
      XSL will provide a mechanism to allow the specification of new flow object
      classes and characteristics for the new classes, by defining:
      <UL>
	<LI>
	  interfaces for flow object classes and characteristics, and
	<LI>
	  a mechanism in an XSL stylesheet for binding a name of flow object class
	  or characteristic to code that implements these interfaces.
      </UL>
    </DIV>
  </DIV>
  <DIV>
    <H2>
      <A NAME="7">7. Scripting Language</A>
    </H2>
    <DIV>
      <H3>
	<A NAME="7.1">7.1. ECMAScript</A>
      </H3>
      <P>
      The <A HREF="http://www.ecma.ch/">ECMAScript standard</A> provides the basis
      for the XSL scripting language. ECMAScript is the standardized specification
      of JavaScript.
    </DIV>
    <DIV>
      <H3>
	<A NAME="7.2">7.2. Limited Side-effects</A>
      </H3>
      <P>
      The ECMAScript language supports side-effects. However, unrestricted use
      of side-effects in XSL would create serious implementation problems for
      progressive rendering and for handling large documents. In XSL it is an error
      for code in a construction rule to change a global variable, or any object
      reachable from a global variable. It is also an error for code to change
      any object reachable from an object specified as the value of an inherited
      characteristic.
      <P>
      Enforcing these restrictions would be difficult for XSL implementations that
      use existing JavaScript implementations; therefore this is not required of
      XSL implementations. However, the results of applying a stylesheet causing
      side effects is unpredictable in systems that do not enforce the restrictions.
    </DIV>
    <DIV>
      <H3>
	<A NAME="7.3">7.3. Units</A>
      </H3>
      <P>
      The scripting language extends ECMAScript by providing a quantity data type
      which represents lengths and quantities that are derived from lengths, such
      as areas and volumes. The base unit is the SI meter. The name for this unit
      is <CODE>m</CODE>.
      <P>
      The following derived units are defined:
      <UL>
	<LI>
	  <CODE>cm</CODE> (0.01m),
	<LI>
	  <CODE>mm</CODE> (0.001m),
	<LI>
	  <CODE>in</CODE> (0.0254m),
	<LI>
	  <CODE>pc</CODE> (1/6in), and
	<LI>
	  <CODE>pt</CODE> (1/12pc).
      </UL>
      <BLOCKQUOTE>
	<PRE>&lt;paragraph space-before="=0.5in - 3pt"
           start-indent="=childNumber(element) * 12pt"&gt;
  &lt;children/&gt;
&lt;/paragraph&gt;
</PRE>
      </BLOCKQUOTE>
      <P>
      <SMALL><I>Note: this example uses DSSSL core flow objects.</I></SMALL>
      <P>
      Device-dependent quantities such as pixels are handled in XSL by using the
      DSSSL length-spec concept.
    </DIV>
    <DIV>
      <H3>
	<A NAME="7.4">7.4. Built-in Functions</A>
      </H3>
      <P>
      A set of built-in functions will be included. These will be a subset of those
      included in the DSSSL standard.
      <P>
      Since DSSSL names containing hyphens are not valid ECMAScript names, we have
      to convert them to an internal-caps equivalent. This applies to function
      names as well as characteristics and other symbolic names when they appear
      in script.
    </DIV>
    <DIV>
      <H3>
	<A NAME="7.5">7.5. Scripting in XSL</A>
      </H3>
      <P>
      The scripting language can be used in XSL in a number of different ways:
      <P>
      At the top-level (outside of any construction rules), variable declarations
      and function definitions may be specified within a <CODE>define-script</CODE>
      element.
      <BLOCKQUOTE>
	<PRE>&lt;define-script&gt;
  var defaultFontSize = "12pt";

		
  function hierarchicalIndent(elementType, element)
  {
    return length(hierarchicalNumberRecursive(
                  elementType, element)) * 12pt;
  }
&lt;/define-script&gt;
</PRE>
      </BLOCKQUOTE>
      <P>
      <SMALL><I>Note: the DSSSL hierarchicalNumberRecursive function returns an
      array representing the child numbers of the requested element type at each
      hierarchical level. Formatting this list produces a numbering system such
      as the one used in the titles and sub-titles of this document.</I></SMALL>
      <P>
      If the value of an attribute specifying a characteristic (i.e. within the
      action) starts with <CODE>=</CODE>, then the remainder of the attribute is
      treated as an ECMAScript expression.
      <BLOCKQUOTE>
	<PRE>&lt;rule&gt;
  &lt;element type="list"&gt;
    &lt;target-element type="item"&gt;
  &lt;/element&gt;
  &lt;DIV font-size="=defaultFontSize"
       margin-left='=1in + hierarchicalIndent(element, "item")'&gt;
    &lt;children/&gt;
  &lt;/DIV&gt;
&lt;/rule&gt;
</PRE>
      </BLOCKQUOTE>
      <P>
      <SMALL><I>Note: this example uses HTML/CSS core flow objects.</I></SMALL>
      <P>
      Within an action, an <CODE>eval</CODE> element containing an ECMAScript
      expression may be used to compute generated text. The value returned by the
      expression is converted to a string and then to a sequence of character flow
      objects. Alternatively the <CODE>eval</CODE> can also contain a sequence
      of ECMAScript statements. The value returned by a <CODE>return</CODE> statement
      is converted to a string and then to a sequence of character flow objects.
      <BLOCKQUOTE>
	<PRE>&lt;rule&gt;
  &lt;target-element type="title"&gt;
  &lt;DIV&gt;
    &lt;eval&gt;
      formatNumberList(
        hierarchicalNumberRecursive("title", element),
        "", ".")
    &lt;/eval&gt;
    &lt;children/&gt;
  &lt;/DIV&gt;
&lt;/rule&gt;
</PRE>
      </BLOCKQUOTE>
      <P>
      <SMALL><I>Note: this example uses HTML/CSS core flow objects.</I></SMALL>
      <P>
      A <CODE>select</CODE> element can filter an arbitrary node list specified
      by script within the <CODE>from</CODE> attribute. This example finds the
      nearest <CODE>department</CODE> ancestor, and returns the
      <CODE>manager</CODE> children of that element.
      <BLOCKQUOTE>
	<PRE>&lt;select from='=ancestor("department",element)'&gt;
  &lt;target-element type="manager"/&gt;
&lt;/select&gt;
</PRE>
      </BLOCKQUOTE>
    </DIV>
  </DIV>
  <DIV>
    <DIV>
      <H2>
	<ANAME="A">Appendix A: Translated selections from the recommended CSS stylesheet
	for HTML 2.0.
      </H2>
      <P>
      This example shows the use of CSS-compatible <CODE>style-rules</CODE> to
      implement the functionality of the Sample Stylesheet for HTML 2.0 found in
      Appendix A of <A HREF="REC-CSS1" W3MIRHREF="http://www.w3.org/TR/REC-CSS1">Cascading Style Sheets,
      Level 1</A>. DSSSL core flow objects are used.
      <PRE>&lt;xsl&gt;
  &lt;rule&gt;
    &lt;target-element type="BODY"/&gt;
    &lt;scroll
        font-family-name="iso-serif"
        space-before="1in"
        left-margin="1in"
        space-after="1in"
        right-margin="1in"
        line-spacing="=12pt * 1.1"
        background-color="white"
        color="black"&gt;
      &lt;children/&gt;
    &lt;/scroll&gt;
  &lt;/rule&gt;

		
  &lt;rule&gt;
    &lt;target-element type="H1"/&gt;
    &lt;target-element type="H2"/&gt;
    &lt;target-element type="H3"/&gt;
    &lt;target-element type="H4"/&gt;
    &lt;target-element type="H5"/&gt;
    &lt;target-element type="H6"/&gt;
    &lt;target-element type="P"/&gt;
    &lt;target-element type="ADDRESS"/&gt;
    &lt;target-element type="BLOCKQUOTE"/&gt;
    &lt;target-element type="PRE"/&gt;
    
    &lt;paragraph&gt;
      &lt;children/&gt;
    &lt;/paragraph&gt;
  &lt;/rule&gt;

		
  &lt;rule&gt;
    &lt;target-element type="HR"/&gt;
    &lt;horizontal-rule/&gt;
  &lt;/rule&gt;

		
  &lt;rule&gt;
    &lt;target-element type="B"/&gt;
    &lt;target-element type="STRONG"/&gt;
    &lt;target-element type="I"/&gt;
    &lt;target-element type="EM"/&gt;
    &lt;target-element type="CITE"/&gt;
    &lt;target-element type="VAR"/&gt;
    &lt;target-element type="TT"/&gt;
    &lt;target-element type="CODE"/&gt;
    &lt;target-element type="KBD"/&gt;
    &lt;target-element type="SAMP"/&gt;
    &lt;target-element type="SPAN"/&gt;

		
    &lt;sequence&gt;
      &lt;children/&gt;
    &lt;/sequence&gt;
  &lt;/rule&gt;

		
  &lt;rule&gt;
    &lt;target-element type="IMG"/&gt;
    &lt;external-graphic href='=element.href'/&gt;
  &lt;/rule&gt;

		
  &lt;style-rule&gt;
    &lt;target-element type="H1"/&gt;

		
    &lt;apply space-before="1em"
           space-after="1em"
           quadding="center"
           font-weight="bold"
           font-size="24pt"/&gt;
  &lt;/style-rule&gt;

		
  &lt;style-rule&gt;
    &lt;target-element type="H2"/&gt;
    
    &lt;apply space-before="1em"
           space-after="1em"
           font-weight="bold"
           font-size="18pt"/&gt;
  &lt;/style-rule&gt;

		
  &lt;style-rule&gt;
    &lt;target-element type="H3"/&gt;
    
    &lt;apply space-before="1em"
           space-after="1em"
           font-posture="italic"
           font-size="14pt"/&gt;
  &lt;/style-rule&gt;

		
  &lt;style-rule&gt;
    &lt;target-element type="H4"/&gt;
    
    &lt;apply space-before="1em"
           space-after="1em"
           font-weight="bold"/&gt;
  &lt;/style-rule&gt;

		
  &lt;style-rule&gt;
    &lt;target-element type="H5"/&gt;
    
    &lt;apply space-before="1em"
           font-posture="italic"/&gt;
  &lt;/style-rule&gt;

		
  &lt;style-rule&gt;
    &lt;target-element type="B"/&gt;
    &lt;target-element type="STRONG"/&gt;

		
    &lt;apply font-weight="bold"/&gt;
  &lt;/style-rule&gt;

		
  &lt;style-rule&gt;
    &lt;target-element type="I"/&gt;
    &lt;target-element type="CITE"/&gt;
    &lt;target-element type="EM"/&gt;
    &lt;target-element type="VAR"/&gt;

		
    &lt;apply font-posture="italic"/&gt;
  &lt;/style-rule&gt;

		
  &lt;rule&gt;
    &lt;target-element type="PRE"/&gt;
    &lt;target-element type="TT"/&gt;
    &lt;target-element type="CODE"/&gt;
    &lt;target-element type="KBD"/&gt;
    &lt;target-element type="SAMP"/&gt;

		
    &lt;apply font-family-name="iso-monospace"/&gt;
  &lt;/rule&gt;

		
  &lt;style-rule&gt;
    &lt;target-element type="ADDRESS"/&gt;

		
    &lt;apply font-posture="italic"
           start-indent="3em"/&gt;
  &lt;/style-rule&gt;

		
  &lt;style-rule&gt;
    &lt;target-element type="BLOCKQUOTE"/&gt;

		
    &lt;apply font-posture="italic"
           start-indent="3em"
           end-indent="3em"/&gt;
  &lt;/style-rule&gt;
</PRE>
    </DIV>
    <DIV>
      <H2>
	<A NAME="B">Appendix B: Example Stylesheet with Scripting</A>
      </H2>
      <P>
      The following stylesheet is an XSL translation of selections from Jon Bosak's
      DSSSL
      <A HREF="http://sunsite.unc.edu/pub/sun-info/standards/dsssl/stylesheets/html3_2/">stylesheet
      for reading HTML</A>. It shows the combination of declarative constructs
      with script to accomplish the formatting of lists. This example uses DSSSL
      core flow objects.
      <PRE>&lt;xsl&gt;
  &lt;define-script&gt;

		
    var bfSize = 10pt;
    var paraSep = bfSize/2.0;
    var blockSep = paraSep*2.0;
    var bodyStartIndent = 6pc;
    var lineSpacingFactor = 1.1;

		
    function inlist(element) 
    {
      return
        haveAncestor(element, "OL") |
        haveAncestor(element, "UL") |
        haveAncestor(element, "DIR") |
        haveAncestor(element, "MENU") |
        haveAncestor(element, "DL");
    }

		
    function olstep(element)
    {
      var x = length(hierarchicalNumberRecursive(element, "OL")) % 4;
      if (x == 1) return 1.2*bfSize;
      if (x == 2) return 1.2*bfSize;
      if (x == 3) return 1.6*bfSize;
      if (x == 0) return 1.4*bfSize;
    }
  &lt;/define-script&gt;

		
  &lt;define-style name="p-style"
    font-size="=bfSize"
    line-spacing="=bfSize * lineSpacingFactor"/&gt;

		
  &lt;rule&gt;
    &lt;target-element type="OL"/&gt;

		
    &lt;display-group
        space-before="=inlist(element) ? paraSep : blockSep"
        space-after="=inlist(element) ? paraSep : blockSep"
        start-indent="=inlist(element) ? inheritedStartIndent(element) : bodyStartIndent" &gt;
      &lt;children/&gt;
    &lt;/display-group&gt;
  &lt;/rule&gt;

		
  &lt;rule&gt;
    &lt;element type="OL"&gt;
      &lt;target-element type="LI"/&gt;
    &lt;/element&gt;

		
    &lt;paragraph use="p-style"
        space-before='=attributeString(ancestor("OL"), "compact") ? 0 : paraSep'
        start-indent="=inheritedStartIndent(element) + olstep(element)"
        first-line-start-indent="=-olstep(element)" &gt;
      &lt;line-field field-width="=olstep(element)"&gt;
        (
        &lt;eval&gt;
          var child = childNumber(element);
          var x = hierarchicalNumberRecursive("OL") % 4;
          if (x == 1) return formatNumber(child, "1");
          if (x == 2) return formatNumber(child, "a");
          if (x == 3) return formatNumber(child, "i");
          if (x == 0) return formatNumber(child, "a");
        &lt;/eval&gt;
        )
      &lt;/line-field&gt;
      &lt;children/&gt;
    &lt;/paragraph&gt;
  &lt;/rule&gt;

		
  &lt;rule&gt;
    &lt;element type="OL"&gt;
      &lt;element type="LI"&gt;
        &lt;target-element type="P"/&gt;
      &lt;/element&gt;
    &lt;/element&gt;

		
    &lt;paragraph use="p-style"
        start-indent="=inheritedStartIndent(element) + olstep(element)"
        first-line-start-indent="=-olstep(element)" &gt;
      &lt;children/&gt;
    &lt;/paragraph&gt;
  &lt;/rule&gt;

		
&lt;/xsl&gt;
</PRE>
    </DIV>
    <DIV>
      <H2>
	<A NAME="C">Appendix C: A DTD for XSL Rules</A>
      </H2>
      <PRE>&lt;!-- This DTD is for exegesis only.  It assumes that the
action parameter entity has been defined as an or-group
of flow object elements. The style parameter entity is
used to represent an or-group of the apply element
and styles defined with define-style. --&gt;

		
&lt;!ENTITY % pattern "(root | (target-element | element | any)*)"&gt;

		
&lt;!ELEMENT rule (%pattern;, %action;) &gt;

		
&lt;!ELEMENT style-rule (%pattern;, %style)&gt;

		
&lt;!ELEMENT root  EMPTY&gt;

		
&lt;!ATTLIST (rule | style-rule)
        priority   NUMBER     #IMPLIED
        importance NUMBER     #IMPLIED
        mode       NAME       #IMPLIED&gt;

		
&lt;!ELEMENT target-element
        (attribute*, (element+ | any)?)    -(target-element)&gt;

		
&lt;!ELEMENT element
        (attribute*, (target-element | element | any)?) &gt;

		
&lt;!ELEMENT any  EMPTY &gt;

		
&lt;!ATTLIST (target-element | element)
        type      NAME        #IMPLIED
        id        NAME        #IMPLIED
        class     NAME        #IMPLIED
        only    (of-type|of-any)  #IMPLIED
        position  (first-of-type|last-of-type|first-of-any|last-of-any)  #IMPLIED
&gt;

		
&lt;!ELEMENT attribute EMPTY &gt;

		
&lt;!ATTLIST attribute
        name     NAME        #REQUIRED
        value   CDATA      #IMPLIED
        has-value (yes|no)    'yes'
&gt;
</PRE>
    </DIV>
    <DIV>
      <H2>
	<A NAME="D">Appendix D: Acknowledgements</A>
      </H2>
      <P>
      We are grateful to <A HREF="mailto:/Jon.Bosak@eng.Sun.COM">Jon Bosak</A> and
      <A HREF="mailto:/howcome@w3.org">H&aring;kon Wium Lie</A> for their comments
      and feedback.
    </DIV>
  </DIV>
</DIV>
</BODY></HTML>

		
.

NEW PAGES:

[ODDNUGGET]

[GOPHER]