In my XSLT file. I use the document() function
<xsl:variable name="Publicity" select="document('./publicity.xml')" />
and that works but if I try to link a PHP script that generate the XML dynamically,
<xsl:variable name="Publicity" select="document('./publicity.php')" />
I get a
Warning: XSLTProcessor::transformToXml() [xsltprocessor.transformtoxml]: file:///C:/wamp/www/XSLT/test.php:3: parser error : Start tag expected, '<' not found in ... on line ...
Which consist of the < from <?php
It looks like the XSLTProcessor isn’t requesting the file like via a HTTP request so it’s not executed by Apache / PHP.
I know I could simply include that XML structure to my main XML but I’m trying to avoid this… until someone tell me there is no other way.
Thank you!
Right the document() function just reads a file off the disk, it does not make an HTTP request. So the PHP doesn’t execute.
You’ll have to use an URL instead of just the filename as the argument to your document() function.
I believe that using an URL in this way is a common feature in most XSLT processors, but I have not tested it with PHP, so your mileage may vary.