[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: A MySQL heads-up.

Subject: Re: A MySQL heads-up.
From: Paul DuBois <paul@xxxxxxxxxxxx>
Date: Tue, 2 Dec 2003 18:26:20 -0600
mysql empty
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.