I have the following XML:
<jobDetails> <Question> <QuestionNumber>1</QuestionNumber> <QuestionResponse> <Response>ResponseOne</Response> </QuestionResponse> </Question> <Question> <QuestionNumber>2</QuestionNumber> <QuestionResponse> <Response>ResponseTwo</Response> </QuestionResponse> </Question> </jobDetails> I am using XSLT 1.0 to get the value of the Response if the question number is 2.
I can output the value of the response by doing this:
<xsl:for-each select="jobDetails/Question"> <xsl:variable name="theSet" select="QuestionNumber[string(.)='2']" /> <xsl:if test="$theSet"> <response> <xsl:value-of select="QuestionResponse/Response" /> </response> </xsl:if> </xsl:for-each> ... but I need to further query the response and output a value depending upon what the response is.
I have tried this:
<xsl:for-each select="jobDetails/Question"> <xsl:variable name="theSet" select="QuestionNumber[string(.)='2']" /> <xsl:if test="$theSet"> <xsl:when test="QuestionResponse/Response = 'ResponseOne'"><Response>SomeValue</Response></xsl:when> <xsl:when test="QuestionResponse/Response = 'ResponseTwo'"><Response>SomeOtherValue</Response></xsl:when> </xsl:if> </xsl:for-each> ... but the XSLT does not validate.
Thanks in advance for any assistance.
No comments:
Post a Comment