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