Representing Null vs. EmptyString in XML

James (archive)

Usenet Archive
Joined
Jan 11, 2000
Messages
567
Reaction score
0
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.
 

Richard Tobin

Usenet Archive
Joined
Jan 6, 2000
Messages
4,251
Reaction score
0
James said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,798
Members
249,594
Latest member
henrywalsh

Latest Threads

Top