Jump to content

theredking

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by theredking

  1. theredking

    XML to JSP

    I am trying to get questions for a multiple choice quiz stored in an xml file displayed on a JSP. I'm new to XML and am stuck as how to get the questions onto the JSP. I know that JDOM and mapping to a database are options but i am not finding examples on the web very helpful. Can anybody suggesat the easiest way to do this. Thank You. I have attached the xml for clarity. <?xml version="1.0" ?><?xml-stylesheet type="text/xsl" href="quizdisplaypd.xsl"?><!-- <!DOCTYPE XMultipleChoice SYSTEM "quizpd.dtd"> --> <XMultipleChoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="quizschemapd.xsd"> <QuizName>Parmjeet Dayal Great XML Assignment Quiz</QuizName> <Units> <Unit> <QuestionNo>1</QuestionNo> <Subject>Dave Chappelle Show</Subject> <Question>Who is Rick James?</Question> <Answer Corr="Y">Rick James</Answer> <Answer>Charlie Murphy</Answer> <Answer>Dave Chappelle</Answer> <Answer>Eddie Murphy</Answer> </Unit> <Unit> <QuestionNo>2</QuestionNo> <Subject>Dave Chappelle Show</Subject> <Question>Should you put feet on other peoples couches?</Question> <Answer>Yes</Answer> <Answer>No</Answer> <Answer>In someone else's house</Answer> <Answer Corr="Y">In Eddie Murphy's house, he can afford it</Answer> </Unit> <Unit> <QuestionNo>3</QuestionNo> <Subject>Wrestling</Subject> <Question>Who is the greatest wrestler of all time?</Question> <Answer>Hulk Hogan</Answer> <Answer>The Rock</Answer> <Answer Corr="Y">Goldberg</Answer> <Answer>Stone Cold Steve Austin</Answer> </Unit> <Unit> <QuestionNo>4</QuestionNo> <Subject>Music</Subject> <Question>Who is the lead singer of The Stone Roses?</Question> <Answer>Noel Gallagher</Answer> <Answer Corr="Y">Ian Brown</Answer> <Answer>Chris Martin</Answer> <Answer>Snoop Dog</Answer> </Unit> <Unit> <QuestionNo>5</QuestionNo> <Subject>The A Team</Subject> <Question>Which of these men takes pity on fools?</Question> <Answer>Murdock</Answer> <Answer>Face</Answer> <Answer Corr="Y">Mr T</Answer> <Answer>Hannibal</Answer> </Unit> <Unit> <QuestionNo>6</QuestionNo> <Subject>Star Wars</Subject> <Question>Master Yoda is the last great practitioner of Ataru. Who is the greatest Soresu practitioner?</Question> <Answer Corr="Y">Mace Windu</Answer> <Answer>Darth Vader</Answer> <Answer>Chewwy</Answer> <Answer>Hans Solo</Answer> </Unit> <Unit> <QuestionNo>7</QuestionNo> <Subject>Seseame Steet</Subject> <Question>Which of these growchy individuals lives in a trash can?</Question> <Answer>Big Bird</Answer> <Answer Corr="Y">Oscar</Answer> <Answer>The Count</Answer> <Answer>Elmo</Answer> </Unit> <Unit> <QuestionNo>8</QuestionNo> <Subject>Lord of the Rings</Subject> <Question>Mithrandir is Sindarin name of which powerful character?</Question> <Answer>Saruman</Answer> <Answer>Pippin</Answer> <Answer>Balrog</Answer> <Answer Corr="Y">Gandalf</Answer> </Unit> <Unit> <QuestionNo>9</QuestionNo> <Subject>Cricket</Subject> <Question>How is the most dangerous man in world cricket today?</Question> <Answer>Matthew Hoggard</Answer> <Answer Corr="Y">Mahendra Singh Dhoni</Answer> <Answer>Ricky Ponting</Answer> <Answer>Shaun Bond</Answer> </Unit> <Unit> <QuestionNo>10</QuestionNo> <Subject>Animal Fights</Subject> <Question>In a fight who would win, a Lion or a Grizzly Bear?</Question> <Answer>Lion</Answer> <Answer>Bear</Answer> <Answer>Draw</Answer> <Answer Corr="Y">They'd discuss their issues and end it in a civilised manner</Answer> </Unit> </Units></XMultipleChoice>
  2. Thanks a lot man! I didn't even know how to use some of that stuff! Much apprechiated
  3. Here is the XML file. Thanks for this!<?xml version="1.0" ?><?xml-stylesheet type="text/xsl" href="quizdisplaypd.xsl"?><!-- <!DOCTYPE XMultipleChoice SYSTEM "quizpd.dtd"> --> <XMultipleChoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="quizschemapd.xsd"> <QuizName>Parmjeet Dayal Great XML Assignment Quiz</QuizName> <Units> <Unit> <QuestionNo>1</QuestionNo> <Subject>Dave Chappelle Show</Subject> <Question>Who is Rick James?</Question> <Answer Corr="Y">Rick James</Answer> <Answer>Charlie Murphy</Answer> <Answer>Dave Chappelle</Answer> <Answer>Eddie Murphy</Answer> </Unit> <Unit> <QuestionNo>2</QuestionNo> <Subject>Dave Chappelle Show</Subject> <Question>Should you put feet on other peoples couches?</Question> <Answer>Yes</Answer> <Answer>No</Answer> <Answer>In someone else's house</Answer> <Answer Corr="Y">In Eddie Murphy's house, he can afford it</Answer> </Unit> <Unit> <QuestionNo>3</QuestionNo> <Subject>Wrestling</Subject> <Question>Who is the greatest wrestler of all time?</Question> <Answer>Hulk Hogan</Answer> <Answer>The Rock</Answer> <Answer Corr="Y">Goldberg</Answer> <Answer>Stone Cold Steve Austin</Answer> </Unit> <Unit> <QuestionNo>4</QuestionNo> <Subject>Music</Subject> <Question>Who is the lead singer of The Stone Roses is?</Question> <Answer>Noel Gallagher</Answer> <Answer Corr="Y">Ian Brown</Answer> <Answer>Chris Martin</Answer> <Answer>Snoop Dog</Answer> </Unit> </Units></XMultipleChoice>
  4. Hello, i am writing an xslt to transform and display my quiz xml document. The questions are displayed and answers are displayed with radio buttons next to them. But i don't know to to provide them values or group them question by questions as all the radio buttons seem to be linked becasue when one is clicked it turns off another one from another question. I have tried amending this problem but with little success, any help would be much apprechiated. Thank you. my code is below. <?xml version="1.0"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > <xsl:template match ="/"> <html> <body> <form name="myform" action="http://www.manut.com" method="POST"> <center> <h2> <xsl:value-of select="XMultipleChoice/QuizName" /> </h2> </center> <hr> </hr> <!-- create the links --> <ul> <xsl:for-each select="XMultipleChoice/Units/Unit"> <li> <a> <xsl:attribute name="href"> <xsl:text>#Unit-</xsl:text> <xsl:value-of select="Question" /> </xsl:attribute> <xsl:value-of select="Question" /> </a> </li> </xsl:for-each> </ul> <!-- now the actual slides --> <xsl:for-each select="XMultipleChoice/Units/Unit"> <hr> </hr> <h3> <a> <xsl:attribute name="name"> <xsl:text>#Unit-</xsl:text> <xsl:value-of select="QuestionNo" /> </xsl:attribute> <xsl:value-of select="QuestionNo" /> - <xsl:attribute name="name"> <xsl:text>#Unit-</xsl:text> <xsl:value-of select="Subject" /> </xsl:attribute> <xsl:value-of select="Subject" /> </a> </h3> <li> <h3> <a> <xsl:attribute name="name"> <xsl:text>#Unit-</xsl:text> <xsl:value-of select="Question" /> </xsl:attribute> <xsl:value-of select="Question" /> </a> </h3> </li> <ul> [B] <xsl:for-each select="Answer" > <p align = "left"><input type = "radio" name = "name1" value = ""/><xsl:value-of select="." /></p> </xsl:for-each>[/B] </ul> </xsl:for-each> </form> </body> </html> </xsl:template> </xsl:stylesheet>
×
×
  • Create New...