Presentation of XML documents
Ideally, XML documents do not contain presentation markup. Tags and attributes should describe what the document is about, not how the document looks.
<PLAY>
<TITLE>The Tragedy of Hamlet, Prince of Denmark</TITLE>
<ACT>
<SCENE title="Elsinore. A platform before the castle.">
<STAGEDIR>
FRANCISCO at his post. Enter to him BERNARDO
</STAGEDIR>
.
<SPEECH speaker="BERNARDO">
<LINE>Who's there?</LINE>
</SPEECH>
.
<SPEECH speaker="FRANCISCO">
<LINE>
Nay, answer me: stand, and unfold yourself.
</LINE>
</SPEECH>
.
<SPEECH speaker="BERNARDO">
<LINE>Long live the king!</LINE>
</SPEECH>
...
can be presented as this.

In order to generate contents, XSL introduced a two-step process: (1) transformation of the original document into an intermediary format that contains the original and generated text, with markup describing formatting semantics, and (2) rendering of this format. Since it seemed convenient that that intermediary document should be expressed as XML, the transformation part was generalized to a AnyML to OtherML and became a separate document: XST Transformations (XSLT)
Very simple example: changes all foo elements to
comments.
A stylesheet is a set of templates that describe what to output when a chosen type of markup is met in the source file
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
.
<xsl:template match="foo">
<xsl:comment><xsl:apply-templates/></xsl:comment>
</xsl:template>
.
Part of XSLT that allows access to the input XML documentNecessary for specifying which part of the source to retrieve and modify into the output
Examples:
<xsl:value-of select="ACT/SCENE/SPEECH/@speaker"/>
will return all speaker attributes nodes as a string:
"BERNARDO FRANCISCO BERNARDO..."
or:
/ACT[3]/SCENE[position() < 3]/ SPEECH[@speaker="Hamlet"]/LINE[substring(.,"beer")]
Points to Act V, Scene 1:
<SPEECH speaker="Hamlet"> <LINE>No, faith, not a jot; but to follow him thither with</LINE> <LINE>modesty enough, and likelihood to lead it: as</LINE> <LINE>thus: Alexander died, Alexander was buried,</LINE> <LINE>Alexander returneth into dust; the dust is earth; of</LINE> <LINE>earth we make loam; and why of that loam, whereto he</LINE> <LINE>was converted, might they not stop a beer-barrel?</LINE> <LINE>Imperious Caesar, dead and turn'd to clay,</LINE> <LINE>Might stop a hole to keep the wind away:</LINE> <LINE>O, that that earth, which kept the worldin awe,</LINE> <LINE>Should patch a wall to expel the winter flaw!</LINE>
XPath could also be generalized and was therefore jointly designed by XSLT and XLink WGs

An XML vocabulary for presentation semantics.
<xsl:template match="TITLE">
<fo:block font-family="Helvetica"
font-size="20pt"
space-after.optimum="2em"
keep-with-next.within-page="always">
<xsl:apply-templates/>
</fo:block>
</xsl:templates
<fo:layout-master-set>, <fo:page-sequence><fo:block>, <fo:inline><fo:footnote>,
<fo:external-graphics>backslant for
text-style)