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

Required fields lead to non required element in XSD #162

Closed
kwin opened this issue Jan 9, 2022 · 4 comments · Fixed by #263
Closed

Required fields lead to non required element in XSD #162

kwin opened this issue Jan 9, 2022 · 4 comments · Fixed by #263

Comments

@kwin
Copy link
Contributor

kwin commented Jan 9, 2022

E.g. the required field prefix from https://github.com/apache/maven/blob/master/maven-repository-metadata/src/main/mdo/metadata.mdo#L354-L360 leads to this XSD:

<xs:element minOccurs="0" name="prefix" type="xs:string">

Obsviously the element with name prefix must leave out minOccurs="0" to be required in the XMLs.

@michael-o
Copy link
Member

Please link the spot in question. I have provided it in the JIRA issue.

@kwin
Copy link
Contributor Author

kwin commented Jan 9, 2022

This seems to be caused by

// Usually, would only do this if the field is not "required", but due to inheritance, it may be
// present, even if not here, so we need to let it slide
w.addAttribute( "minOccurs", "0" );
.

@kwin
Copy link
Contributor Author

kwin commented Oct 18, 2022

The reason for this behaviour seems to be driven by pom.xml specifics, i.e. POMs are merged with their parents before they need to be valid. As this is definitely an edge case Modello should have a flag for enabling/disabling that behaviour.
By default it is reasonable to assume that the XML is not requiring post-processing before validating it against the schema.

@michael-o
Copy link
Member

The reason for this behaviour seems to be driven by pom.xml specifics, i.e. POMs are merged with their parents before they need to be valid. As this is definitely an edge case Modello should have a flag for enabling/disabling that behaviour. By default it is reasonable to assume that the XML is not requiring post-processing before validating it against the schema.

I fully agree with that.

kwin added a commit to kwin/modello that referenced this issue Oct 18, 2022
@kwin kwin closed this as completed in #263 Dec 29, 2022
kwin added a commit that referenced this issue Dec 29, 2022
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

Successfully merging a pull request may close this issue.

2 participants