|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Xml transformation to HTML with PHP and XSL
Hi, I'm having trouble transforming my XML file into HTML with XSL and PHP. The XML and XSL file work fine together without PHP but when i use PHP i get nothing returned to the screen. I have just had PHP reconfigured with sablotron and xslt support and have been told I need to run PHP through the cgi server. It is PHP version 4.2.2. Below are my XML and XSL files. Has anyone got any PHP code that would use the files together to produce HTML. Please please Jo XML file (chapter.xml) <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="chapter.xsl"?> <chapter xmlns:chapter="http://slashdot.org/backslash.dtd"> <question> <text> 1. What is the best agent architecture? </text> <possible-answer> <label>A</label> <text>TouringMachines</text> </possible-answer> <possible-answer> <label>B</label> <text>InterRap</text> </possible-answer> <possible-answer> <label>C</label> <text>The Procedural Reasoning System</text> </possible-answer> <correct-answer>A</correct-answer> </question> <question> <text> 2. What is the best agent architecture? </text> <possible-answer> <label>A</label> <text>TouringMachines</text> </possible-answer> <possible-answer> <label>B</label> <text>InterRap</text> </possible-answer> <possible-answer> <label>C</label> <text>The Procedural Reasoning System</text> </possible-answer> <correct-answer>B</correct-answer> </question> </chapter> XSL file (chapter.xsl) <?xml version="1.0" encoding="utf-8" ?> - <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl utput method="html" indent="yes" encoding="utf-8" /> - <xsl:template match="/chapter1"> - <HTML> - <BODY> <xsl:call-template name="question" /> </BODY> </HTML> </xsl:template> - <xsl:template name="question"> - <xsl:for-each select="question"> <xsl:value-of select="text" /> - <xsl:for-each select="possible-answer"> <xsl:value-of select="label" /> <xsl:text /> <xsl:value-of select="text" /> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet> |
|
#2
|
|||
|
|||
|
XSL radiobuttons
hi,
I sorted my last problem. But now i have a new one! The XSL script below prints out a set of multiple choice questions with radiobuttons. The problem is that I need a separate radio button for each single value of the questions, for when i come to handle the data with PHP, but i don't know how to do this. I have tried using <xsl rocessing-instructions="php"> but it did not work.Please help Jo <?xml version="1.0" encoding="utf-8" ?> - <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - <!-- this statement says that the output generated will be in HTML -->f(clean); <xsl utput method="html" indent="yes" encoding="utf-8" /> - <!-- define root of document with template 1 -->f(clean); - <xsl:template match="/chapter"> - <HTML> - <BODY> <xsl:call-template name="question" /> </BODY> </HTML> - <!-- close template 1 -->f(clean); </xsl:template> - <!-- open template 2 -->f(clean); - <xsl:template name="question"> - <!-- create form for radio button questions. They will be sent by'POST' method and handled by the PHP program 'results1.php' -->f(clean); - <form action="results1.php" method="POST"> - <xsl:for-each select="question"> - <b> <xsl:value-of select="text" /> </b> <br /> <br /> - <xsl:for-each select="possible-answer"> - <xsl:choose> - <xsl:when test="label"> - <!-- radiobuttons for questions --> <input type="radio" name="radio" value="A" /> <xsl:value-of select="label" /> </xsl:when> </xsl:choose> <xsl:text /> <xsl:value-of select="text" /> <br /> <br /> - <!-- close the 'for' loops --> </xsl:for-each> </xsl:for-each> - - <!-- code for the interaction elements of the webpage --> <input type="HIDDEN" value="HIDDEN" /> <input type="SUBMIT" name="SUBMIT" value="Submit" /> <input type="RESET" name="RESET" value="Reset" /> </form> <br /> <br /> <br /> - <!-- close template 2 -->f(clean); </xsl:template> - <!-- close the stylesheet -->f(clean); </xsl:stylesheet> |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Xml transformation to HTML with PHP and XSL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|