Php into XML

D

Davide Benini

Heelo everybody.
I am using XML and XSL to analyse a text.
Now, I am trying to integrate php into the XML code, in order to make
the XML page dynamic.
Yet the parser doesn't even read the php code embedded in the xml page.
Here is the beginning of my XML page, inf-dev.xml
-----
?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE inferno SYSTEM
"file:/Users/davidebenini/Documents/Universita%CC%80/Dottorato/inferno/inferno.dtd">
<?xml-stylesheet
type="text/xsl" href="inf-dev.xslt"?>

<inferno>
<filtro>FILTRO: <?php
echo "Filtro passsato in php";
?>-</filtro>
<canto>
<n>1</n>
<passo>
<vv>1</vv>
<dante>
<v>Nel mezzo del cammin di nostra vita</v>
</dante>
<carson>
<v>Halfway through the story of my life</v>
</carson>
<nota>
<n>Carson introduce story</n>
</nota>
</passo>
<passo>
<vv>14</vv>
<dante>
<v>là dove terminava quella valle</v>
</dante>
<carson>
<v>hill; here, thre valley formed a cul-de-sac</v>
</carson>
<nota>Carson introduce cul-de-sac, uno dei termini che
spesso associa ai vicoli di
Belfast; prima nota di colore locale</nota>
</passo>

----- and so on.

Then, this is the XSLT, inf-dev.xslt
----
?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:eek:utput method="html"/>
<xsl:template match="/">

<html>
<head>
<title>Inferno: comparazione</title>
<link rel="stylesheet" title="main" href="stile-inf.css"
type="text/css" />
</head>
<body>
<div id="container">
<?php
echo"Php funziona<br>";
$risultato=$_POST[keyword];
echo "Hai inviato $risultato";
?>
<h1>Inferno</h1>
<xsl:value-of select="inferno/filtro"/>
<xsl:for-each select="inferno/canto">
<div class="cant">
<h2>
Canto <xsl:value-of select="n"/>
</h2>
<xsl:for-each select="passo">




<div class="pass">
<xsl:value-of select="../n"/>, <xsl:value-of
select="vv"/>
<table border="0" width="100%">
<tr>
<td width = "50%">
<xsl:for-each select="dante/v">
<xsl:value-of select="."/>
<br/>
</xsl:for-each>
</td>

<td>
<xsl:for-each select="carson/v">
<xsl:value-of select="."/>
<br/>
</xsl:for-each>
</td>
</tr>
</table>
<div class="note">
<xsl:for-each select="nota">
- <xsl:value-of select="."/>
<br/>
</xsl:for-each>
</div>

</div>

<br/>


</xsl:for-each>

</div>
</xsl:for-each>

</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
---
As you've probably noticed, the php code is only for testing purpouses...
Yet the output doesn't show the value of <filtro>, only the string; the
php code is ignored.
Any suggestion?
Cheers,
Davide
 
N

Nick Kew

Davide said:
Heelo everybody.
I am using XML and XSL to analyse a text.
Now, I am trying to integrate php into the XML code, in order to make
the XML page dynamic.
Yet the parser doesn't even read the php code embedded in the xml page.

You need to configure your system to run PHP then XSLT. For example,
if you were using Apache you could make PHP the handler and then add
mod_transform as output filter. But since you didn't say what the
system is, I can only suggest you read its manual.
 
D

Davide Benini

Nick said:
You need to configure your system to run PHP then XSLT. For example,
if you were using Apache you could make PHP the handler and then add
mod_transform as output filter. But since you didn't say what the
system is, I can only suggest you read its manual.
Sorry; it's a mac with OS X, so it is apache indeed.
How do I perform the operation you suggested in detail?
Cheers,
Davide
 
P

Peter Flynn

Davide said:
Heelo everybody.
I am using XML and XSL to analyse a text.
Now, I am trying to integrate php into the XML code, in order to make
the XML page dynamic.
Yet the parser doesn't even read the php code embedded in the xml page.

That is correct. It's not supposed to -- PHP statements use Processing
Instructions which XML software is required to ignore and pass through
for later action (in this case by PHP). PHP is not an XML technology,
so an XML parser cannot do anything with it. To make XML handle it, you
have to pass it through a PHP processor first, so that the PHP material
becomes XML.

///Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top