cancel
Showing results for 
Search instead for 
Did you mean: 

empty and null elements

Former Member
0 Kudos

Hello.

I couldn't find an exhaustive explanation about this subject.

When we have an xml elemnt - when is it defined as an empty element, and when is it defined as a null element?

Is there a standard?

I have found the following options:

1. <element/>

2. <element></element>

3. the element is absent (when we have minOccurs=0 this is possible)

4. <element xsi:nil="true" />

Is there a difference at how different programming languages "understand" the different options?

Can SAP PI message mapping generate each of them with basic graphic java functions? or are XSLT and user defined functions necessary?

Thanks for any one who will help at this matter.

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

1. <element/>

2. <element></element>

1&2 are semantically equal, both are considered empty because the element is existing but does not contain any value e.g blank. Older xml parsers will read number 2 but not number one.

3. the element is absent (when we have minOccurs=0 this is possible)

This is considered a null. In PI it will appear as SUPPRESS

4. <element xsi:nil="true" />

When the occurrence of a field is 1..1 but when nil is set to true, not having that element in an xml will still pass an xml validation check.

Is there a difference at how different programming languages "understand" the different options?

You have to research about the programming language handling of xml.

Can SAP PI message mapping generate each of them with basic graphic java functions? or are XSLT and user defined functions necessary?

Yes, but for xsd:nil, I think this is present from Pi 7.0 onwards. (please correct)

Hope this helps,

Mark

Former Member
0 Kudos

Hi.

Thanks for the quick answer.

I tested a little bit with message mappins, and found that when I have an empty element passed in message mapping - the element that will be created in the output is: <element/>

however for some reason - in c# xmlReader class there is a difference between <element></element> and </element>

see: [XmlReader.IsEmptyElement|http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.isemptyelement.aspx]

I can't see a way of generating <element></element> with the basic java function of the message mapping. can you please be more specific about this section?

also - as you said that "1&2 are semantically equal" - however this class for instance doesn't implement this.

can you please provide a link to the standard definitions on this matter?

Thank you,

Imanuel Rahamim.

Edited by: Imanuel Rahamim on Sep 22, 2011 8:04 AM

stefan_grube
Active Contributor
0 Kudos

> also - as you said that "1&2 are semantically equal" - however this class for instance doesn't implement this.

> can you please provide a link to the standard definitions on this matter?

Here you are:

http://www.w3.org/TR/2006/REC-xml11-20060816/#sec-starttags

Former Member
0 Kudos

thanks.

Answers (0)