[xsl] Stumped on XPath

Subject: [xsl] Stumped on XPath
From: Spencer Tickner <spencertickner@xxxxxxxxx>
Date: Tue, 7 Feb 2006 13:31:31 -0800
Hi everyone,

Thanks in advance for the help. I've got an interesting match pattern
(I think) I can't seem to get my mind around.

XML
<doc>
 <manual>
  <sentence>This is a sentence with a reference<id ref="1"/> as an
inline element</sentence>
     <clause>This is a clause with inline elements <strong>
and</strong> a reference <id ref="3"/></clause>
</manual>
<appendix>
 <refnote id="1">This is the first reference</refnote>
 </appendix>
 <appendix>
 <refnote id="2">This is the second reference</refnote>
 <refnote id="3">This is the third reference</refnote>
</appendix>
</doc>

Ok, I can't quite figure out the best method for comming up with the
following output

<html>
<body>
<p>This is a sentence with a reference (see Appendix A) as an inline
element</p>
<p class="clause">This is a clause with inline elements <strong>
and</strong> a reference (see Appendix B)</p>
</body>
</html>

So far what I have is:

XSL
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="manual">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="sentence">
  <p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="clause">
 <p class="clause"><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="strong">
<strong><xsl:apply-templates/></strong>
</xsl:template>
<xsl:template match="appendix"/>
<xsl:template match="id">
<!-- This is what I'm having a hard time with -->
<!-- I imagine I have to match the id on the name and then count the
following siblings of appendix and use a translate to get the alpha
value,, but I can't seem to get the syntax down for this -->
</xsl:template>

Well there you go. It's a scaled down version, any thoughts would be
appreciated. Thanks.

Current Thread