In JaxMeXS, the XSComplexType methods isEmpty(), isMixed(), and
isElementOnly() throw IllegalStateException if hasSimpleContent()
returns true.

This is inconsistent with other sets of methods that represent mutually
exclusive cases and with the XML Schema specification's treatment of the
cases.

Those first three methods probably should simply return false and
_not_ throw IllegalStateException when hasSimpleContent() would
return true.


Recall the other sets of methods representing mutually exclusive cases:

- XSModelGroup has the group isChoice(), isSequence(), and isAll().  The
  conditions they represent are mutually exclusive.  At least one is
  always true.  The user can call any method to ask if the corresponding
  condition is true.  The user can write a multi-way if statement in any
  order.

- XSComplexType has the pair isRestriction() and isExtension().  As above,
  the conditions they represent are mutually exclusive, at least one is
  always true, the user can call any method to ask if the corresponding
  condition is true, and the user can write a multi-way if statement in any
  order.

- XSParticle has the group isElement(), isGroup(), and isWildcard().  Again,
  the conditions they represent are mutually exclusive, at least one is
  always true, the user can call any method to ask if the corresponding
  condition is true, and the user can write a multi-way if statement in any
  order.

- There are also isList(), isUnion(), etc.

However, note the initial similarities but then inconsistencies:

- XSComplexType has the group hasSimpleContent(), isEmpty(), isMixed(),
  and isElementOnly().  The conditions they represent are mutually
  exclusive.  At least one is always true.

  *However*, the user *cannot* call any method to ask if the corresponding
  condition is true; the user must check hasSimpleType() first to avoid a
  possible IllegalStateException from the other methods.

  Additionally, the user *cannot* write a multi-way if statement in any
  order; the caller must handle hasSimpleContent() first (or otherwise
  call hasSimpleContent() first).



Additionally, these methods' asymmetry is inconsistent with how the the
XML schema specification treats the content type property of complex type
definition schema components.  The specification says:

  {content type} determines the �validation� of [children] of element
                 information items. Informally:

    * A {content type} with the distinguished value _empty_
      �validates� elements with no character or element
      information item [children].
    * A {content type} which is a Simple Type Definition
      (�2.2.1.2) �validates� elements with character-only
      [children].
    * An _element-only_ {content type} �validates� elements with
      [children] that conform to the supplied �content model�.
    * A _mixed_ {content type} �validates� elements whose element
      children] (i.e. specifically ignoring other [children] such
      as character information items) conform to the supplied
      �content model�.

Specifically, notice how the specification does _not_ divide the cases
between simple vs. complex-type cases (in which case it might have made
sense in the API to have to check a higher-level condition before
checking a lower-level condition).

Consider trying to implement some schema processing by following the
specification as closely as possible.  JaxMeXS's object model follows
the specification's object model (the schema components and properties)
fairly closely.  However, someone trying to handle the four cases of
complex types in the order from the specification will likly be tripped
up or at least inconvenienced, seemingly unnecessarily.



Therefore, it seems that methods isEmpty(), isElementOnly(), and isMixed()
should always return false when their respective conditions are false and
should not throw IllegalStateException when the content type is a simple
type.


Daniel







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to