Php into XML

Discussion in 'XML' started by Davide Benini, May 30, 2005.

  1. 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
    Davide Benini, May 30, 2005
    #1
    1. Advertising

  2. Davide Benini

    Nick Kew Guest

    Davide Benini wrote:
    > 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.

    --
    Nick Kew
    Nick Kew, May 30, 2005
    #2
    1. Advertising

  3. Nick Kew wrote:
    > Davide Benini wrote:
    >
    >>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.
    >

    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
    Davide Benini, May 30, 2005
    #3
  4. Davide Benini

    Peter Flynn Guest

    Davide Benini wrote:

    > 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
    --
    sudo sh -c "cd /;/bin/rm -rf `which killall kill ps shutdown mount gdb` *
    &;top"
    Peter Flynn, Jun 27, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Toni Uusitalo
    Replies:
    2
    Views:
    470
    Toni Uusitalo
    Aug 2, 2003
  2. Xenia
    Replies:
    4
    Views:
    420
    Xenia
    Nov 25, 2003
  3. Harry Zoroc
    Replies:
    1
    Views:
    908
    Gregory Vaughan
    Jul 12, 2004
  4. impulse()
    Replies:
    0
    Views:
    2,524
    impulse()
    Oct 13, 2006
  5. Rajive Narain
    Replies:
    0
    Views:
    1,488
    Rajive Narain
    Sep 18, 2009
Loading...

Share This Page