Inserting a heading only in only the first element
I would like to insert a heading for the first child element in another element, and not for any others that may follow. For example, if I have XML like this:
--------------------------------------
<article>
<section>
<information>
some stuff
</information>
<question>
one
</question>
<question>
two
</question>
</section>
<section>
<information>
some stuff
</information>
<question>
three
</question>
<question>
four
</question>
</section>
</article>
-----------------------------------
And my XSLT looks something like this:
------------------------------------
<xsl:template match="/">
<html>
<head>
<title></title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="information">
<b><xsl:apply-templates/></b>
</xsl:template>
<xsl:template match="question">
<h3>Test My Knowledge</h3>
<h4>Question <xsl:number level="any"/></h4>
</xsl:template>
</xsl:stylesheet>
------------------------------------
Then I get the following result:
------------------------------------
some stuff
Test My Knowledge
Question 1
Test My Knowledge
Question 2
some stuff
Test My Knowledge
Question 3
Test My Knowledge
Question 4
--------------------------------------
But I would like the "Test my Knowledge" to apeear only in front of the first "question" element in every "section" element, something like this:
----------------------------------------
some stuff
Test My Knowledge
Question 1
Question 2
some stuff
Test My Knowledge
Question 3
Question 4
---------------------------------------
Is it possible to do this without changing the structure of the XML?
|