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

RE: Occurrence Question

  • To: "Tolkin, Steve" <Steve.Tolkin@F...>, xml-dev@l...
  • Subject: RE: Occurrence Question
  • From: Michele Vivoda <idmichele@y...>
  • Date: Tue, 28 Mar 2006 16:03:42 +0200 (CEST)
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.it; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=RjFjSv020EAj/MoFmnaxfOr3OOn1ob84+PZJFskm4pCSR1DP1lO36pvJ5NjE8b4HTqg8uEv0UYHM2akGC4DuljgTaHfdUtlTithHCkAx7e0n3Rc1TYOS2IY2NTzyhrFHJDcsW2jL8ifprda4n0P4mxMrhVz/BJVRnXpjh6tMSkg= ;
  • In-reply-to: <493A37523A8D17448240DA1DDDE924B40686D113@M...>

xsi nil 1

--- "Tolkin, Steve" <Steve.Tolkin@F...> ha scritto:


> Can you please clarify what you meant by "there is
> no difference between
> empty and absent in xml."

Yes sure, I can try, I have various thoughts 
on the argument, I put them out.

xml tree is made mainly of sequences of nodes, 
these sequences can be empty or filled but 
there is no third option (null or absent) 
in this construct.

In DOM child nodes are a Node*List* that 
is always present,by default empty.


The difference between null and empty is common
in programming languages and databases. 

An object and a record can be seen as a map,
an associative array, one gets the values 
from it by name.

The children of an xml element are a single 
sequence containing items with possibly 
different names, is very different from 
an object or a record.

A text field of a DB record can usually be 
null or an empty string, an object field 
value might be null if the language  uses 
strings as references, like in java. In
Basic there is no null string, some Basic 
use a placeholder for communicating 
with databases.


XML attributes are different because they 
are not a sequence but more like a map 
(in DOM a NamedNode*Map*) and one can 
distinguish between the three cases for 
attribute b:

<a>
<a b=''>
<a b='ccccc'>


An attribute can be used more easily to 
serialize the null value of a field, 
but there are some differences. 
In a map it might be possible to distinguish 
between an entry {key,value} with null value 
and an absent entry, this might be relevant 
when merging maps (as happens for DB
updates)

Something like this is (luckily?) not present in xml.

<a b='<null/>'/>


When there is this empty/null difference 
there _might_ be three states for a 'value': 

null/empty/present   

or even 4 considering [absent] and [present but null]
as different. This last possibility is only
in open maps, not in objects or records where the
keys are fixed. 

xml elements 'collections' and xml text content 
cannot be mapped to a null or an 'empty value'
consistently, you need to choose one of the two
possibly helping yourself with some other info. 

Text of an element does not really exists 
as property of an xml element, 
in DOM might be seen as the the sum of 
the node values of the child nodes of type text
if there are no child elements. 

Also 'collections' do not exist, 
there is only one sequence, 
the sequence of the child nodes, 
you need to interpret the sequence iterating 
it and selecting the right nodes to be put 
in a collection, you cannot just say 
"give me a certain collection" as with objects.


> I think there is a difference.  Suppose the empty
> element <Bonus> is
> used as a "marker", meaning: If and only if <Bonus/>
> occurs then the
> person is eligible to receive a bonus.  
> Clearly there is a difference between empty and
> absent.

Yes but there is no third option.

In your example the element is present:
is the content, the child nodes sequence,
to be empty. The other case is the absent element.

If the bonus is a boolean primitive (true/false)
then an element absent/present might be a good marker.
But a boolean could be also a java.lang.Boolean
allowing null value, or a boolean field of a DB
record, also allowing null value. 
The null value might mean that the 
bonus-situation has not been decided yet
or might be used to unset a true/false situation.


If one doesn't have nulls might use two values 
or create an enumeration, use xsi:nil [1] or other
trick.

In general one needs a convention so that is
pssible to interpret the xml data and 
reproduce this concept and 
you cannot just 'read it' from the data.


in my opinion the absence of a
difference between null an empty and also 
the absence of an explicitly serialized 
container for collections gives big advantages 
in compatibility between _serialized instances 
of objects_ since the same serialized form 
can be 'interpreted' as an instance of different 
structures. For example one single element 
can be a single occurrence field but also 
the first item of a future collection.

So for me using xml for object serialization
is better than binary for compatibility, 
what is not good instead is using xml or 
xml schema to describe objects, 
beacause some structures cannot be mapped.

Greetings
Michele

[1] http://www.w3.org/TR/xmlschema-1/#xsi_nil
http://xsd.stylusstudio.com/2001Nov/post02006.htm


		
___________________________________ 
Yahoo! Messenger with Voice: chiama da PC a telefono a tariffe esclusive 
http://it.messenger.yahoo.com

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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.