I am using saxon 8 and <xsl:stylesheet version="2.0"
I haven't been using xslt 2.0 features very much and am thinking this is
where some would come in handy.
My exact desired result follows - basically I want to add the letter a,
b, or c to the Question # depending on if the problem is the 1st, 2nd or
3rd.
Currently in my xsl I have a generic copy template which takes care of
just copying all the nodes I care about.
Now I want to modify the text in the <span class="questionHeader"> based
on its parent <question>'s position.
I can imagine a slightly cumbersome strategy using xslt 1.0 that
involves parameters and writing several more templates to match the
various nodes so the param can be passed through correctly. Then using
substring functions.
In xslt 2.0 I see regular expressions to change the text, but can't find
a faster way to determine the position of the parent node. Pointers
anyone? Thanks
<!-- my generic copy template -->
<xsl:template match="*" mode="qcaudio">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="qcaudio"/>
</xsl:copy>
</xsl:template>
### sample xml:
<base>
<group>
<problem ...> ... many nodes ...
<question ...> ... many nodes...
<span class="questionHeader">Question 1: </span> ... many
nodes...
</question>
</problem>
<problem ...> ... many nodes ...
<question ...> ... many nodes...
<span class="questionHeader">Question 1: </span> ... many
nodes...
</question>
</problem>
<problem ...> ... many nodes ...
<question ...> ... many nodes...
<span class="questionHeader">Question 1: </span> ... many
nodes...
</question>
</problem>
</group>
<group>
<problem ...> ... many nodes ...
<question ...> ... many nodes...
<span class="questionHeader">Question 2: </span> ... many
nodes...
</question>
</problem>
<problem ...> ... many nodes ...
<question ...> ... many nodes...
<span class="questionHeader">Question 2: </span> ... many
nodes...
</question>
</problem>
<problem ...> ... many nodes ...
<question ...> ... many nodes...
<span class="questionHeader">Question 2: </span> ... many
nodes...
</question>
</problem>
</group>
### desired result xml:
<group>
<problem ...> ... many nodes ...
<question ...> ... many nodes...
<span class="questionHeader">Question 1a: </span> ... many
nodes...
</question>
</problem>
<problem ...> ... many nodes ...
<question ...> ... many nodes...
<span class="questionHeader">Question 1b: </span> ... many
nodes...
</question>
</problem>
<problem ...> ... many nodes ...
<question ...> ... many nodes...
<span class="questionHeader">Question 1c: </span> ... many
nodes...
</question>
</problem>
</group>
<group>
... etc....