Re: Fun with XSLT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matthew Croud wrote:
> Hi Guys,
> 
> Well i;ve been slaving on with my PHP XML endeavors and i'm loving it,
> just finishing the meaty parts of my XSLT for dummies book too.
> 
> I have a question which asks "is it possible?".
> 
> Using XSLT I can collect specific parts of my XML using something sexy
> like <xsl:template match="umbungo">.  Lets say however, that I need to
> use XSLT, but I would want the user to select which element they
> request. In other words, they are given a form with options and that
> form can manipulate the .XSL file.
> 
> Now I know it could be done in a lengthly manner by just opening the XSL
> file and manipulating it like fopen or something like that, but is there
> a way to somehow embed the contents of the xml into the php code (like
> using <<< EOF for html), and being able to substitute the template match
> string for a variable ?
> 
> Any ideas ?
> 
> Thanks Gamesmaster,
> Matt
> 

Despite my other post, of course you can generate the XSL on the fly:

<?php
$choice='umbongo';

$xslScript <<<EoXSL
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:output method="xml" encoding="UTF-8" />

    <xsl:template match='/'>
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match='{$choice}'><xsl:apply-templates/></xsl:template>
</xsl:stylesheet>
EoXSL

$xslt = new DOMDocument();
$xslt->loadXML($xslScript);

// ... etc...
?>




-- 
Peter Ford                              phone: 01580 893333
Developer                               fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux