How do I define attributes in an HTML tag in XSL using the value of XSL??
[XML]
<?XML version= "1.0"?><?xml-stylesheet type= "text/xsl" href= "exam.xsl "?><Test> <Test_type>Exam</Test_type> <TestIDID= "1"> <say>What's the matter?</say> <Answers> <AnswerID= "00001">I know</Answer> <AnswerID= "00002">I understand</Answer> <AnswerID= "00003">Yes</Answer> <AnswerID= "00004">Good</Answer> </Answers> </TestID> <TestIDID= "2"> <say>What's the matter? 2</say> <Answers> <AnswerID= "00001">I know, 2.</Answer> <AnswerID= "00002">I get it. 2</Answer> <AnswerID= "00003">Yes, 2.</Answer> <AnswerID= "00004">Good 2</Answer> </Answers> </TestID> <TestIDID= "3"> <say>What's the matter? 3</say> <Answers> <AnswerID= "00001">I know, 3.</Answer> <AnswerID= "00002">I get it. 3</Answer> <AnswerID= "00003">Yes, 3.</Answer> <AnswerID= "00004">Good 3</Answer> </Answers> </TestID> </Test>
[Exam.xsl]
<?XML version= ' 1.0 ' encoding= ' utf-8 '?><Xsl:stylesheetversion= "1.0"xmlns:xsl= "Http://www.w3.org/1999/XSL/Transform" > <Xsl:outputMethod= "html"/>
<xsl:templateMatch="/"><formAction= "Test.aspx"Method= "POST"> <P><xsl:apply-templatesSelect= "Test"/></P> <P> <inputtype= "Submit"value= "Submit"/> <inputtype= "Reset"value= "Reset"/> </P> </form> </xsl:template>
<xsl:templateMatch= "Test"> <Xsl:for-eachSelect= "TestID"> <P>Topic:</P> <xsl:value-ofSelect= "Say"/> <Xsl:for-eachSelect= "Answers"> <Xsl:for-eachSelect= "Answer"> <P> <inputtype= "Radio"CHECKED= "0"value= "text ()"name= "Ancestor::testid/@id" > <xsl:value-ofSelect= "text ()"/> </input> </P> </Xsl:for-each>
</Xsl:for-each> </Xsl:for-each> </xsl:template></Xsl:stylesheet>
Grammar:
Name= "{Ancestor::testid/@id}"
Defining attributes in the HTML tag in XSL uses the values of the XSL