[xsd-users] warning with any

Boris Kolpackov boris at codesynthesis.com
Wed Jul 2 10:33:42 EDT 2008


Hi Ray,

Rizzuto, Raymond <Raymond.Rizzuto at sig.com> writes:

> 1>SDMP-1.2.xsd:738:90: warning: namespace '##any' allows for element 'ticket'
> 1>SDMP-1.2.xsd:738:90: warning: generated code may not associate element 
> 'ticket' correctly if it appears in place of this wildcard
> 1>SDMP-1.2.xsd:601:46: info: element 'ticket' is defined here
>
> [...]
> 
>  <xs:sequence>
>    <xs:element ref="ticket" minOccurs="0"/>
>    <xs:element name="price" type="Price"/>
>    <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded">
>  </xs:sequence>

The special ##any namespace indicates that an element from any
namespace, including the schema's target namespace, can appear.
As a result, in order to support this widlcard in the general
case, one needs to perform full-blown structure validation in
order to determine which elements are matched by which schema
declaration. In the C++/Tree mapping we delegate the XML Schema
validation to the underlying XML parser (Xerces-C++) and thus,
in certain situations, cannot guarantee correct association
of content.

For example, an element with name 'ticket' can appear for the
wildcard which may cause the current parsing code to fail to
associate this element properly (e.g., it will be associated
to the 'ticket' element instead of the wildcard) That's why
the XSD compiler detects such cases and issues warnings.

It is rarely the intention of the schema author to allow elements
from the same schema (let alone the same type) to appear in the
wildcard. If the 'ticket' and 'price' elements can never appear
in the content matched by the wildcard then you can safely ignore
this warning.

If none of the elements from the schema's target namespace are
supposed to appear in the content matched by the wildcard, then
you can go a step further and replace ##any with ##other which
will get rid of the warning.

Boris




More information about the xsd-users mailing list