Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: when will empty tags pass schema validation?

From: Peter Flynn <peter.nosp@-.--------.-->
To: NULL
Date: 5/5/2006 11:48:00 PM

wolf_y wrote:
> Thanks for answering, but maybe I should have led with my disclaimer:
> I'm a newbie to XML, primarily program in SAS, and consulted online
> documentation.
> 
> Some of my confusion stems from the way terms such as empty, missing,
> null, and blank are used/handled in different languages.  I don't mind
> reading docs, but I can't find an answer I understand at
> http://www.w3.org/ or url links I've found.
> 
> I don't want to create an empty element, but need to know under what
> circumstances an empty element will pass schema checks, 

I think the confusion arises from the two different meanings of the word.

a) EMPTY (in caps) is an XML keyword used to declare that a certain
    element type can *never* have any content (neither character data
    content nor other elements)

b) empty (in lowercase) is just an adjective meaning "with no content";
    it doesn't specify whether content is permitted or not, it simply
    says that there isn't any content at the moment.

An element type declared as EMPTY can be represented as <foo/> or as
<foo></foo>. The first is often recommended because it is unambiguous
and there is no possibility of anyone ever manually inserting any
content and thereby breaking the document model.

An element type declared *with* content *may* be empty on some
occasions (like this <name></name>) but that does not necessarily mean
that it was declared EMPTY: you'd have to consult the Schema or DTD
to find that out.

So an empty element like <name></name> will pass a validation check
either

a) if it was declared EMPTY, or
b) it was declared with optional content and just doesn't happen to
    have any right now.

An element like <foo/> will only pass a validation check if it was
declared EMPTY.

(In both cases I am assuming there are no compulsory attributes.)

///Peter
-- 
XML FAQ: http://xml.silmaril.ie/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent