|
|
@@ -0,0 +1,72 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+Lib::loadClass('RouteBase');
|
|
|
+
|
|
|
+class Route_Test_XslRecurse extends RouteBase {
|
|
|
+
|
|
|
+ function defaultAction() {
|
|
|
+ UI::layout( [ $this, 'defaultView' ], [ 'showMenu' => false ] );
|
|
|
+ }
|
|
|
+ function defaultView() {
|
|
|
+ Lib::loadXslFunction('testFetchWfs');
|
|
|
+ Lib::loadXslFunction('testHtmlContent');
|
|
|
+ $xml = "
|
|
|
+ <root>
|
|
|
+ <item typeName=\"default_db:TEST_PERMS\">
|
|
|
+ <featureId>TEST_PERMS.1</featureId>
|
|
|
+ </item>
|
|
|
+ <item typeName=\"default_db__x3A__TEST_PERMS:TestPermAnt\">
|
|
|
+ <featureId>TestPermAnt.1</featureId>
|
|
|
+ </item>
|
|
|
+ </root>
|
|
|
+ ";
|
|
|
+ $xsl = '<?xml version="1.0" encoding="UTF-8"?>';
|
|
|
+ $xsl .= '
|
|
|
+ <xsl:stylesheet version="1.0"
|
|
|
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
|
+ xmlns:php="http://php.net/xsl">
|
|
|
+ <xsl:output method="html" encoding="utf-8" indent="yes"/>
|
|
|
+ <xsl:template match="root">
|
|
|
+ <html><body>
|
|
|
+ <h2>Items</h2>
|
|
|
+ <table class="table table-bordered">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>featureId</th>
|
|
|
+ <th>item</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <xsl:for-each select="item">
|
|
|
+ <tr>
|
|
|
+ <td><xsl:value-of select="featureId"/></td>
|
|
|
+ <td><pre>
|
|
|
+ <xsl:copy-of select="php:function(\'testFetchWfs\',@typeName, string(featureId))/node()"/>
|
|
|
+ </pre></td>
|
|
|
+ </tr>
|
|
|
+ </xsl:for-each>
|
|
|
+ </table>
|
|
|
+
|
|
|
+ <h3>Test function to get xml content from php function</h3>
|
|
|
+ <xsl:copy-of select="php:function(\'testHtmlContent\', \'test-arg-1-from-xsl\', \'test-arg-2-from-xsl\')/node()"/>
|
|
|
+
|
|
|
+ </body></html>
|
|
|
+ </xsl:template>
|
|
|
+ </xsl:stylesheet>
|
|
|
+ ';
|
|
|
+ $xmldoc = new DOMDocument;
|
|
|
+ $xmldoc->loadXML($xml);
|
|
|
+ $xsldoc = new DOMDocument;
|
|
|
+ $xsldoc->loadXML($xsl);
|
|
|
+
|
|
|
+ $proc = new XSLTProcessor();
|
|
|
+ $proc->registerPHPFunctions();
|
|
|
+ $proc->importStyleSheet($xsldoc);
|
|
|
+ $transformed = $proc->transformToXML($xmldoc);
|
|
|
+ DBG::nicePrint(htmlspecialchars($xml), 'xml');
|
|
|
+ DBG::nicePrint(htmlspecialchars($transformed), 'xml transformed');
|
|
|
+ echo "\n".'<hr>';
|
|
|
+ echo $transformed;
|
|
|
+ echo '<hr>'."\n";
|
|
|
+ }
|
|
|
+
|
|
|
+}
|