Representing Null vs. EmptyString in XML

Discussion in 'XML' started by James, Apr 25, 2004.

  1. James

    James Guest

    In certain applications, it is necessary to distinguish between an
    emptyString vs. a null value. What is the appropriate way to make
    this distinction in XML?

    <elementName></elementName>
    looks like a zero-length string (emptyString) but will evaluate to
    null.

    The data element in question may have its own datatype (string, title,
    name, etc.) but also need to hold an emptyString value.
     
    James, Apr 25, 2004
    #1
    1. Advertising

  2. In article <>,
    James <> wrote:

    >In certain applications, it is necessary to distinguish between an
    >emptyString vs. a null value. What is the appropriate way to make
    >this distinction in XML?


    There isn't a way to do this defined in plain XML, but you can make up
    your own way of doing it. A natural way is to use an attribute, and
    if you're using XML Schema then it provides one: xsi:nil="true" (where
    xsi is bound to the schema instance namespace). Nothing stops you
    from using this even when you're not using XML Schema, though you will
    have to interpret it yourself in the application.

    -- Richard
     
    Richard Tobin, Apr 25, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    26,738
    Mike Schilling
    Mar 29, 2006
  2. Simon Brooke
    Replies:
    0
    Views:
    442
    Simon Brooke
    Oct 12, 2003
  3. Hans Oesterholt-Dijkema

    Representing Meta Data using an XML Schema

    Hans Oesterholt-Dijkema, Apr 13, 2005, in forum: XML
    Replies:
    0
    Views:
    353
    Hans Oesterholt-Dijkema
    Apr 13, 2005
  4. Venky
    Replies:
    0
    Views:
    541
    Venky
    Jun 27, 2005
  5. James Owens
    Replies:
    8
    Views:
    5,506
    Tjerk Wolterink
    Nov 24, 2005
Loading...

Share This Page