Can PHP communicate with XSLT?

后端 未结 3 1624
耶瑟儿~
耶瑟儿~ 2021-01-07 13:15

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

3条回答
  •  抹茶落季
    2021-01-07 13:34

    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:

    registerPHPFunctions();
    $proc->setParameter('', 'p', '123');
    $proc->importStylesheet(DOMDocument::load("script.xsl"));
    echo $proc->transformToXML(DOMDocument::load("data.xml"));
    ?>
    

    second XSLT file:

    
    
      
      
         
        
      
    
    

    The output should be 123456
    EDITED: select="''" instead select=""

提交回复
热议问题