1

我有这个非常简单的代码,它应该生成我的 HTML,但我得到的只是白页。我几乎尝试了任何东西,它只是空白页。如果有人可以检查并告诉我我做错了什么,我会在天堂!

PHP代码:

        $xp = new XsltProcessor();
    // create a DOM document and load the XSL stylesheet
    $xsl = new DomDocument;
    $xsl->load('template-file.xls');
    // import the XSL styelsheet into the XSLT process
    $xp->importStylesheet($xsl);
    // create a DOM document and load the XML datat
    $xml_doc = new DomDocument;
    $xml_doc->load('temporary-file.xml');
    // transform the XML into HTML using the XSL file
    if ($html = $xp->transformToXML($xml_doc)) {
        return $html;
    } else {        
        return "<p>FAILED</p>";
    }

XML 文件:

    <?xml version="1.0"?>
<results>
    <xml_report>
    <subject>
         <efx_file_header>
              <efx_header>
                <bureau>EFX</bureau>
                <customer_number>682ZB08042</customer_number>
                <customer_reference_code>199</customer_reference_code>
                <ecoa>2</ecoa>
                <output_format>02</output_format>

                <multiple_files_indicator>1</multiple_files_indicator>
                <name>ZUVICH, TYLER J</name>
                <ssn>196722017</ssn>

              </efx_header>
         </efx_file_header>
   </subject>
    </xml_report>
</results>

这是 XLS 模板文件:

<?xml version="1.0" encoding="utf-8"?>  
<xsl:stylesheet version="1.0"
xmlns:php="http://php.net/xsl"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<!-- Edited by Adrian -->

<xsl:output method="html" encoding="UTF-8" indent="yes"/>  

<xsl:template match="results/xml_report">

<xsl:for-each select="subject">
    <table class="table-paddings" cellspacing="0" cellpadding="0">      
        <tbody>
        <tr>
            <td width="245px">Boreau</td>
            <td width="250px"><xsl:value-of select="efx_file_header/ext_header/bureau" /></td>
        </tr>

        <tr>
            <td>Customer Number</td>
            <td><xsl:value-of select="efx_file_header/ext_header/customer_number" /></td>
        </tr>

        <tr>
            <td>Customer Reference Code</td>
            <td><xsl:value-of select="efx_file_header/ext_header/customer_reference_code" /></td>
        </tr>                           

        </tbody>
    </table>
    <br />
</xsl:for-each>

</xsl:template>
</xsl:stylesheet>
4

1 回答 1

1

尝试echo $html代替return $html

于 2012-04-19T23:40:57.180 回答