[xsl] Making an FAQ page from XML

Subject: [xsl] Making an FAQ page from XML
From: John Steel <john.steel@xxxxxxxxxxxxxxx>
Date: Sun, 11 Feb 2007 21:39:42 +0000

(Borderline newbie alert!)
Given this XML:

<faqlist xmlns:OTAMate="urn:schemas.otamate.com">
 <q>Question One?</q>
 <a>Answer One</a>
 <q>Question Two?</q>
 <a>Answer Two.</a>
 <q>Question Three?</q>
 <a>Answer Three.</a>

I'm trying to make a page with all the questions on the top half which have links to the bottom half, like this:
1 Question 1
2 Question 2

1 Answer 1
2 Answer 2

I can do either the questions alone or the answers alone but can't figure how to split them this way. Heres as far as I got which just does the questions:

<xsl:template match='*|@*'>
  <xsl:apply-templates select='node()|@*'/>

<xsl:template match='faq'>
  <td valign='top' width='24' class="mText" style="font-size: 11px">
   <xsl:value-of select="count(preceding-sibling::*) + 1"/>
  <td class="mText" style="font-size: 11px">
   <a href="#1">
    <xsl:value-of select='q'/>

How can I set up some kind of "toggle" to say parse again but just for the 'a' nodes please? Thanks very much in advance.


Current Thread