As I wrote: It depends on how that enum type for ReturnCode is being used in
other places.
Which values do you need to process in input XML?
I suppose you don't have problems while marshalling?
What kind of "strange error" are you getting?
I can't begin to think about a solution if all I know is "strange error".
-W
On Mon, May 3, 2010 at 5:05 PM, Rochak Gupta <rochak005_at_gmail.com> wrote:
> problem is this is the way it was done in Jaxb1 and my application is
> running with that. Now i am migrating this to jaxb2.0 and i cannot change
> the XSD. What can i do now ?
>
> Is there any way to define external binding to add values for enum that are
> not in XSD? or any other work around to overcome this ?
> Thanks and regards,
> Rochak
> On Mon, May 3, 2010 at 5:35 PM, Wolfgang Laun <wolfgang.laun_at_gmail.com>
> wrote:
>>
>> How an absent element or attribute is handled is not a question of the
>> class of that element or attribute (and therefore the code of enum
>> ReturnCode does not matter).
>>
>> If ReturnType is used as an attribute, the attribute definition may
>> define use="optional" and default="whatever". Then, xjc will generate
>> code giving you the default in return for an absent attribute.
>>
>> If ReturnCode is used as the type of an XML element, then XML Schema
>> lets you specify minOccurs="0" with that element, indicating it may be
>> absent, but there is no way to define a default value in XML Schema
>> for that. (Any application that is not prepared to handle an absent
>> element that may be omitted has a serious bug.)
>>
>> If the XML does contain a value, but not matching one of the
>> <enumeration> values, then the XML is in error, and if this throws an
>> exception, it is not a "strange error".
>>
>> -W
>>
>>
>> On Mon, May 3, 2010 at 1:16 PM, Rochak Gupta <rochak005_at_gmail.com> wrote:
>> > Hi ,
>> >
>> > We are getting strange error while upgrading our code from JAXB1.x to
>> > JAXB2.x .
>> >
>> > Here
>> >
>> > <simpleType name="ReturnCode">
>> >
>> > <restriction base="string">
>> >
>> > <enumeration value="Mal-formed Input"/>
>> >
>> > <enumeration value="TN/CLS and SO combination is not
>> > found"/>
>> >
>> > <enumeration value="SO failed provisioning"/>
>> >
>> > <enumeration value="SO not found"/>
>> >
>> > </restriction>
>> >
>> > </simpleType>
>> >
>> >
>> >
>> >
>> >
>> > In JAXB2.X Returncode enum type is created. I have used the decompiler
>> > and
>> > pasted here
>> >
>> > // Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov Date:
>> > 5/1/2010
>> > 3:21:30 PM
>> >
>> > // Home Page : http://members.fortunecity.com/neshkov/dj.html - Check
>> > often
>> > for new version!
>> >
>> > // Decompiler options: packimports(3)
>> >
>> > // Source File Name: ReturnCode.java
>> >
>> > package com.bellsouth.snt.broadbandos.idm.xml.techaccess.schema;
>> >
>> >
>> >
>> >
>> >
>> > public final class ReturnCode extends Enum
>> >
>> > {
>> >
>> >
>> >
>> > public static ReturnCode[] values()
>> >
>> > {
>> >
>> > return (ReturnCode[])$VALUES.clone();
>> >
>> > }
>> >
>> >
>> >
>> > public static ReturnCode valueOf(String name)
>> >
>> > {
>> >
>> > return
>> >
>> > (ReturnCode)Enum.valueOf(com/bellsouth/snt/broadbandos/idm/xml/techaccess/schema/ReturnCode,
>> > name);
>> >
>> > }
>> >
>> >
>> >
>> > private ReturnCode(String s, int i, String v)
>> >
>> > {
>> >
>> > super(s, i);
>> >
>> > value = v;
>> >
>> > }
>> >
>> >
>> >
>> > public String value()
>> >
>> > {
>> >
>> > return value;
>> >
>> > }
>> >
>> >
>> >
>> > public static ReturnCode fromValue(String v)
>> >
>> > {
>> >
>> > ReturnCode arr$[] = values();
>> >
>> > int len$ = arr$.length;
>> >
>> > for(int i$ = 0; i$ < len$; i$++)
>> >
>> > {
>> >
>> > ReturnCode c = arr$[i$];
>> >
>> > if(c.value.equals(v))
>> >
>> > return c;
>> >
>> > }
>> >
>> >
>> >
>> > throw new IllegalArgumentException(v);
>> >
>> > }
>> >
>> >
>> >
>> > public static final ReturnCode MAL_FORMED_INPUT;
>> >
>> > public static final ReturnCode
>> > TN_CLS_AND_SO_COMBINATION_IS_NOT_FOUND;
>> >
>> > public static final ReturnCode SO_FAILED_PROVISIONING;
>> >
>> > public static final ReturnCode SO_NOT_FOUND;
>> >
>> > private final String value;
>> >
>> > private static final ReturnCode $VALUES[];
>> >
>> >
>> >
>> > static
>> >
>> > {
>> >
>> > MAL_FORMED_INPUT = new ReturnCode("MAL_FORMED_INPUT", 0,
>> > "Mal-formed
>> > Input");
>> >
>> > TN_CLS_AND_SO_COMBINATION_IS_NOT_FOUND = new
>> > ReturnCode("TN_CLS_AND_SO_COMBINATION_IS_NOT_FOUND", 1, "TN/CLS and SO
>> > combination is not found");
>> >
>> > SO_FAILED_PROVISIONING = new
>> > ReturnCode("SO_FAILED_PROVISIONING", 2,
>> > "SO failed provisioning");
>> >
>> > SO_NOT_FOUND = new ReturnCode("SO_NOT_FOUND", 3, "SO not
>> > found");
>> >
>> > $VALUES = (new ReturnCode[] {
>> >
>> > MAL_FORMED_INPUT, TN_CLS_AND_SO_COMBINATION_IS_NOT_FOUND,
>> > SO_FAILED_PROVISIONING, SO_NOT_FOUND
>> >
>> > });
>> >
>> > }
>> >
>> > }
>> >
>> >
>> >
>> >
>> >
>> > Now if there is any other value it throws exception . Our concern is can
>> > we
>> > some way or through some external binding some default value to the enum
>> > so
>> > that if its null it takes default value .
>> >
>> > Thanks and regards,
>> >
>> > Rochak
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>
>
>