jaxb2-basics icon indicating copy to clipboard operation
jaxb2-basics copied to clipboard

JAXB2 Simplify plugin for DTD files

Open sachinbedraman opened this issue 8 years ago • 0 comments

Hello,

I have been using this plugin for generating Java classes from DTD's and its is very helpful in terms of configuration and generation.

I am generating the Java classes for cXML standard. I have the schema, binding file and the generated Java class for your reference. I am using the 'JAXB2 Simplify Plugin'.

I have configured the execution in pom.xml as given below.

<!-- Configuration for cXML.dtd -->
<execution>
	<id>generate-cXML</id>
	<goals>
		<goal>generate</goal>
	</goals>
	<configuration>
		<cleanPackageDirectories>true</cleanPackageDirectories>
		<schemaDirectory>src/main/dtd/cxml/</schemaDirectory>
		<schemaLanguage>DTD</schemaLanguage>
		<schemaIncludes>
			<include>*.dtd</include>
		</schemaIncludes>
		<schemaExcludes>
			<exclude>*.xs</exclude>
		</schemaExcludes>
		<generateDirectory>src/main/generated-cxml</generateDirectory>
		<generatePackage>org.cxml</generatePackage>
		<bindingDirectory>src/main/bindings/cxml</bindingDirectory>
		<bindingIncludes>
			<bindingInclude>*.xjb</bindingInclude>
		</bindingIncludes>
		<extension>true</extension>
		<args>
			<arg>-Xsimplify</arg>
		</args>
		<plugins>
			<plugin>
				<groupId>org.jvnet.jaxb2_commons</groupId>
				<artifactId>jaxb2-basics</artifactId>
				<version>0.9.4</version>
			</plugin>
		</plugins>
	</configuration>
</execution>

In the generated CXML.java file, instead of generating separate attributes, a single collection attribute has been generated.

    @XmlElements({
        @XmlElement(name = "Header", required = true, type = Header.class),
        @XmlElement(name = "Message", required = true, type = Message.class),
        @XmlElement(name = "Request", required = true, type = Request.class),
        @XmlElement(name = "Response", required = true, type = Response.class)
    })
    protected List<Object> headerOrMessageOrRequestOrResponse;

I was not able to find the correct way to configure the binding for DTD files for using the 'JAXB2 Simplify Plugin'.

I am trying to understand if I have configured the plugin in a wrong way or if support is not yet available for the same.

Thank you, Sachin

cXML.zip

sachinbedraman avatar Oct 30 '17 11:10 sachinbedraman