1

I want to generate two group of classes and one class have the same name - TAG, from two different XML.

<templates xmlns="http://xxxxxxxxxxx.xx.xxx.xxx">
    <template name="XXXXXXXXXXXXXXXXXXXXX">
        <tag id="XXXXXXXXXXX">
            <tag id="XXXXXXX" value="XXXXXXXXX" />
        </tag>
        <tag id="YYY" value="YYYYY" />
    </template>
</templates>

and xsd file for this XML

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://xxxxxxxxxxx.xx.xxx.xxx"
            xmlns:tns="http://xxxxxxxxxxx.xx.xxx.xxx">

<xsd:element name="templates" type="tns:Templates"/>

<xsd:complexType name="Tag">
    <xsd:sequence>
        <xsd:element type="tns:Tag" name="tag"/>
    </xsd:sequence>
    <xsd:attribute type="xsd:string" name="id"/>
</xsd:complexType>

<xsd:complexType name="Template">
    <xsd:sequence>
        <xsd:element type="tns:Tag" name="tag" maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attribute type="xsd:string" name="name"/>
</xsd:complexType>

<xsd:complexType name="Templates">
    <xsd:sequence>
        <xsd:element type="tns:Template" name="template"/>
    </xsd:sequence>
</xsd:complexType>
</xsd:schema>

and the other XML with same element name

<?xml version="1.0" encoding="UTF-8"?>
<keys>
    <key label="XXXXXXXXXXXXXXX">
        <tag id="YYYYY" />
        <tag id="ZZZZZZZZZ" />
    </key>
</keys>

with the another xml.

To generate class I use a maven dependency:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>2.3</version>
        <executions>
            <execution>
                <id>xjc_pos</id>
                <goals>
                    <goal>xjc</goal>
                </goals>
                <configuration>
                    <packageName>ru.bpc.cg.cainterface</packageName>
                    <generateEpisode>false</generateEpisode>
                    <clearOutputDir>false</clearOutputDir>
                </configuration>
            </execution>
        </executions>
        <configuration>
            <outputDirectory>src/main/java</outputDirectory>
            <sources>
                <source>src/main/resources/ru/bpc/cg/cainterface/caTemplates.xsd</source>
                <source>src/main/resources/ru/bpc/cg/storagehandler/keyStorage.xsd</source>
            </sources>
        </configuration>
    </plugin>

After mvn clean package I have an error:

org.xml.sax.SAXParseException: A class/interface with the same name "com.xxxxxxxxxxxxx.Tag" is already in use. Use a class customization to resolve this conflict.

How to resolve this conflict? May be there is a link from one xsd to another with the same class definition.

Dean
  • 1,833
  • 10
  • 28
Vadim
  • 557
  • 8
  • 21
  • 1
    [This](https://stackoverflow.com/questions/35108965/how-to-use-a-class-customization-to-resolve-file-generating-conflicts) looks like the same question. – kaqqao Nov 09 '18 at 12:43
  • Possible duplicate of [How to use a class customization to resolve file generating conflicts](https://stackoverflow.com/questions/35108965/how-to-use-a-class-customization-to-resolve-file-generating-conflicts) – J Fabian Meier Nov 09 '18 at 12:53

0 Answers0