users@jaxb.java.net

Please help with educating me on the jaxb bindings to deal with duplicate elements in mutliple .xsd files.

From: Jarrod Roberson <jarrod_at_vertigrated.com>
Date: Wed, 13 Jul 2011 16:47:58 -0400

I asked the question on stackoverflow.com
http://stackoverflow.com/questions/6681265/

I have 4 .xsd files that I want to auto-generate code for. A couple of the
files have duplicate names that clash when I try to generate all of them at
the same time.

When I get these 4 working I have about a hundred files to process. But I am
just focusing on 4 of these files for now. I am not in control of them, they
are from a vendor, so adding something to every one of them is not an
option, neither is deleting the offending duplicates.

I am using the maven-jaxb2-plugin to process these files.

I am getting the following error when I try and generate code from my .xsd
files.

[ERROR] Error while parsing schema(s).Location [
file:/C:/Users/Jarrod%20Roberson/Projects/spa-tools/spa-lib/src/main/sc
hema/mac-stylesheet-3.4.xsd{165,33}].
org.xml.sax.SAXParseException: 'halign' is already define

Here is my binding.xjb file

<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="2.1"
              xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
              xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
              xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
              xmlns:xs="http://www.w3.org/2001/XMLSchema"
              xsi:schemaLocation=" http://java.sun.com/xml/ns/jaxb
http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd">
  <jxb:bindings schemaLocation="mac-3.4.xsd">
    <jxb:schemaBindings>
      <jxb:package name="my.company.mac"/>
    </jxb:schemaBindings>
  </jxb:bindings>
  <jxb:bindings schemaLocation="mac-stylesheet-3.4.xsd">
    <jxb:schemaBindings>
      <jxb:package name="my.company.stylesheet"/>
    </jxb:schemaBindings>
  </jxb:bindings>
</jxb:bindings>

here is the offending element that is in multiple files, all the same
definition, this appears in both .xsd files.

  <xsd:simpleType name="halign">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="left" />
      <xsd:enumeration value="center" />
      <xsd:enumeration value="right" />
    </xsd:restriction>
  </xsd:simpleType>


I would ideally like duplicate entries to all point to the implemenation of
the very first entry if at all possible.

-- 
Jarrod Roberson
678.551.2852