• [^] # Ma reponse à ma question

    Posté par . En réponse au journal Site multi-lingue. Évalué à 1.

    http://www.onlamp.com/pub/a/onlamp/2001/03/16/sablotron.html?page=3(...)

    On pourrait regretter l ouverture en fichier texte et non xml qui serait pratique pour faire des ajout à l xml avant de l envoyer au passeur xslt

    Noter que l on pourrait gérer un cache pour éviter de faire la transformation xslt a chaque appel de page.

    <?php

    // Include the DeviceType() function.
    INCLUDE("xmllib.inc");


    // What are the XML and XSL files?
    $xmlFile = "news.xml";
    $xslFile = DeviceType();

    // Create a new processor handle
    $th = @xslt_create() or die("Can't create XSLT handle!");

    // Open the XML and XSL files
    $xh = fopen($xmlFile, "r") or die("Can't open XML file");
    $sh = fopen($xslFile, "r") or die("Can't open XSL file");

    // Read in the XML and XSL contents
    $xmlContent = fread($xh, filesize($xmlFile));
    $xslContent = fread($sh, filesize($xslFile));

    // Perform the XSL transformation
    @xslt_process($xslContent, $xmlContent, $XSLtransformation);

    // send the correct WAP header if necessary
    if ($xslFile == "wapnews") :

    header("content-type: text/vnd.wap.wml");

    endif;

    // Output the transformed XML file
    echo $XSLtransformation;

    // Free up the resources
    @xslt_free($th);

    ?>
    d autre avis ?