Question

I use XJC and now I want to use XMLCataloges which refers to other cataloges. The problem is that it should be able to use relative paths instead of absolute paths when referencing to other cataloges.

This catalog is placed in project1 and should refer to the catalog.xml file located in the project2.

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">

<public publicId="http://company.com/test"
    uri="src/main/resources/test.xsd" />

<nextCatalog catalog="../project2/catalog.xml" /></catalog>

The XJC call looks like this:

<java fork="true" jar="${xjc-jar-file}">
    <!-- folder where the generated files should be saved -->
    <arg value="-d" />
    <arg value="${target-folder}"/>
        <arg value="-extension" />
    <!-- catalog file -->
    <arg value="-catalog" />
    <arg value="${catalog-file}" />
    <!-- current xsd file -->
    <arg value="@{xsd-file}" />
</java>

Have I made a mistake in the catalog file, or is there any workaround for using such catalog with XJC?

Was it helpful?

Solution

My web search for using relative paths was not successful.

Finally I ended up with writing an ant task which edit catalog files.

In detail the task edit the xml:base attributeof the catalog file and insert the absolute path to the catalog file. Then I save the catalog as e.g. catalog_temp.xml and get all nextCatalog nodes with XPath which will be edited recursive like the first one.

After executing XJC I execute my ant task again which deletes all edited (catalog_temp.xml) cataloges.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top