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

XSD Generator: Support emitting xs:any for fields not restricting the element name #264

Closed
kwin opened this issue Oct 20, 2022 · 2 comments · Fixed by #265
Closed

XSD Generator: Support emitting xs:any for fields not restricting the element name #264

kwin opened this issue Oct 20, 2022 · 2 comments · Fixed by #265

Comments

@kwin
Copy link
Contributor

kwin commented Oct 20, 2022

Currently <xs:any> is only emitted for fields with type java.util.Properties or DOM (

else if ( Properties.class.getName().equals( field.getType() )
|| "DOM".equals( field.getType() ) )
{
writePropertiesElement( w );
}
).

For the case of the Maven plugin descriptor the element configuration may contain children with arbitrary names (although in the Model it is incorrectly described as paramName, https://maven.apache.org/ref/3.8.6/maven-plugin-api/plugin.html#class_paramName).
The according MDO at https://github.com/apache/maven/blob/daa8e1690226fc385db3d448ad962997afe3dba8/maven-plugin-api/src/main/mdo/plugin.mdo#L340 just defines the placeholder paramName instead.

As XSD unfortunately doesn't support enforcing a complex type on elements with arbitrary names, the best one can come up with is xs:any.

I propose to support a value * for xml.tagName in https://codehaus-plexus.github.io/modello/modello.html#field which leads to allowing everything below in the XSD.

@kwin kwin changed the title XSD Generator: Support emittting xs:any for association XSD Generator: Support emitting xs:any for association Oct 20, 2022
@kwin
Copy link
Contributor Author

kwin commented Oct 20, 2022

One other alternative is to emit XSD 1.1 which allows to put additional assertions on elements: https://stackoverflow.com/questions/14644747/is-it-possible-to-define-a-xsd-element-with-an-arbitrary-name-but-with-specific, but unfortunately XSD 1.1 parsers are not very common.

@kwin kwin changed the title XSD Generator: Support emitting xs:any for association XSD Generator: Support emitting xs:any for fields not restricting the element name Oct 20, 2022
@kwin
Copy link
Contributor Author

kwin commented Oct 21, 2022

FTR: This is how Maven POM deals with configuration element: https://github.com/apache/maven/blob/18eff3baeb899ddd27b34635c8f0d7e47f5c027b/api/maven-api-model/src/main/mdo/maven.mdo#L2164 (it leverages type=DOM)

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

Successfully merging a pull request may close this issue.

1 participant