Browse Source

Format XSLT and pass parameters.

pull/126/head
Adam Vessey 13 years ago committed by Adam Vessey
parent
commit
d44aca62d1
  1. 10
      ObjectHelper.inc
  2. 62
      xsl/convertQDC.xsl

10
ObjectHelper.inc

@ -410,9 +410,17 @@ class ObjectHelper {
if (($xsl_path = "$path/xsl/convertQDC.xsl") && if (($xsl_path = "$path/xsl/convertQDC.xsl") &&
($xsl = DOMDocument::load($xsl_path)) && ($xsl = DOMDocument::load($xsl_path)) &&
($ds = DOMDocument::loadXML($xmlstr))) { ($ds = DOMDocument::loadXML($xmlstr))) {
$xslt_opts = array(
'BASEURL' => $base_url,
'PATH' => url($path, array('absolute' => TRUE)),
'baseUrl' => $base_url, //XXX: Deprecated; just here for legacy cases.
'path' => url($path, array('absolute' => TRUE)), //XXX: Deprecated; just here for legacy cases.
);
$transform = new XSLTProcessor(); $transform = new XSLTProcessor();
$transform->importStylesheet($xsl); $transform->importStylesheet($xsl);
return $transform->transformToXML($ds); $transform->setParameter('', $xslt_opts);
$transformed = $transform->transformToDoc($ds);
return $transformed->saveHTML();
} }
else { else {
$simplexml = new SimpleXMLElement($xmlstr); $simplexml = new SimpleXMLElement($xmlstr);

62
xsl/convertQDC.xsl

@ -1,33 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:variable name="BASEURL"> <!-- Old parameter names "$baseUrl" and "$path" are deprecated. Currently just used as defaults. -->
<xsl:value-of select="$baseUrl"/> <xsl:param name="BASEURL" select="$baseUrl"/>
</xsl:variable> <xsl:param name="PATH" select="$path"/>
<xsl:variable name="PATH">
<xsl:value-of select="$path"/> <xsl:template match="/">
</xsl:variable> <div>
<xsl:template match="/"> <table cellspacing="3" cellpadding="3">
<tbody>
<div><table cellspacing="3" cellpadding="3"><tbody> <tr>
<tr><th colspan="3"><h3>MetaData</h3></th></tr> <th colspan="3"><h3>MetaData</h3></th>
<xsl:for-each select="/*/*"> </tr>
<xsl:variable name="FULLFIELD" select="name()"/> <xsl:for-each select="/*/*">
<xsl:variable name="FIELD" select="local-name()"/> <xsl:variable name="FULLFIELD" select="name()"/>
<xsl:variable name="DATA" select="text()"/> <xsl:variable name="FIELD" select="local-name()"/>
<xsl:if test="$DATA != ' '"> <xsl:variable name="DATA" select="normalize-space(text())"/>
<tr><td><strong><xsl:value-of select="local-name()"/></strong></td><td><xsl:value-of select="text()"/> <xsl:if test="$DATA">
<xsl:for-each select="*"> <tr>
<div> <td><strong><xsl:value-of select="local-name()"/></strong></td>
<xsl:value-of select="local-name()"/> = <xsl:value-of select="text()"/> <td><xsl:value-of select="$DATA"/>
</div> <xsl:for-each select="*">
</xsl:for-each> <div><xsl:value-of select="concat(local-name(), ' = ', text())"/></div>
</td></tr> </xsl:for-each>
</xsl:if> </td>
</xsl:for-each> </tr>
</xsl:if>
</tbody></table></div> </xsl:for-each>
</tbody>
</xsl:template> </table>
</div>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

Loading…
Cancel
Save