At 18:21 -0500 12/2/03, Ben Trafford wrote:
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.
I issued these statements using mysql -X:
DROP TABLE IF EXISTS t;
CREATE TABLE t (tx TEXT);
INSERT INTO t (tx) VALUES(''),(NULL),('some text');
SELECT tx FROM t;
The result was:
<?xml version="1.0"?>
<resultset statement="SELECT tx FROM t">
<row>
<tx></tx>
</row>
<row>
<tx>NULL</tx>
</row>
<row>
<tx>some text</tx>
</row>
</resultset>
Dumping the table with mysqldump -X produces:
<?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
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list