1

I have this very simple CODE, which should generate me HTML, but all I get is white page. I tryed nearly anything, it just blank page. If anyone could check and tell me what im doing wrong I would be in heavens!

PHP CODE:

        $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 file:

    <?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>

And this is the XLS template file:

<?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>
7
  • display errors turned on? error reporting set to E_ALL? Commented Apr 19, 2012 at 23:01
  • @Hajo I done it, no errors :S Commented Apr 19, 2012 at 23:08
  • checked if all files are found / loaded in php and that they contain the data expected before processed by dom? Commented Apr 19, 2012 at 23:11
  • @Hajo Yes, ofc, atleast 10x :S Commented Apr 19, 2012 at 23:19
  • then i'm out of ideas for now, sorry :( Commented Apr 19, 2012 at 23:23

1 Answer 1

1

Try echo $html instead of return $html

Sign up to request clarification or add additional context in comments.

2 Comments

Yes but if he is not echoing the results anywhere he will get the exact behaviour he is experiencing.
WOW, simple as that? 150 hours lost on ECHO :S, how could I miss that::.... MANY MANY THANKS!!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.