PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 13th, 2004, 04:55 AM
jocuddy10 jocuddy10 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 3 jocuddy10 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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">
<xslutput 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>

Reply With Quote
  #2  
Old August 16th, 2004, 06:51 AM
jocuddy10 jocuddy10 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 3 jocuddy10 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 <xslrocessing-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);
<xslutput 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>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Xml transformation to HTML with PHP and XSL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT