Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Join Date
    May 2002
    Hayward, CA
    Thanked 23 Times in 21 Posts

    mod_perl: Running XML through PHP preprocessor

    Lately I've been revisiting an old thorn in my side for HTTP usage. Namely, how can I pass to PHP, SSI, Perl, or Python (or any other language as needed) an XML document for processing via XML processing instructions?

    At first, I tinkered with the idea of creating custom Apache filename extensions (.pxml, for instance, for PHP-processed XML). A little work with .htaccess showed that wouldn't necessarily fit the bill.

    So I'm exploring another idea, based on something I remember Firepages telling me.

    Suppose I have a URI:


    Where the actual file resides at

    The "php" directory could be an alias for indicating I should send the document through the PHP interpreter. After it goes through the interpreter, the server would then return the correct mime-type.

    Is this doable, perhaps with a couple sub-requests, perhaps an HTTP HEAD request involved?

    UPDATE: Figured out how to do the PHP thing, at least for phpdev4.2.3. In httpd.conf, add the following:

    # run PHP interpreter through a directory request
    Alias /processPHP/ "C:/phpdev/contentTypes/process.php/"
    <Directory "C:/phpdev/contentTypes/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from localhost
    php.ini gets its "short_open_tags" value set to "Off", so I don't have to worry about <?xml version="1.0" ?> triggering PHP...

    Then I create a new directory, C:/phpdev/contentTypes/, and I add the following files:

    AddType application/xhtml+xml .xhtml
    AddType image/svg+xml .svg
    $fileInfo = apache_lookup_uri($_SERVER["PATH_INFO"]);
    header("Content-type: ".$fileInfo["content_type"]);
    Now I need to figure out equivalents for Perl and Python...
    Last edited by Alex Vincent; 07-14-2003 at 12:46 AM.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts