note 28444 deleted from function.xslt-process by sobak
| From: | sobak@php.net | Date: | Tue, 22 Nov 2016 03:33:07 +0000 |
| Subject: | note 28444 deleted from function.xslt-process by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207353@lists.php.net to get a copy of this message | ||
Note Submitter: twa at carlbro dot dk
----
It seems to be undocumented how to get the XSL parser to use two XML files at the same time to
produce the output. It is possible though. Here is how it's done with the XML data in a
variable:
First you need to change the 5th argument.
$xh = xslt_create();
$args = array('/_xml'=>$xml1, '/_xsl'=>$xsl, 'xml2'=>$xml2);
$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $args);
Inside the XSLT document you then need to do this:
<xsl:template match="/">
<root>
<foo>
<xsl:value-of select="/foo" />
</foo>
<bar>
<xsl:value-of select="document('xml2')/bar" />
</bar>
</root>
</xsl:template>
This creates a XML result containing a root node called "root" containing two nodes. One
called "foo" with the content of the root node in $xml1 and one called "bar"
with the content of the root node in $xml2.
In the $args array I don't know if it is best to write "'xml2'=>$xml2"
or "'/xml2'=>$xml2". Both work. I think it has something to do with the level
of the argument (/level1/level2/level3). Maybe this site reveals the true syntax:
http://www.gingerall.com/charlie/ga/act/gadoc.act?pg=sablot#i__1029
I don't know if there is another - more elegant way - to do this. But I can't find any
documentation on it.
For the moment I can't get this to work in PHP 4.3.0/Windows because there seems to be a
problem with the Sablotron that is shipped with this version (I have not tried the UNIX version
though). I think a new version of the sablot.dll will fix this problem. But for the moment I
can't seem to get PHP to work with this new version. If anyone knows how to do this then please
send me a mail. I'll post anything that I find out.
/watson