TCPDF未显示XSL元素值

The xsl:value-of select does not display the attributes in the pdf, however if you display the xsl as html, then it displays the data, which however is not displaying in the tcpdf PDF document. I am using DOM document and PHP, XSL and XML and TCPDF technologies.

The XML code is here:

<?xml version="1.0" encoding="UTF-8"?>
<catalogue>
    <category id="689" name="Cards" parentid="3"/>
    <category id="7" name="Toys" parentid="0"/>
    <category id="697" name="Boys Toys" parentid="7"/>
    <category id="698" name="Girls Toys" parentid="7"/>
    <category id="707" name="Play Toys" parentid="7"/>
    <category id="708" name="Rides" parentid="7"/>
    <category id="684" name="Swimming Accessories" parentid="7"/>
    <category id="719" name="" parentid="0"/>
    <category id="710" name="Cash" parentid="0"/>
    <category id="711" name="Airtime" parentid="0"/>
    <category id="716" name="Babies" parentid="0"/>
    <category id="701" name="Baby Shower" parentid="716"/>
    <category id="700" name="Infant" parentid="716"/>
    <category id="713" name="Kiddies Furniture" parentid="716"/>
    <category id="712" name="Protective Clothing (Baby Wear)" parentid="716"/>
    <category id="715" name="Educational" parentid="0"/>
    <category id="704" name="Educational Blocks" parentid="715"/>
    <category id="705" name="Educational Puzzles" parentid="715"/>
    <category id="695" name="Educational Toys" parentid="715"/>
    <category id="3" name="Gifts" parentid="0"/>
    <category id="693" name="Gift Bags" parentid="3"/>
    <category id="718" name="Party" parentid="0"/>
    <category id="696" name="Cake Decor" parentid="718"/>
    <category id="688" name="Craft Accessories" parentid="718"/>
    <category id="699" name="Decor" parentid="718"/>
    <category id="694" name="Flowers" parentid="718"/>
    <category id="686" name="Rentals" parentid="718"/>
    <category id="687" name="Party Accessories" parentid="718"/>
    <category id="687" name="Party Accessories" parentid="718"/>
    <category id="720" name="Services" parentid="718"/>
    <category id="686" name="Sweets" parentid="718"/>
    <category id="2" name="Wedding Accessories" parentid="718"/>
    <category id="717" name="Stationeries" parentid="0"/>
    <category id="720" name="Stationery Reading Blocks" parentid="714"/>
    <category id="4" name="Stationery" parentid="717"/>
    <category id="691" name="Stationery Papers" parentid="717"/>
</catalogue>

The XSL code is here

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="no" omit-xml-declaration="yes" doctype-public="-//W3C/DTD XHTML 1.0 Transitional//EN" doctype-system="
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" standalone="no" media-type="text/html" />

<xsl:template match="/">
<!--  <html>
  <body>-->
    <h2>Categories</h2>  
    <table border="1">
      <tr bgcolor="#9acd32">
    <th style="text-align:left; width: 210px">Category Name</th>
    <th style="text-align:left; width: 80px">ID</th>
    <th style="text-align:left; width: 80px">ParentID</th>   
      </tr>

      <xsl:for-each select="catalogue/category">
      <tr >
        <td><xsl:value-of select="@name"/></td>
        <td><xsl:value-of select="@id"/></td>
        <td><xsl:value-of select="@parentid"/></td>
      </tr>
    </xsl:for-each>

      </table>

  <!--</body>
  </html>-->
    </xsl:template> 
</xsl:stylesheet>

The PHP code is here:

<?php
    $xsl=0;
    $xmldata = new DOMDocument( "1.0", "UTF-8");
    $xml_file = "test005.xml";
    $xmldata->load($xml_file);

    $xslDoc = new DOMDocument("1.0", "UTF-8");
    $xslt_file = "catalogue2.xsl";
    $xslDoc->load($xslt_file);

    print_r(xml2html($xmldata, $xslDoc));
function xml2html($xmldata, $xsl)
{
    /* $xmldata -> your XML */
    /* $xsl -> XSLT file */

    $path = 'include';
    $arguments = array('/_xml' => $xmldata);

    $xsltproc = new XSLTProcessor();
    $xsltproc->importStyleSheet($xsl);
    $html = $xsltproc->transformToXML($xmldata);

    if (empty($html)) {
       die('XSLT processing error: ');//. XSLTxslt_error($xsltproc));
    }

    return $html;
}

?>

This sounds similar to a problem I've been having with TCPDF not fully displaying the XML that I've passed into it.

In my case, it seems that the XML that's been returned from transformToXML contains an empty cell in the form of a self-closing tag ie. <td /> rather than <td></td>. This renders fine when viewed as a web page through a browser, but TCPDF doesn't like it and the generated PDF is blank beyond that point.

If you're seeing the same problem, based on your XML and XSL, the blank 'name' attribute of category ID 719 would seem to be the most obvious culprit.

Try appending a blank space in the table cells in your <xsl:for-each> loop to see whether this results in the PDF being correctly generated; in my case, it does.