Ashley Sheridan wrote:
> I still disagree, as using XSL is essentially converting the XML to
> another format,
Which is all you're doing when you're extracting parts of an XML
document.
> which is then being used by PHP. XSL is great for some tasks, but for
> this, I think having a good PHP XMLDoc (or similar type of) class is
> better.
Ash, I'd really like to hear you argue why you think so.
I can't help thinking it's a bit like saying "I know there is a compiler
for C-code, but I prefer to convert to assembler by using PHP". I know
it's not quite that bad, but I hope you get my point.
> On a slightly aside note though, how would you apply the XSL to the
> XML using PHP?
Roughly like this: (this is from a project I'm currently working on).
--------------
// create the xslt processor object
if ( FALSE===($xp=new XSLTProcessor()) ) { print "unable to create xslt
engine"; return FALSE; }
// Load the XML source
$xml=new DOMDocument;
$xml->loadXML($list);
// then load the XSL stylesheet
$xsl=new DOMDocument;
$xsl->load('getfilebypos.xsl');
// attach the stylesheet
$xp->importStyleSheet($xsl);
$pos=$_GET['pos'];
$xp->setParameter('', array('pos' => $_GET['pos']) );
$file=$xp->transformToXML($xml);
------------
$file in this case is just a single filename, no XML. My input data has
a list of filenames, the 'pos' argument from the URI identifies one I
need to process.
/Per Jessen, Zürich
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php