| Subject: Re: [xsl] A MySQL heads-up. From: Paul DuBois <paul@xxxxxxxxxxxx> Date: Tue, 2 Dec 2003 18:26:20 -0600 | 
Just a wee heads-up for anybody using MySQL's XML output function...it seems to export any empty field with a datatype of "text" as an empty element, rather than an element containing the NULL one might expect.
Why do you expect this? An empty field is not the same as a field that contains NULL.
DROP TABLE IF EXISTS t;
CREATE TABLE t (tx TEXT);
INSERT INTO t (tx) VALUES(''),(NULL),('some text');
SELECT tx FROM t;<resultset statement="SELECT tx FROM t">
  <row>
        <tx></tx>
  </row>  <row>
        <tx>NULL</tx>
  </row>  <row>
        <tx>some text</tx>
  </row>
</resultset><?xml version="1.0"?>
<mysqldump>
<database name="test">
        <table name="t">
        <row>
                <field name="tx"></field>
        </row>
        <row>
                <field name="tx">NULL</field>
        </row>
        <row>
                <field name="tx">some text</field>
        </row>
        </table>
</database>
</mysqldump>
In both cases, the output for the empty value and the NULL value are different. If they were not, you'd be hard-pressed to distinguish the two in your stylesheets. (Of course, as it is, you can't really distinguish NULL from a column containing the string "NULL", hm....)
I found this out a few minutes ago, after a very frustrating search. If you've encountered this, you might think your XSLT was broken, as I did. Never fear! It's the product!
;^)
--->Ben
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| [xsl] A MySQL heads-up., Ben Trafford | Thread | Re: [xsl] A MySQL heads-up., Ben Trafford | 
| [xsl] A MySQL heads-up., Ben Trafford | Date | Re: [xsl] A MySQL heads-up., Ben Trafford | 
| Month |