* Chuck P wrote in microsoft.public.dotnet.xml:
Quote:
>I am trying to retrieve the @AnswerCount Attribute
for the @QuestionID=1 AND the Answer element text =3
>
>I successfully can pass the variables QuestionID and Answer but can't pull
>out the
>@AnswerCount
>
<QuestionResults>
<Question QuestionID="1">
<Answer AnswerCount="1">1</Answer>
<Answer AnswerCount="5">3</Answer>
<Answer AnswerCount="1">4</Answer>
<Answer AnswerCount="1">N/A</Answer>
</Question>
<Question QuestionID="2">
......
>
>I was unsucessfully trying:
<xsl:variable name="choiceCount"
>select="//QuestionResults/Question[@QuestionID=$qid][Answer=$matchText]/Answer/@AnswerCount"/>
>
<xsl:choose>
<xsl:when test="$choiceCount 0">
<xsl:value-of select="$choiceCount" />
</xsl:when>
<xsl:otherwise>-</xsl:otherwise>
</xsl:choose>
>
>I always get 1 for the $choiceCount when the @QuestionID is found.
|
That's because the right Answer is not in your path, you just check
whether there is a right Answer. Put the predicate after the Answer,
..../Answer[ . = $matchText ]/@AnswerCount.
--
Björn Höhrmann · mailto:bjoern@hoehrmann.de ·
http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·
http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·
http://www.websitedev.de/