469,332 Members | 6,649 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

xpath match text question

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.

Feb 19 '07 #1
2 3456
* Chuck P wrote in microsoft.public.dotnet.xml:
>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:bj****@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/
Feb 19 '07 #2
Hi Chuck,

Just want to check if the issue has been resolved.
Please feel free to let me know if there is anything we can help with.

Have a great day.
Sincerely,
Wen Yuan

Feb 22 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by 0wl | last post: by
reply views Thread by Michael Fork | last post: by
2 posts views Thread by ahogue at theory dot lcs dot mit dot edu | last post: by
7 posts views Thread by Sebastian Petzelberger | last post: by
5 posts views Thread by Tom Alsberg | last post: by
1 post views Thread by bjam | last post: by
1 post views Thread by Kathy Burke | last post: by
5 posts views Thread by Patrick.O.Ige | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.