[
https://jira.codehaus.org/browse/MJAXB-55?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=283835#comment-283835
]
Lennart Jörelid commented on MJAXB-55:
--------------------------------------
The solution is rather straightforward, gentlemen; I have a decently complete
implementation and test case for the scenario where several namespaces are
generated by a model.
Moreover - I believe the renaming feature within the plugin to be very valuable
in any decently large project (and not as an afterthought).
Since generated schema files contain references to other schema file names
within the same JAXB generation unit, it is important that all renaming is done
at the same time.
Typical scenario:
a) [fact] JAXB requires the schema file/stream to enable validation upon
serialization
b) [fact] JAXB validation requires you to match the marshaled entity with its
generated schema
c) [scenario] Your deliverable contains 40 maven projects, each holding several
JAXB-annotated entity classes within separate namespaces
d) [fact] Generated schema files refer between their own namespace and the
generated filename of each imported namespace (see below). This is complex and
messy if all schema file names are called schemaX.xsd.
e) [fact] Maven's pom should be as simple as possible. Noone wants to mess
around with several plugins to achieve the effect that one plugin should
provide. In this case, the JAXB maven plugin should provide filename alteration
and consistent schema transformation (i.e. xs:import
namespace="http://another/namespace"
schemaLocation="whateverIWannaCallTheFile.xsd").
Consider the generated schema below, and multiply the complexity of renaming
all generated schema files with the number of projects... and I hope you reach
the same conclusion as me. This is the job of our plugin, not a set of other
plugins. Simplicity is king.
Example of a generated multi-namespace schema. Note the import statement
referring to another namespace/generated schema file.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="http://some/namespace"
xmlns:ns1="http://another/namespace"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://another/namespace" schemaLocation="schema3.xsd"/>
<xs:element name="anOptionalElementInSomeNamespace" type="xs:string"/>
<xs:complexType name="fooBar">
<xs:sequence>
<xs:element name="requiredElement" type="xs:string"
default="requiredElementValue"/>
<xs:element ref="ns1:aRequiredElementInAnotherNamespace"
default="requiredElementValue"/>
<xs:element name="optionalElement" type="xs:string" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="requiredAttribute" type="xs:string" use="required"/>
<xs:attribute name="optionalAttribute" type="xs:string"/>
</xs:complexType>
</xs:schema>
> Provide means to set the file name of generated XML schema
> ----------------------------------------------------------
>
> Key: MJAXB-55
> URL: https://jira.codehaus.org/browse/MJAXB-55
> Project: Maven 2.x JAXB 2.1 Plugin
> Issue Type: New Feature
> Affects Versions: 1.3.1
> Environment: All
> Reporter: Lennart Jörelid
> Assignee: Anders Hammar
> Attachments: fileRenamePatch.diff
>
>
> AbstractSchemagenMojo sneakily hard-codes the resulting filename for the
> generated schema file.
> This should really be configurable; provided a parameter to set the resulting
> file name, as well as an integration test.
> For reasons of somewhat misguided backwards compatibility, I set the default
> value of the parameter to its currently hardcoded value, "schema1.xsd".
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email