Empty type property example
Consider an XML element called Comment
.
Presuming that this element has a simple content of an arbitrary length, it
can be represented in a type tree as a text item, with the initiator value <Comment>
and
the terminator value </Comment>
.
This item can then be used to validate the following data:
<Comment>Some comment...</Comment>
The resulting value for the item will be:
Some comment...
As another example, the following data is also successfully validated:
<Comment></Comment>
The resulting value for the item will be a zero-length string.
The problem occurs with the following data: <Comment/>
From the XML perspective, this data is equivalent to the <Comment></Comment>
data
shown above, as it represents the Empty element Comment
.
However, from the type tree perspective, this data is invalid because it does
not start with <Comment>
and does not end with </Comment>
as
required by the initiator and terminator item property values.
This
is where the Empty property is useful. By defining the Empty property
for the item to have a value of <Comment/>
, it will
be possible to validate the data <Comment/>
.
Even if the data does not match the syntax described by the initiator and terminator properties, it will be validated because it will match the Empty property value. It will be treated as an empty item, that is, the resulting value for the item will be a zero-length string, similar to the example shown previously.