Note that there are some explanatory texts on larger screens.

plurals
  1. POJAXB xjc parsing fails when -binding is used together with -catalog (bug?)
    text
    copied!<p>Below is the absolute trivial, minimal example that demonstrates the problem. Three schema files: <em>A.xsd</em>, <em>B.xsd</em>, <em>C.xsd</em> in the following import configuration:</p> <pre><code>C.xsd ---------------- imports ----------------&gt; A.xsd \ / \---- imports ---&gt; B.xsd --- imports ----/ </code></pre> <p>So <em>A.xsd</em> is imported directly by <em>C.xsd</em> and again indirectly through <em>B.xsd</em>. The problem occurs when trying to run <strong>xjc</strong> (ver. <strong>2.2.4</strong>) on <em>C.xsd</em> when <strong>both</strong> a catalog <strong>and</strong> a binding file is used (even an empty one).</p> <h2>A.xsd</h2> <pre><code>&lt;schema targetNamespace="foo://a" xmlns="http://www.w3.org/2001/XMLSchema"&gt; &lt;simpleType name="year"&gt; &lt;restriction base="dateTime"&gt; &lt;pattern value="\d{4}"/&gt; &lt;/restriction&gt; &lt;/simpleType&gt; &lt;/schema&gt; </code></pre> <h2>B.xsd</h2> <pre><code>&lt;schema targetNamespace="foo://b" xmlns="http://www.w3.org/2001/XMLSchema"&gt; &lt;import namespace="foo://a" schemaLocation="boo://a.xsd"/&gt; &lt;/schema&gt; </code></pre> <h2>C.xsd</h2> <pre><code>&lt;schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="foo://c"&gt; &lt;import namespace="foo://a" schemaLocation="A.xsd"/&gt; &lt;import namespace="foo://b" schemaLocation="B.xsd"/&gt; &lt;/schema&gt; </code></pre> <h2>catalog.xml</h2> <pre><code>&lt;catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"&gt; &lt;system systemId="boo://a.xsd" uri="A.xsd"/&gt; &lt;/catalog&gt; </code></pre> <h2>binding.xjb</h2> <pre><code>&lt;bindings xmlns="http://java.sun.com/xml/ns/jaxb" version="2.1"/&gt; </code></pre> <p>Given the above files, all placed in the same directory the below invocation succeeds:</p> <pre><code>xjc -d src -extension -catalog catalog.xml C.xsd </code></pre> <p>whereas the following invocation:</p> <pre><code>xjc -d src -extension -catalog catalog.xml C.xsd -b bindings.xjb </code></pre> <p>... <strong>fails</strong> with the bug-like message (pointing to some internal mess-up?):</p> <pre><code>parsing a schema... [ERROR] 'year' is already defined line 8 of file:/home/brutus/A.xsd [ERROR] (related to above error) the first definition appears here line 3 of file:/home/brutus/A.xsd Failed to parse a schema. </code></pre> <h2>UPDATE</h2> <p>Posted a <a href="https://java.net/jira/browse/JAXB-963" rel="nofollow">bug report</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload