The Maven JAXB plugin was enhanced this past weekend such that it can now
reference an XML Schema file contained within a jar file managed as a
dependency under Maven in the Eclipse environment. This is useful for
generating Java code from an XML Schema using the JAX XJC feature where it
is desired not to regenerate Java code for schema that has been imported
into another schema to use its types.

A sample Maven project demonstrating this enhancement is available at:

This solution still leaves one more item that pertains to the
utility/usage of the XML Catalog feature in Eclipse. That is, for the
author or future editor of a 'b.xsd' XML Schema there will still be an
error reported when the 'a.xsd' file is not referenceable via the value
specified in the b.xsd import statement for 'a.xsd'. That's because the
Eclipse XML Schema editor won't inherently find 'a.xsd' in a Maven managed
jar file (which is on the classpath in the Eclipse project) without the
successful addition of an XML Catalog entry.

I did note that Eclipse does have an XML Catalog dialog which is part of
the Eclipse preferences system. This is found at Preferences -- Web and
XML -- XML Catalog. However when I tried to create a user entry there for
a Maven artifact, this produced an error due to the '.' in
~/.m2/repository/... path. The standard convention for Maven is that the
repository cached on a workstation is located at ~./.m2/repository.
Therefore the '.m2' portion of the file path which results in the error in
the Eclipse XML Catalog preference tool.

Does anyone here know if there is a way to reference a Maven jar with the
Eclipse XML Catalog such that the Eclipse XML Schema Editor can resolve
the import statement for a.xsd when editing b.xsd? I can see system
entries that reference XSD files in jar files, but can't seem to
successfully enter one for the Maven dependencies.

The XML Catalog entry for the Maven JAXB solution looks like the following
example (uses a scheme of 'classpath'):

Sorry I misled you by using this compact Unix notation [ ~./.m2 ]. That
was just to avoid typing out the entire pathname. The actual item in
question which is causing the error in the Eclipse XML Catalog preferences
tool is the fully specified form.

For example, using the File System ... menu option in the Add XML Catalog
Entry dialog, the following actual Location from my local Maven repository
is selected:

Modifying the location to remove the '.' in front of m2 eliminates the
above error, but is not the correct location of the xsd file which then
yields this error:

The specified resource can't be located: C:\Documents and
Settings\my-username\m2\....

I also tried adding jar:file: in front of the location but this didn't
eliminate the original error.

Please advise how I can use the XML Catalog feature in Eclipse to map an
XSD contained in a jar file in the Maven repository. Is this a bug? Or is
there another way to handle this?

As a separate issue, I don't seem to be able to use the XML Catalog
feature in Eclipse where the purpose is to get a valid edit of another
schema in the XML Schema Editor which resolves an import statement which
depends on an XML Catalog entry for the referenced schema file.

Is there a limitation with the XML Catalog feature? The online Eclipse
help seems to only give examples where the focus is to resolve an XSD for
an XML instance, rather than for an XML Schema that references the mapped
XSD file. Should the XML Catalog feature work with XML Schemas import
statement as well as for XML instances?

Make sure that your URI is using the file:/// indicator if it isn't already.

Dave

Patrick Podenski wrote:
> Nitin asked:
>
> Are you certain that it is the '.' and not the '~'?
>
> Sorry I misled you by using this compact Unix notation [ ~./.m2 ]. That
> was just to avoid typing out the entire pathname. The actual item in
> question which is causing the error in the Eclipse XML Catalog
> preferences tool is the fully specified form.
>
> For example, using the File System ... menu option in the Add XML
> Catalog Entry dialog, the following actual Location from my local Maven
> repository is selected:
>
>
> [ C:\Documents and
> Settings\my-username\.m2\repository\org\jvnet\jaxb2\maven2\m aven-jaxb2-plugin-sample-episode-a-maven\0.6.1\maven-jaxb2-p lugin-sample-episode-a-maven-0.6.1.jar
> ]
>
> This location yields the following error:
>
> URI must not be included '.' or '..'
>
> Modifying the location to remove the '.' in front of m2 eliminates the
> above error, but is not the correct location of the xsd file which then
> yields this error:
>
> The specified resource can't be located: C:\Documents and
> Settings\my-username\m2\....
>
>
> I also tried adding jar:file: in front of the location but this didn't
> eliminate the original error.
>
> Please advise how I can use the XML Catalog feature in Eclipse to map an
> XSD contained in a jar file in the Maven repository. Is this a bug? Or
> is there another way to handle this?
>
> As a separate issue, I don't seem to be able to use the XML Catalog
> feature in Eclipse where the purpose is to get a valid edit of another
> schema in the XML Schema Editor which resolves an import statement which
> depends on an XML Catalog entry for the referenced schema file.
>
> Is there a limitation with the XML Catalog feature? The online Eclipse
> help seems to only give examples where the focus is to resolve an XSD
> for an XML instance, rather than for an XML Schema that references the
> mapped XSD file. Should the XML Catalog feature work with XML Schemas
> import statement as well as for XML instances?
>
>
>