I want to use a combination of xml & xslt as a templating system. The question that I want answered is: can xslt and PHP communicate with each other (i.e share variables)?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- Illegal to have multiple roots (start tag in epilo
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
XSLT is a language, not a piece of software. It entirely depends what software you are using to process your XSLT: if it is a PHP extension, running as part of your existing PHP app, then yes. Otherwise, no.
The basic task you can do with PHP is to define which XML file to transform with which XSLT script. Using this you can
a) pass parameters from PHP to XSLT and
b) use PHP functions in the XSLT script.
This example shows how - first PHP file:
second XSLT file:
The output should be 123456
EDITED: select="''" instead select=""
What exactly do you mean by "share variables"? Do you want a PHP script to generate XSLT first and use that output in another PHP script to render your XML data? If so, then yes, that's possible. It doesn't matter where the XSLT comes from.