Re: [xml-dev] What does "optional" mean?

From
John Cowan <>
To
Mukul Gandhi <>
Date
2012-02-26T20:25:44Z
ID
<>
Thread
Re: [xml-dev] What does "optional" mean?
Mukul Gandhi scripsit:

> Following is an use case, that probably makes the notion of "optional"
> in XML documents *necessary*,
> 
> Let's assume, that a book object may be represented in an XML format

[snip]

> i.e, an ISBN number of book may be represented either as an attribute
> or as a child element of element book, but not at both of these
> places. To define a schema for this need (at least with XSD I
> believe), a schema author I think *must* make the attribute "isbn" and
> the element "isbn" as optional and constrain a singular cardinality of
> the semantic information "isbn" via another schema constraint.

That is indeed an XSD 1.0 limitation.  It does not apply to RNG, where
representing a choice between an element and an attribute is trivial.
I don't know if it applies to XSD 1.1 or not.  It does not apply to
Schematron either, where everything that is not forbidden is permitted.

There is a more general point: it's not always possible in any schema
language to represent the exact specification, and applications may need
to do further validation of the input.

-- 
LEAR: Dost thou call me fool, boy?      John Cowan
FOOL: All thy other titles              http://www.ccil.org/~cowan
             thou hast given away:      
      That thou wast born with.