Hi,
Tempore 20:36:25, die 06/30/2005 AD, hinc in
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit <04083259(_at_)brookes(_dot_)ac(_dot_)uk>:
i have a set of questions and for each question a set of answers (4
answers )stored in xml file as each each answer has an attribute as a
reference to the question that it belogs to as following :
You're probably stuck with an xpath because you're missing the 'current()'
function.
But this situation (nodes connected with references) it is common to use
keys.
here's a stylesheet demonstrating two methods:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:key name="answer" match="answer" use="@question"/>
<xsl:template match="*[ques]">
<h1>My questions</h1>
<xsl:apply-templates select="ques"/>
</xsl:template>
<xsl:template match="question">
<h2><xsl:apply-templates/></h2>
key method:
<ol>
<xsl:for-each select="key('answer',@id)">
<li><xsl:apply-templates/></li>
</xsl:for-each>
</ol>
xpath method:
<ol>
<xsl:for-each select="//answer[(_at_)question=current()/@id]">
<li><xsl:apply-templates/></li>
</xsl:for-each>
</ol>
</xsl:template>
</xsl:stylesheet>
regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Ceterum censeo XML omnibus esse utendum
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--