[xsd-users] warning with any

Rizzuto, Raymond Raymond.Rizzuto at sig.com
Wed Jul 2 11:10:30 EDT 2008


Boris,

I can see where the ambiguity would occur in certain cases, such as with
optional or sets, but for a sequence of A, B, ##ANY, where A and B must
appear exactly 1 time, an A or B in the ##ANY slot shouldn't be
ambiguous.

Does the warning occur for ##ANY, regardless of that?  I.e. the warning
is not taking the context into consideration, just telling the author to
be advised?

Since I am not the schema author, I can't really make changes, but I'll
raise the question with the author.  I believe he has the ##ANY in so
that a future version of the protocol will be compatible with the
current version.  I.e. a 1.3 version with a new field added at the end
of the sequence will still talk to the 1.2 version I am coding.

Ray

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: Wednesday, July 02, 2008 10:34 AM
To: Rizzuto, Raymond
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] warning with any

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

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.




More information about the xsd-users mailing list