A number of instructions may appear within a template, including comments, processing instructions, elements and attributes.
The instructions allowed directly within a Template element are in some cases also allowed within the instructions themselves (with the exception of the Param element). For convenience, the Template entity is defined to group these elements:
<!ENTITY % template " (#PCDATA %instructions;
%result-elements;)* " >
Elements that refer to this entity include the If, When, Otherwise, With Parameter, Variable, Parameter, Copy, Message and Fallback elements.
A Comment element is defined as follows:
<!ELEMENT xsl:comment %char-template; >
With all entities replaced, the true model is as follows. The fact that all these elements can occur within a comment shows how the content of the comment does not have to be specified as a simple text string; its content can be determined using the full power of XSLT:
<!ELEMENT xsl:comment ( #PCDATA | xsl:apply-templates | xsl:call-template | xsl:apply-imports | xsl:for-each | xsl:value-of | xsl:copy-of | xsl:number | xsl:choose | xsl:if | xsl:text | xsl:copy | xsl:variable | xsl:message | xsl:fallback )* >
The attributes are as follows:
<!ATTLIST xsl:comment %space-att; >
With the entity replaced, the true model is as follows:
<!ATTLIST xsl:comment xml:space (default|preserve) #IMPLIED >
For example:
<xsl:comment xml:space="preserve"> This is a comment. </xsl:comment>
The Processing Instruction element is defined as follows:
<!ELEMENT xsl:processing-instruction %char-template; >
With all entities replaced, the true model is as follows. It is not clear why these elements are allowed to occur here, as they can have no purpose within a processing instruction:
<!ELEMENT xsl:processing-instruction ( #PCDATA | xsl:apply-templates | xsl:call-template | xsl:apply-imports | xsl:for-each | xsl:value-of | xsl:copy-of | xsl:number | xsl:choose | xslif | xsl:text | xsl:copy | xsl:variable | xsl:message | xsl:fallback )* >
The attributes are as follows:
<!ATTLIST xsl:processing-instruction name %avt; #REQUIRED %space-att; >
With all entities replaced, the true model is as follows:
<!ATTLIST xsl:processing-instruction name CDATA #REQUIRED xml:space (default|preserve) #IMPLIED >
For example:
<xsl:processing-instruction name="ACME"> new_page </xsl:processing-instruction>
The Element instruction is defined as follows:
<!ELEMENT xsl:element %template;>
With all entities replaced, the true model is as follows (with any output elements to be added). Note that an element can contain another element, which is necessary to build element hierarchies for output within a single template:
<!ELEMENT xsl:element ( #PCDATA | xsl:apply-templates | xsl:call-template | xsl:apply-imports | xsl:for-each | xsl:value-of | xsl:copy-of | xsl:number | xsl:choose | xslif | xsl:text | xsl:copy | xsl:variable | xsl:message | xsl:fallback | xsl:processing-instruction | xsl:comment | xsl:element | xsl:attribute )* >
The attributes are as follows:
<!ATTLIST xsl:element name %avt; #REQUIRED namespace %avt; #IMPLIED use-attribute-sets %qnames; #IMPLIED %space-att; >
With all entities replaced, the true model is as follows:
<!ATTLIST xsl:element name CDATA #REQUIRED namespace CDATA #IMPLIED use-attribute-sets NMTOKENS #IMPLIED xml:space (default|preserve) #IMPLIED >
For example:
<xsl:element name="TITLE"> A <xsl:element name="EMPH">Title</xsl:element> </xsl:element>
An Attribute instruction is defined as follows:
<!ELEMENT xsl:attribute %char-template;>
With all entities replaced, the true model is as follows (with any output elements to be added). Note that an element can contain another element, which is necessary to build element hierarchies for output within a single template:
<!ELEMENT xsl:attribute ( #PCDATA | xsl:apply-templates | xsl:call-template | xsl:apply-imports | xsl:for-each | xsl:value-of | xsl:copy-of | xsl:number | xsl:choose | xsl:if | xsl:text | xsl:copy | xsl:variable | xsl:message | xsl:fallback )* >
The attributes are as follows:
<!ATTLIST xsl:attribute name %avt; #REQUIRED namespace %avt; #IMPLIED use-attribute-sets %qnames; #IMPLIED %space-att; >
With all entities replaced, the true model is as follows:
<!ATTLIST xsl:attribute name CDATA #REQUIRED namespace CDATA #IMPLIED use-attribute-sets NMTOKENS #IMPLIED xml:space (default|preserve) #IMPLIED >
For example:
<xsl:attribute name="author">J. Smith</xsl:attribute>
An Apply Templates instruction is defined as follows:
<!ELEMENT xsl:apply-templates (xsl:sort|xsl:with-param)*>
The attributes are as follows:
<!ATTLIST xsl:apply-templates select %expr; "node" mode %qname; #IMPLIED >
With all entities replaced, the true model is as follows:
<!ATTLIST xsl:apply-templates select CDATA "node" mode NMTOKEN #IMPLIED >
A Call Template instruction is defined as follows:
<!ELEMENT xsl:call-template (xsl:with-param)* >
The attributes are as follows:
<!ATTLIST xsl:call-template name %qname; #IMPLIED >
With the entity replaced, the true model is as follows:
<!ATTLIST xsl:call-template name NMTOKEN #IMPLIED >
The Apply Imports instruction is defined as follows:
<!ELEMENT xsl:apply-imports EMPTY >
It has no attributes.
For example:
<xsl:apply-imports />
A For Each instruction is defined as follows:
<!ELEMENT xsl:for-each (#PCDATA %instructions;
%result-elements; | xsl:sort )* >
With all entities replaced, the true model is as follows (with any output elements to be added). Note that an element can contain another element, which is necessary to build element hierarchies for output within a single template:
<!ELEMENT xsl:for-each ( #PCDATA | xsl:apply-templates | xsl:call-template | xsl:apply-imports | xsl:for-each | xsl:value-of | xsl:copy-of | xsl:number | xsl:choose | xsl:if | xsl:text | xsl:copy | xsl:variable | xsl:message | xsl:fallback | xsl:processing-instruction | xsl:comment | xsl:element | xsl:attribute | xsl:sort )* >
This model does not capture the precise requirement when the Sort element is used. If it occurs, it must precede all other elements and text.
The attributes are as follows:
<!ATTLIST xsl:for-each select %expr; #REQUIRED %space-att; >
With all entities replaced, the true model is as follows:
<!ATTLIST xsl:for-each select CDATA #REQUIRED xml:space (default|preserve) #IMPLIED >
For example:
<xsl:for-each select="item"> <xsl:comment>There was an item here.</xsl:comment> </xsl:for-each>
The Value Of instruction is defined as follows:
<!ELEMENT xsl:value-of EMPTY >
The attributes are as follows:
<!ATTLIST xsl:value-of select %expr; #REQUIRED disable-output-escaping (yes|no) "no">
With the entity replaced, the true model is as follows:
<!ATTLIST xsl:value-of select CDATA #REQUIRED disable-output-escaping (yes|no) "no">
For example:
<xsl:value-of select="@price" />
A Copy Of instruction is defined as follows:
<!ELEMENT xsl:copy-of EMPTY >
The attributes are as follows:
<!ATTLIST xsl:copy-of select %expr; #REQUIRED >
With the entity replaced, the true model is as follows:
<!ATTLIST xsl:copy-of select CDATA #REQUIRED >
For example:
<xsl:copy-of select="table" />
The Number instruction is defined as follows:
<!ELEMENT xsl:number EMPTY >
The attributes are as follows:
<!ATTLIST xsl:number level (single|miltiple|any) "single" count %pattern; #IMPLIED from %pattern; #IMPLIED value %expr; #IMPLIED format %avt; "1" lang %avt; #IMPLIED letter-value %avt; #IMPLIED grouping-separator %avt; #IMPLIED grouping-size %avt; #IMPLIED >
With the entities replaced, the true model is as follows:
<!ATTLIST xsl:number level (single|multiple|any) "single" count CDATA #IMPLIED from CDATA #IMPLIED value CDATA #IMPLIED format CDATA "1" lang CDATA #IMPLIED letter-value CDATA #IMPLIED grouping-separator CDATA #IMPLIED grouping-size CDATA #IMPLIED >
For example:
<xsl:number level="multiple" count="chapter|section" from="part" format="1.a.i" />
The Choose instruction is defined as follows:
<!ELEMENT xsl:choose (xsl:when+, xsl:otherwise?) >
The attributes are as follows:
<!ATTLIST xsl:choose %space-att; >
With all entities replaced, the true model is as follows:
<!ATTLIST xsl:choose xml:space (default|preserve) #IMPLIED >
See below for a description of the content of this element.
The If instruction is defined as follows:
<!ELEMENT xsl:if %template; >
With the entity replaced, the true model is as follows:
<!ELEMENT xsl:if ( #PCDATA | xsl:apply-templates | xsl:call-template | xsl:apply-imports | xsl:for-each | xsl:value-of | xsl:copy-of | xsl:number | xsl:choose | xsl:if | xsl:text | xsl:copy | xsl:variable | xsl:message | xsl:fallback | xsl:processing-instruction | xsl:comment | xsl:element | xsl:attribute )* >
The attributes are as follows:
<!ATTLIST xsl:if test %expr; #REQUIRED %space-att; >
With all entities replaced, the true model is as follows:
<!ATTLIST xsl:if test CDATA #REQUIRED xml:space (default|preserve) #IMPLIED >
For example:
<xsl:if test="@type='secret'"> <xsl:message>Found secret paragraph</xsl:message> </xsl:if>
The Text template instruction is defined as follows:
<!ELEMENT xsl:text (#PCDATA) >
The attributes are as follows:
<!ATTLIST xsl:text disable-output-escaping (yes|no) "no">
For example:
<xsl:text disable-output-escaping="yes"> create HTML <P> (paragraph) </P> </xsl:text>
The Copy instruction is defined as follows:
<!ELEMENT xsl:copy %template; >
With the entity replaced, the true model is as follows:
<!ELEMENT xsl:copy ( #PCDATA | xsl:apply-templates | xsl:call-template | xsl:apply-imports | xsl:for-each | xsl:value-of | xsl:copy-of | xsl:number | xsl:choose | xsl:if | xsl:text | xsl:copy | xsl:variable | xsl:message | xsl:fallback | xsl:processing-instruction | xsl:comment | xsl:element | xsl:attribute )* >
The attributes are as follows:
<!ATTLIST xsl:copy use-attribute-sets %qnames; #REQUIRED %space-att; >
With all entities replaced, the true model is as follows:
<!ATTLIST xsl:copy use-attribute-sets NMTOKENS #REQUIRED xml:space (default|preserve) #IMPLIED >
For example:
<xsl:copy> <xsl:message>Copied source element - but no attributes</xsl:message> </xsl:copy>
The Variable instruction is defined as follows:
<!ELEMENT xsl:variable %template; >
With the entity replaced, the true model is as follows:
<!ELEMENT xsl:variable ( #PCDATA | xsl:apply-templates | xsl:call-template | xsl:apply-imports | xsl:for-each | xsl:value-of | xsl:copy-of | xsl:number | xsl:choose | xsl:if | xsl:text | xsl:copy | xsl:variable | xsl:message | xsl:fallback | xsl:processing-instruction | xsl:comment | xsl:element | xsl:attribute )* >
The attributes are as follows:
<!ATTLIST xsl:variable name %qname; #REQUIRED select %expr; #IMPLIED >
With all entities replaced, the true model is as follows:
<!ATTLIST xsl:variable name NMTOKEN #REQUIRED select CDATA #IMPLIED >
For example:
<xsl:variable name="Copyright"> <xsl:text>(c) ACME Productions</xsl:text> </xsl:variable> <xsl:variable name="BookTitle" select="/book/title" />
The Message instruction is defined as follows:
<!ELEMENT xsl:message %template; >
With the entity replaced, the true model is as follows:
<!ELEMENT xsl:message ( #PCDATA | xsl:apply-templates | xsl:call-template | xsl:apply-imports | xsl:for-each | xsl:value-of | xsl:copy-of | xsl:number | xsl:choose | xsl:if | xsl:text | xsl:copy | xsl:variable | xsl:message | xsl:fallback | xsl:processing-instruction | xsl:comment | xsl:element | xsl:attribute )* >
The attributes are as follows:
<!ATTLIST xsl:message terminate (yes|no) "no" %space-att; >
With the entity replaced, the true model is as follows:
<!ATTLIST xsl:message terminate (yes|no) "no" xml:space (default|preserve) #IMPLIED >
For example:
<xsl:message>Error in processing</xsl:message>
The Fallback instruction is defined as follows:
<!ELEMENT xsl:fallback %template; >
With the entity replaced, the true model is as follows:
<!ELEMENT xsl:fallback ( #PCDATA | xsl:apply-templates | xsl:call-template | xsl:apply-imports | xsl:for-each | xsl:value-of | xsl:copy-of | xsl:number | xsl:choose | xsl:if | xsl:text | xsl:copy | xsl:variable | xsl:message | xsl:fallback | xsl:processing-instruction | xsl:comment | xsl:element | xsl:attribute )* >
The attributes are as follows:
<!ATTLIST xsl:fallback %space-att; >
With the entity replaced, the true model is as follows:
<!ATTLIST xsl:fallback xml:space (default|preserve) #IMPLIED >