Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

referencing/including xsd files in a jar

I want to add an xsd file to our project that relies on types defined in another xsd that is in a jar. We use jaxb to generate Java classes from the xsds. How do i refer to SchemaContainingFooTypeIsInaJAR.xsd so that 'FooType' resolves correctly and the proper Java classes get generated

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="SchemaContainingFooTypeIsInaJAR.xsd"/>
<xs:complexType name="FooMoreType">
    <xs:complexContent>
        <xs:extension base="FooType">
            <xs:sequence>
                <xs:element name="something" type="xs:boolean" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation xml:lang="en">
                            something something
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:sequence>
        </xs:extension>
    </xs:complexContent>
</xs:complexType>
</xs:schema>
like image 241
charudatta Avatar asked Nov 04 '22 16:11

charudatta


1 Answers

You might be interested in these features:

  • http://confluence.highsource.org/display/MJIIP/User+Guide#UserGuide-CompilingaschemafromaMavenartifact
  • http://confluence.highsource.org/display/MJIIP/User+Guide#UserGuide-Usingcatalogs

In short, you can write a catalog file which would point to your schema in a JAR file:

REWRITE_SYSTEM "some/url/a.xsd" "maven:org.jvnet.jaxb2.maven2:maven-jaxb2-plugin-tests-episodes-a!/a.xsd"

DISCLAIMER: I am the principal dev of maven-jaxb2-plugin.

like image 152
lexicore Avatar answered Nov 09 '22 14:11

lexicore