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
    type="text/xsl" href="inf-dev.xslt"?>

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

    ----- and so on.

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

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

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

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





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

  2. Davide Benini

    Nick Kew Guest

    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, May 30, 2005
    1. Advertisements

  3. Sorry; it's a mac with OS X, so it is apache indeed.
    How do I perform the operation you suggested in detail?
    Davide Benini, May 30, 2005
  4. Davide Benini

    Peter Flynn Guest

    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 Flynn, Jun 27, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.