Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard '##any' causes the content model to become ambiguous #482

Open
jflevesque-genetec opened this issue Feb 2, 2024 · 1 comment
Open

Comments

@jflevesque-genetec
Copy link

Hi,

First time user of this generator and I'm getting these warnings that seem to prevent the code gen from completing. I am currently trying to understand how I should modify the XSD file to resolve these issues.

xscgen --namespace "|onvif.xsd=My.Custom.Namespace" --nullable --gc --netCore --nullableReferenceAttributes --verbose --output="c:\temp" common.xsd

Generates these logs:

Wildcard '##any' allows element 'http://www.onvif.org/ver10/schema:Extension', and causes the content model to become ambiguous. A content model must be formed such that during validation of an element information item sequence, the particle contained directly, indirectly or implicitly therein with which to attempt to validate each item in the sequence in turn can be uniquely determined without examining the content or attributes of that item, and without any information about the items in the remainder of the sequence.
Wildcard '##any' allows element 'http://www.onvif.org/ver10/schema:Weight', and causes the content model to become ambiguous. A content model must be formed such that during validation of an element information item sequence, the particle contained directly, indirectly or implicitly therein with which to attempt to validate each item in the sequence in turn can be uniquely determined without examining the content or attributes of that item, and without any information about the items in the remainder of the sequence.

Any ideas?

common.xsd can be found here: https://www.onvif.org/ver10/schema/common.xsd

@mganss
Copy link
Owner

mganss commented Feb 2, 2024

The error message is a validation error that occurs when compiling the XML schema using XmlSchemaSet.Compile().

Though the error message is pretty cryptic, I think what it means is that it's impossible to validate a document against the schema because of this part:

<xs:complexType name="ColorDescriptor">
        <xs:sequence>
	        <xs:element name="ColorCluster" minOccurs="0" maxOccurs="unbounded">
		        <xs:complexType>
			        <xs:sequence>
				        <xs:element name="Color" type="tt:Color"/>
				        <xs:element name="Weight" type="xs:float" minOccurs="0"/>
				        <xs:element name="Covariance" type="tt:ColorCovariance" minOccurs="0"/>
				        <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>	<!-- reserved for ONVIF -->
			        </xs:sequence>
			        <xs:anyAttribute processContents="lax"/>
		        </xs:complexType>
	        </xs:element>
	        <xs:element name="Extension" type="xs:anyType" minOccurs="0"/>
	        <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>	<!-- reserved for ONVIF -->
        </xs:sequence>
        <xs:anyAttribute processContents="lax"/>
</xs:complexType>
  1. If Weight occurs after Color, is it the explicit Weight element or were both Weight and Covariance omitted (minOccurs="0") and it's part of the any?
  2. Similarly, if Extension occurs, is it the explicit element or was that omitted and it's part of the any?

If you remove both of the above lines containing xs:any (lines 224 and 230) it will generate code. However, I'm not sure if this would allow all real life documents to deserialize.

Another way to fix the schema is to set minOccurs="1" for Covariance and Extension. Again, not sure what real life documents will look like for your use case and if they can be deserialized with this modification to the schema.

Third option I can think of is to make the owners of the schema aware of this ambiguity and have them fix it. Not sure if that's feasible of course. The organization that publishes the schema has a GitHub account https://github.com/onvif/ but I haven't investigated further if they accept issue reports in the schemas they publish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants