[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-user
Subject:    Re: RE: Abstract Types
From:       "Satish Kumar" <satish_subramaniam () rediffmail ! com>
Date:       2006-08-31 7:50:27
Message-ID: 20060831075027.11877.qmail () webmail83 ! rediffmail ! com
[Download RAW message or body]

Thanks Radu, it works now !!!!

On Wed, 30 Aug 2006 Radu Preotiuc-Pietro wrote :
>First, let me assume that your Schema declares "AbstractClass" as the
>substitutionGroup for "classA" and "classB" and not "AbstractElement"
>like stated in your message. Then, you would write the following code:
>
>     RootDocument doc = RootDocument.Factory.newInstance();
>     RootDocument.Root root = doc.addNewRoot();
>     XmlObject xmlObject = root.addNewAbstractClass();
>     xmlObject = xmlObject.substitute(
>         ClassADocument.type.getDocumentElementName(),
>         ClassAType.type);
>     // You can now add stuff to xmlObject
>
>Now the "doc" object will contain the document in the format you want.
>
>The idea is that you need to use the method .substitute() to create a
>document that uses substitution groups. XmlBeans doesn't look at the
>fact that the element is abstract or that it has substitutions but
>instead uses the simpler rule that "you need to call .substitute() if
>you want to enable substitutions".
>
>Radu
>
>
>Hi,
>
>Need some help in solving problems of abstract types. I have the
>following elements:
>
><xs:element name="Root">
><xs:complexType>
><xs:sequence>
><xs:element ref="AbstractClass"/>
></xs:sequence>
></xs:complexType>
></xs:element>
>
><element name="AbstractClass" abstract="true">
>
><element name="classA" type="ClassAType"
>substitutionGroup="AbstractElement">
>
><element name="classB" type="ClassBType"
>substitutionGroup="AbstractElement">
>
>I need an output XML of the form
>
><root>
><classA>...........</classA>
></root>
>
>but i get the following:
>
><root>
><AbstractClass>
><classA>...........</classA>
></AbstractClass>
></root>
>
>In the java code i have the following options
>
>a) root.addNewAbstractClass();
>b) root.setAbstractClass(XmlObject xmlObject);
>
>I want to get only the implementation of the "AbstractClass" as the
>sub-element of the "Root" element, how is it possible to achieve this.
>
>Thanks in advance,
>
>Cheers,
>Satish
>
>_______________________________________________________________________
>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: user-unsubscribe@xmlbeans.apache.org
>For additional commands, e-mail: user-help@xmlbeans.apache.org
>

[Attachment #3 (text/html)]

<P>
&nbsp; <BR>
 Thanks Radu, it works now !!!!<BR>
<BR>
On Wed, 30 Aug 2006 Radu Preotiuc-Pietro wrote :<BR>
&gt;First, let me assume that your Schema declares &quot;AbstractClass&quot; as \
the<BR> &gt;substitutionGroup for &quot;classA&quot; and &quot;classB&quot; and not \
&quot;AbstractElement&quot;<BR> &gt;like stated in your message. Then, you would \
write the following code:<BR> &gt;<BR>
&gt;&nbsp; &nbsp;  RootDocument doc = RootDocument.Factory.newInstance();<BR>
&gt;&nbsp; &nbsp;  RootDocument.Root root = doc.addNewRoot();<BR>
&gt;&nbsp; &nbsp;  XmlObject xmlObject = root.addNewAbstractClass();<BR>
&gt;&nbsp; &nbsp;  xmlObject = xmlObject.substitute(<BR>
&gt;&nbsp; &nbsp; &nbsp; &nbsp;  ClassADocument.type.getDocumentElementName(),<BR>
&gt;&nbsp; &nbsp; &nbsp; &nbsp;  ClassAType.type);<BR>
&gt;&nbsp; &nbsp;  // You can now add stuff to xmlObject<BR>
&gt;<BR>
&gt;Now the &quot;doc&quot; object will contain the document in the format you \
want.<BR> &gt;<BR>
&gt;The idea is that you need to use the method .substitute() to create a<BR>
&gt;document that uses substitution groups. XmlBeans doesn't look at the<BR>
&gt;fact that the element is abstract or that it has substitutions but<BR>
&gt;instead uses the simpler rule that &quot;you need to call .substitute() if<BR>
&gt;you want to enable substitutions&quot;.<BR>
&gt;<BR>
&gt;Radu<BR>
&gt;<BR>
&gt;<BR>
&gt;Hi,<BR>
&gt;<BR>
&gt;Need some help in solving problems of abstract types. I have the<BR>
&gt;following elements:<BR>
&gt;<BR>
&gt;&lt;xs:element name=&quot;Root&quot;&gt;<BR>
&gt;&lt;xs:complexType&gt;<BR>
&gt;&lt;xs:sequence&gt;<BR>
&gt;&lt;xs:element ref=&quot;AbstractClass&quot;/&gt;<BR>
&gt;&lt;/xs:sequence&gt;<BR>
&gt;&lt;/xs:complexType&gt;<BR>
&gt;&lt;/xs:element&gt;<BR>
&gt;<BR>
&gt;&lt;element name=&quot;AbstractClass&quot; abstract=&quot;true&quot;&gt;<BR>
&gt;<BR>
&gt;&lt;element name=&quot;classA&quot; type=&quot;ClassAType&quot;<BR>
&gt;substitutionGroup=&quot;AbstractElement&quot;&gt;<BR>
&gt;<BR>
&gt;&lt;element name=&quot;classB&quot; type=&quot;ClassBType&quot;<BR>
&gt;substitutionGroup=&quot;AbstractElement&quot;&gt;<BR>
&gt;<BR>
&gt;I need an output XML of the form<BR>
&gt;<BR>
&gt;&lt;root&gt;<BR>
&gt;&lt;classA&gt;...........&lt;/classA&gt;<BR>
&gt;&lt;/root&gt;<BR>
&gt;<BR>
&gt;but i get the following:<BR>
&gt;<BR>
&gt;&lt;root&gt;<BR>
&gt;&lt;AbstractClass&gt;<BR>
&gt;&lt;classA&gt;...........&lt;/classA&gt;<BR>
&gt;&lt;/AbstractClass&gt;<BR>
&gt;&lt;/root&gt;<BR>
&gt;<BR>
&gt;In the java code i have the following options<BR>
&gt;<BR>
&gt;a) root.addNewAbstractClass();<BR>
&gt;b) root.setAbstractClass(XmlObject xmlObject);<BR>
&gt;<BR>
&gt;I want to get only the implementation of the &quot;AbstractClass&quot; as the<BR>
&gt;sub-element of the &quot;Root&quot; element, how is it possible to achieve \
this.<BR> &gt;<BR>
&gt;Thanks in advance,<BR>
&gt;<BR>
&gt;Cheers,<BR>
&gt;Satish<BR>
&gt;<BR>
&gt;_______________________________________________________________________<BR>
&gt;Notice:&nbsp; This email message, together with any attachments, may contain<BR>
&gt;information&nbsp; of&nbsp; BEA Systems,&nbsp; Inc.,&nbsp; its subsidiaries&nbsp; \
and&nbsp; affiliated<BR> &gt;entities,&nbsp; that may be confidential,&nbsp; \
proprietary,&nbsp; copyrighted&nbsp; and/or<BR> &gt;legally privileged, and is \
intended solely for the use of the individual<BR> &gt;or entity named in this \
message. If you are not the intended recipient,<BR> &gt;and have received this \
message in error, please immediately return this<BR> &gt;by email and then delete \
it.<BR> &gt;<BR>
&gt;---------------------------------------------------------------------<BR>
&gt;To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org<BR>
&gt;For additional commands, e-mail: user-help@xmlbeans.apache.org<BR>
&gt;<BR>

</P>
<br><br>
<a href="http://adworks.rediff.com/cgi-bin/AdWorks/sigclick.cgi/www.rediff.com/signature-home.htm/1507191490@Middle5?PARTNER=3"><IMG \
SRC="http://adworks.rediff.com/cgi-bin/AdWorks/sigimpress.cgi/www.rediff.com/signature-home.htm/1963059423@Middle5?OAS_query=null&PARTNER=3" \
BORDER=0 VSPACE=0 HSPACE=0></a>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic