F
FLEB
Okay, so I've got this XML:
<qa>
<questionset>
<question name="yourname">What is your name?</question>
<question name="yourquest">What is your quest?</question>
<question name="favcolor"> What is your favorite color?</question>
</questionset>
<answerset time="some_unique_time">
<answer question="yourname">FLEB the Amazing</answer>
<answer question="yourquest">To get some decent XHTML</answer>
<answer question="favcolor">Dark white</answer>
</answerset>
<!-- more answersets... -->
</qa>
In use, <questionset> is unique to its <qa> container (there may be other
<qa>s, but any given <qa> will have only one <questionset>). There will,
however, be a lot of different <answerset>s. I want to transform this so I
get the full question with each answer. I just can't think of a way to say
"The question element with the attribute "name", matching THE CURRENT
ELEMENT's "question" value."
I've tried, for instance, looping through the <answer> elements, and using
something like:
<xsl:value-of select="../../questionset/question[@name=@answer]">
but this (as it naturally should) tries to compare the question's @name to
its own @answer. I'm stuck. I also don't want to use IDs in a DTD, because
I might have multiple <questions> with the same id, but under a different
pile of heirarchy. Is there any way to "reset" back to the start of the
path in order to retrieve the current element's @question value? Or (more
likely) am I thinking about this all wrong?
Thanks for any help!
<qa>
<questionset>
<question name="yourname">What is your name?</question>
<question name="yourquest">What is your quest?</question>
<question name="favcolor"> What is your favorite color?</question>
</questionset>
<answerset time="some_unique_time">
<answer question="yourname">FLEB the Amazing</answer>
<answer question="yourquest">To get some decent XHTML</answer>
<answer question="favcolor">Dark white</answer>
</answerset>
<!-- more answersets... -->
</qa>
In use, <questionset> is unique to its <qa> container (there may be other
<qa>s, but any given <qa> will have only one <questionset>). There will,
however, be a lot of different <answerset>s. I want to transform this so I
get the full question with each answer. I just can't think of a way to say
"The question element with the attribute "name", matching THE CURRENT
ELEMENT's "question" value."
I've tried, for instance, looping through the <answer> elements, and using
something like:
<xsl:value-of select="../../questionset/question[@name=@answer]">
but this (as it naturally should) tries to compare the question's @name to
its own @answer. I'm stuck. I also don't want to use IDs in a DTD, because
I might have multiple <questions> with the same id, but under a different
pile of heirarchy. Is there any way to "reset" back to the start of the
path in order to retrieve the current element's @question value? Or (more
likely) am I thinking about this all wrong?
Thanks for any help!