[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Making an FAQ page from XML

Subject: Re: Making an FAQ page from XML
From: Kamal Bhatt <kbhatt@xxxxxxxxx>
Date: Mon, 12 Feb 2007 08:47:55 +1100
Re:  Making an FAQ page from XML
John Steel wrote:
Hi,

(Borderline newbie alert!)
Given this XML:

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

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:copy>
  <xsl:apply-templates select='node()|@*'/>
 </xsl:copy>
</xsl:template>

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

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.
You want to use modes.

You can have multiple matches if you use a mode. Eg:

<xsl:apply-templates select="faq" mode="question"/>
<xsl:apply-templates select="faq" mode="answer"/>

...

<xsl:template match="faq" mode="question">
...Question processing...
</xsl:template>

<xsl:template match="faq" mode="answer">
...Answer processing...
</xsl:template

--
Kamal Bhatt

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.