Understanding an XSLT Stylesheet
On the left, you can see a complete stylesheet. Read the stylesheet and answer the questions.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xpath-default-namespace="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
version="2.0">
<xsl:output method="xhtml" encoding="utf-8" />
<xsl:template match="node()|@*" priority="-1">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="span[@class='editorialNote']"/>
<xsl:template match="h3">
<xsl:copy>
<xsl:attribute name="class" select="'topicHeading'"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
What kind of input document is this stylesheet expecting?
- TEI XML
- XHTML
- plain text
What kind of output document is this stylesheet designed to create?
- TEI XML
- XHTML
- plain text
Look at the first template in the stylesheet. What kind of stylesheet do you think this is?
- An XSL:FO document
- An identity transform
- A transformation to generate a web page from a TEI document
If this transformation encounters an XHTML <div>
element in the input, what will it do with it?
- It will ignore it, and write nothing to the output.
- It will copy it to the output.
- It will transform it into a
<p>
element.
If this transformation encounters an XHTML <h3>
element in the input, what will it do with it?
- It will ignore it, and write nothing to the output.
- It will copy it to the output.
- It will transform it into a
<span>
element. - It will copy it to the output, adding a
class=
attribute in the process.
If this transformation encounters an XHTML <span>
element in the input, what will it do with it?
- It will ignore it, and write nothing to the output.
- It will copy it to the output.
- Sometimes it will ignore it, and sometimes it will copy it to the output.
- It will copy it to the output, adding a
class=
attribute in the process.
If this transformation encounters an XHTML <span>
with a class="editorialNote"
attribute in the input, what will it do with it?
- It will ignore it, and write nothing to the output.
- It will copy it to the output.
- Sometimes it will ignore it, and sometimes it will copy it to the output.
- It will copy it to the output, but it will remove the
class=
attribute.
Now you have examined the stylesheet in detail, which description gives the best account of the purpose of this stylesheet?
- This stylesheet is designed to take an XHTML document and turn it into a TEI XML document.
- This stylesheet is designed to make minor changes to a web page, by removing some editorial notes and adding a class attribute to some headings.
- This stylesheet is designed to take an XHTML document and simplify it to the point where it contains only
<span>
and <h3>
elements.