I'm creating for school a multiple choice program. For this I have to write an xslt stylesheet to show the right answer.
My XML has the following strucure
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QUIZ SYSTEM "quiz.dtd">
<?xml-stylesheet type="text/xsl" href="quizanswers.xsl"?>
<quiz>
<multipleChoice solution="3">
<question>Question 1</question>
<answer>answer 1</answer>
<answer>answer 2</answer>
<answer>answer 3</answer>
<answer>answer 4</answer>
</multipleChoice>
<multipleChoice solution="4">
<question>Question 1</question>
<answer>answer 1</answer>
<answer>answer 2</answer>
<answer>answer 3</answer>
<answer>answer 4</answer>
</multipleChoice>
</quiz>
With the following xslt file
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h1>Answers</h1>
<xsl:for-each select="quiz/multipleChoice">
<u><br></br><xsl:value-of select="question"/></u><br></br>
- <xsl:value-of select="question[../multipleChoice/@solution]"/> <br />
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
What i want is to set the number from attribute solution in the question[attribute of solution]. Which I achieved but doesn't work. Has anyone a solution/suggestion for thi problem?
I also want to have this xml file to have multiple stylesheets... Is that possible?
Thanks in advance...
<quiz>is lowercase, but your doctype declaration is uppercase (QUIZ). You should change your doctype to match the case of your root element. - Daniel Haley