users@jaxb.java.net

Re: Is it possible to use JAXB having a partial schema of the documents to be processed?

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 28 May 2004 09:03:20 -0700

> In other words, I wanted to use JAXB to read documents without having to
> specify the full schema of those documents , skipping some attributes and
> elements and just define the attributes and elements that the application
> is interested in. The full schema may be too large, some elements have too
> many attributes and I am not sure I would be able to finish a schema that
> fully describes all the possible documents....and there is no need to have
> such a complete schema. (we dont generate such documents, just use
> partial information from them).

I see.

Since the attribute wildcard isn't speced in JAXB 1.0, you have to turn
on the -extension mode. The compiler should have told you that.
Even in the extension mode the contents of the wildcard will be just
ignored, but I guess that's OK with you.

For content model, you have to be careful when using wildcard, because
you can easily make your schema incorrect wrt the XML Schema spec.

For example, you can't say:

    a, wildcard*, b

I think this is the problem you are facing. To work around this, you
have to try to massage your content model, but in general this is hard.

Alternatively, you can use RELAX NG (http://relaxng.org/), so that you
can write:

    <element name="a">
       ... content model of A ...
    </element>
    
    <zeroOrMore>
      <element>
        <anyName>
          <except>
            <name>a</name>
          </except>
        </anyName>
        
        ...
      </element>
    </zeroOrMore>
    
    <element name="b">
      ... content model of B ...
    </element>



regards,
--
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net