users@jaxb.java.net

Re: JAXB not repeatable?

From: Lowell Kirsh <lowellk_at_gmail.com>
Date: Thu, 5 Oct 2006 16:26:28 -0700

Not that this helps, but I have had similar problems. I have a type defined
in my schema:

    <xs:complexType name="numericList">
        <xs:choice maxOccurs="unbounded">
            <xs:element ref="number" />
            <xs:element ref="numberRange"/>
        </xs:choice>
    </xs:complexType>

The java code that it produces is sometimes getNumbersAndNumberRanges() and
other times it generates getNumberRangesAndNumbers(). This is without
changing the schema at all.

If anyone knows how to fix this, please let me know.

Thanks
Lowell

On 10/5/06, Hilco Wijbenga <hilco.wijbenga_at_gmail.com> wrote:
>
> Hi all,
>
> JAXB (1.4) is part of our build and everything is working nicely. We
> are trying to modularise the build more (preparing for our move to
> Maven) and to facilitate that I'm trying to create a comparison script
> allowing me to guarantee that a change to the build script does not
> change the result.
>
> The first test case, of course, is to run the current build twice and
> see if it yields the same result. Oops ... no it doesn't. :-(
>
> There is a simple and obvious problem: JAXB adds comments with
> timestamps and references to the files. I've succesfully removed those
> with a simple replace after JAXB has finished. Is there a way to tell
> JAXB (1.4) not to generate these comments?
>
> Now for my real problem: the source code that is generated is actually
> different on subsequent runs of the build. Not different as in
> different behaviour, but different as in different class files. The
> first run would generate something like
>
> public void enterElement(<snip/>) throws org.xml.sax.SAXException {
> <snip/>
> switch (state) {
> case 1 :
> <snip/>
> case 3 :
> <snip/>
> case 0 :
> <snip/>
> }
> <snip/>
> }
>
> but the second run would generate (e.g.)
>
> public void enterElement(<snip/>) throws org.xml.sax.SAXException {
> <snip/>
> switch (state) {
> case 1 :
> <snip/>
> case 0 :
> <snip/>
> case 3 :
> <snip/>
> }
> <snip/>
> }
>
> (note cases '0' and '3' have swapped places).
>
> An other problem I see is in code like
>
> public com.sun.msv.verifier.DocumentDeclaration createRawValidator() {
> if (schemaFragment == null) {
> schemaFragment = com.sun.xml.bind.validator.SchemaDeserializer.deserialize
> ((
> "... abc ..."
> ));
> return new com.sun.msv.verifier.regexp.REDocumentDeclaration
> (schemaFragment);
> }
>
> where a subsequent run yields 'xyz' instead of 'abc' (the 'abc' and
> 'xyz' are usually close but not identical).
>
> I tried running JAXB outside of the build but, of course, I can't
> reproduce the problem then: subsequent JAXB invocations yield exactly
> the same source code. Sigh.
>
> I would greatly appreciate any help or ideas to get a repeatable
> build. What kind of outside influences would have an effect on the
> generated source code?
>
> Cheers,
> Hilco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>