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. Advertisements

  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. Advertisements

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:
    30,424
    Mike Schilling
    Mar 29, 2006
  2. Simon Brooke
    Replies:
    0
    Views:
    551
    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:
    437
    Hans Oesterholt-Dijkema
    Apr 13, 2005
  4. Venky
    Replies:
    0
    Views:
    646
    Venky
    Jun 27, 2005
  5. James Owens
    Replies:
    8
    Views:
    5,705
    Tjerk Wolterink
    Nov 24, 2005
  6. Alona
    Replies:
    1
    Views:
    533
    Joe Kesselman
    Apr 5, 2007
  7. Charles Packer

    Representing duplicated data in XML

    Charles Packer, Aug 28, 2008, in forum: XML
    Replies:
    5
    Views:
    559
    Peter Flynn
    Sep 6, 2008
  8. Erik Wasser
    Replies:
    5
    Views:
    864
    Peter J. Holzer
    Mar 5, 2006
Loading...