Hi Lawrence

I tried this out and basically it works, but there is still a problem.
I am comparing my stuff based on the W3C-nodes and those nodes are still
named "base..." while the xml I want to compare them to never uses thos
basetypes.
Maybe I could change the comparemethod, but the instances I send the xml
to seem to have problem with the use of basetypes and thats definitly
out of my reach.

Is there any solution to this?

Ramin



Am Fr 03.03.2006 20:03 schrieb Lawrence Jones <[EMAIL PROTECTED]>:

> Hi Ramin
> 
> You can substitute even simple types - David Bau, one of the original
> designers of XmlBeans, thought of this (it's discussed in 3 articles
> called "The Design of XMLBeans" parts 1, 2 and 3 - there are links to
> these articles at http://xmlbeans.apache.org/resources/index.html).
> 
> To substitute this you need to get hold of what David calls the
> "formal"
> type - in this case an instance of XmlString instead of just String.
> 
> There are special methods on the generated beans that allow you to get
> (and set) through formal types. Instead of being getXXX()/setXXX they
> are xgetXXX() and xsetXXX(). So in your case you want code that looks
> something like this:
> 
>         XmlString initialBaseState = tt.xgetBaseState();
>         QName troubleStateQName =
>             new QName("your_target_namespace", "troubleState");
>         TroubleState troubleState =
> (TroubleState)initialBaseState.substitute(troubleStateQName,
> TroubleState.type);
>         troubleState.set(TroubleState.UNKNOWNTROUBLESTATE);
> 
> I tried that out on a simple schema based on your fragment and that
> all
> works for me - so let me know if you have problems.
> 
> Cheers,
> 
> Lawrence
> 
> > -----Original Message-----
> > From: Ramin Roham-Pour [mailto:[EMAIL PROTECTED]
> > Sent: Friday, March 03, 2006 6:48 AM
> > To: [email protected]
> > Subject: substituting simple types
> > 
> > Hello!
> > 
> > I my schema it reads:
> > 
> > <complexType name="TroubleTicketValue" abstract="false">
> >    <complexContent>
> >       <extension base="co:ManagedEntityValue">
> >          <sequence>
> >             <element ref="tt:baseState" nillable="true"
> minOccurs="0"/>
> >          </sequence>
> >       </extension>
> >    </complexContent>
> > </complexType>
> > 
> > <element name="baseState" type="string"/>
> > 
> > <element name="troubleState" type="tt:TroubleState"
> > substitutionGroup="tt:baseState"/>
> > 
> > <simpleType name="TroubleState">
> >     <restriction base="string">
> >     <enumeration value="UNKNOWNTROUBLESTATE"/>
> >     <enumeration value="QUEUED"/>
> >     <enumeration value="OPENACTIVE"/>
> >     <enumeration value="DEFERRED"/>
> >     <enumeration value="CLEARED"/>
> >     <enumeration value="CLOSED"/>
> >     <enumeration value="DISABLED"/>
> >     </restriction>
> > </simpleType>
> > 
> > If I want to add a troubleState to a troubleTicketValue, I can only
> add
> > baseState. Parsing a document containing troubleState works fine,
> > but
> > I'd like to build documents with troubleState without parsing it.
> > As troubleState is just a String I cannot use substitute(). Is there
> any
> > other way to solve this?
> > 
> > Regards
> > Ramin
> > 
> > 
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
>
> _______________________________________________________________________
> Notice: This email message, together with any attachments, may contain
> information of BEA Systems, Inc., its subsidiaries and affiliated
> entities, that may be confidential, proprietary, copyrighted and/or
> legally privileged, and is intended solely for the use of the
> individual
> or entity named in this message. If you are not the intended
> recipient,
> and have received this message in error, please immediately return
> this
> by email and then delete it.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to