|
Posted by Jochem Maas on 07/31/05 18:04
Allan Jardine wrote:
> Hello all,
>
> I'm having a real problem with applying an xslt transform to a selected
> part of an xml document. I load the xml document using
> simplexml_load_file, and the same with the xsl file. Using the xpath
> function for simplexml I select a part of the xml document and store it
> in a different variable. I then apply the xml transform to that
> variable, however the transform actually applies to the whole xml
> document, rather than just the selected part in the new variable. I
> can't figure out why it does this. Does anyone know? The code I'm used
> is below.
>
> $xml = simplexml_load_file ( 'simple_test.xml' );
>
> if ( isset ( $_GET['s'] ) && isset ( $_GET['ss'] ) )
> foreach ( $xml->xpath( "//section[@id='".$_GET['s']."']/
> subsection[@id='".$_GET['ss']."']" ) as $subsection)
> $content = $subsection;
>
> $xsl = simplexml_load_file( 'simple_test.xsl' );
> $proc = new XsltProcessor();
> $proc->importStylesheet($xsl);
> echo $proc->transformToXML($content);
you might start by using some braces to explicitly delineate the
if and foreach block? ...personally I'm not sure exactly what your code
should be doing.
>
> Thanks for any help
> Allan
>
Navigation:
[Reply to this message]
|