Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » ComplexTypeDefinition missing when encapsulated in an element
ComplexTypeDefinition missing when encapsulated in an element [message #15710] Mon, 31 March 2003 19:55 Go to next message
kaunteya bhattacharya is currently offline kaunteya bhattacharyaFriend
Messages: 24
Registered: July 2009
Junior Member
hello,
I am having problems in setting a complextypedefinition encapsulated in an
element in a model group. I am attaching my code below. I have set the
attribute as :
status_dec.setLexicalValue(status);

in my complextypedefinition. The code is attached below. When the schema
is generated the attribute is missing. I have put the schema at the bottom
of the page

any help would be great

XSDParticle particle = xsdFactory.createXSDParticle();
XSDComplexTypeDefinition complex_def
=xsdFactory.createXSDComplexTypeDefinition();
complex_def.setName(item_name);
Iterator iter = properties.iterator();
while(iter.hasNext())
{
String prop_name = (String)iter.next();
XSDAttributeDeclaration attr_decl =
xsdFactory.createXSDAttributeDeclaration();
attr_decl.setName(prop_name);

attr_decl.setTypeDefinition(sch.getSchemaForSchema().resolve SimpleTypeDefinition( "string"));
XSDAttributeUse AttributeUse = xsdFactory.createXSDAttributeUse();
AttributeUse.setContent(attr_decl);
complex_def.getAttributeContents().add(AttributeUse);
}
XSDAttributeDeclaration status_dec =
xsdFactory.createXSDAttributeDeclaration();
status_dec.setName("Optional");
String status = new String();
status="M";
***here**
status_dec.setLexicalValue(status);

XSDAttributeUse optionalAttributeUse =
xsdFactory.createXSDAttributeUse();
optionalAttributeUse.setContent(status_dec);
complex_def.getAttributeContents().add(optionalAttributeUse) ;

//encapsulate the complex type in an element.
XSDElementDeclaration elem_item =
xsdFactory.createXSDElementDeclaration();
elem_item.setTypeDefinition(complex_def);
//assign a dummy name on element
elem_item.setName(item_name+"_");

particle.setContent(elem_item);
particle.setMinOccurs(minOccur);
particle.setMaxOccurs(maxOccur);

List model_list = sch.getModelGroupDefinitions();
Iterator model_iter = model_list.iterator();
while(model_iter.hasNext())
{
XSDModelGroupDefinition group = (XSDModelGroupDefinition)
model_iter.next();
if(group_name.equals("GROUP1")){
XSDModelGroup model_group = group.getModelGroup();
model_group.getContents().add(particle);
group.setModelGroup(model_group);
}
}


sch.update();

as you can see the group is created but the attribute on the complextype
and the complex type is not shown

- <xsd:group name="GROUP1">
- <xsd:all>
<xsd:element maxOccurs="2" minOccurs="1" name="item1_" type="item1" />
</xsd:all>
</xsd:group>
Re: ComplexTypeDefinition missing when encapsulated in an element [message #16865 is a reply to message #15710] Mon, 31 March 2003 21:29 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Kaunteya,

As I stated in an earlier note, setAnonymousTypeDefinition is used in order for an element to
contain a complex type as opposed to setTypeDefinition which is used to refer to a type
contained elsewhere.


kaunteya bhattacharya wrote:

> hello,
> I am having problems in setting a complextypedefinition encapsulated in an
> element in a model group. I am attaching my code below. I have set the
> attribute as :
> status_dec.setLexicalValue(status);
>
> in my complextypedefinition. The code is attached below. When the schema
> is generated the attribute is missing. I have put the schema at the bottom
> of the page
>
> any help would be great
>
> XSDParticle particle = xsdFactory.createXSDParticle();
> XSDComplexTypeDefinition complex_def
> =xsdFactory.createXSDComplexTypeDefinition();
> complex_def.setName(item_name);
> Iterator iter = properties.iterator();
> while(iter.hasNext())
> {
> String prop_name = (String)iter.next();
> XSDAttributeDeclaration attr_decl =
> xsdFactory.createXSDAttributeDeclaration();
> attr_decl.setName(prop_name);
>
> attr_decl.setTypeDefinition(sch.getSchemaForSchema().resolve SimpleTypeDefinition( "string"));
> XSDAttributeUse AttributeUse = xsdFactory.createXSDAttributeUse();
> AttributeUse.setContent(attr_decl);
> complex_def.getAttributeContents().add(AttributeUse);
> }
> XSDAttributeDeclaration status_dec =
> xsdFactory.createXSDAttributeDeclaration();
> status_dec.setName("Optional");
> String status = new String();
> status="M";
> ***here**
> status_dec.setLexicalValue(status);
>
> XSDAttributeUse optionalAttributeUse =
> xsdFactory.createXSDAttributeUse();
> optionalAttributeUse.setContent(status_dec);
> complex_def.getAttributeContents().add(optionalAttributeUse) ;
>
> //encapsulate the complex type in an element.
> XSDElementDeclaration elem_item =
> xsdFactory.createXSDElementDeclaration();
> elem_item.setTypeDefinition(complex_def);
> //assign a dummy name on element
> elem_item.setName(item_name+"_");
>
> particle.setContent(elem_item);
> particle.setMinOccurs(minOccur);
> particle.setMaxOccurs(maxOccur);
>
> List model_list = sch.getModelGroupDefinitions();
> Iterator model_iter = model_list.iterator();
> while(model_iter.hasNext())
> {
> XSDModelGroupDefinition group = (XSDModelGroupDefinition)
> model_iter.next();
> if(group_name.equals("GROUP1")){
> XSDModelGroup model_group = group.getModelGroup();
> model_group.getContents().add(particle);
> group.setModelGroup(model_group);
> }
> }
>
> sch.update();
>
> as you can see the group is created but the attribute on the complextype
> and the complex type is not shown
>
> - <xsd:group name="GROUP1">
> - <xsd:all>
> <xsd:element maxOccurs="2" minOccurs="1" name="item1_" type="item1" />
> </xsd:all>
> </xsd:group>
Re: ComplexTypeDefinition missing when encapsulated in an element [message #567037 is a reply to message #15710] Mon, 31 March 2003 21:29 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Kaunteya,

As I stated in an earlier note, setAnonymousTypeDefinition is used in order for an element to
contain a complex type as opposed to setTypeDefinition which is used to refer to a type
contained elsewhere.


kaunteya bhattacharya wrote:

> hello,
> I am having problems in setting a complextypedefinition encapsulated in an
> element in a model group. I am attaching my code below. I have set the
> attribute as :
> status_dec.setLexicalValue(status);
>
> in my complextypedefinition. The code is attached below. When the schema
> is generated the attribute is missing. I have put the schema at the bottom
> of the page
>
> any help would be great
>
> XSDParticle particle = xsdFactory.createXSDParticle();
> XSDComplexTypeDefinition complex_def
> =xsdFactory.createXSDComplexTypeDefinition();
> complex_def.setName(item_name);
> Iterator iter = properties.iterator();
> while(iter.hasNext())
> {
> String prop_name = (String)iter.next();
> XSDAttributeDeclaration attr_decl =
> xsdFactory.createXSDAttributeDeclaration();
> attr_decl.setName(prop_name);
>
> attr_decl.setTypeDefinition(sch.getSchemaForSchema().resolve SimpleTypeDefinition( "string"));
> XSDAttributeUse AttributeUse = xsdFactory.createXSDAttributeUse();
> AttributeUse.setContent(attr_decl);
> complex_def.getAttributeContents().add(AttributeUse);
> }
> XSDAttributeDeclaration status_dec =
> xsdFactory.createXSDAttributeDeclaration();
> status_dec.setName("Optional");
> String status = new String();
> status="M";
> ***here**
> status_dec.setLexicalValue(status);
>
> XSDAttributeUse optionalAttributeUse =
> xsdFactory.createXSDAttributeUse();
> optionalAttributeUse.setContent(status_dec);
> complex_def.getAttributeContents().add(optionalAttributeUse) ;
>
> //encapsulate the complex type in an element.
> XSDElementDeclaration elem_item =
> xsdFactory.createXSDElementDeclaration();
> elem_item.setTypeDefinition(complex_def);
> //assign a dummy name on element
> elem_item.setName(item_name+"_");
>
> particle.setContent(elem_item);
> particle.setMinOccurs(minOccur);
> particle.setMaxOccurs(maxOccur);
>
> List model_list = sch.getModelGroupDefinitions();
> Iterator model_iter = model_list.iterator();
> while(model_iter.hasNext())
> {
> XSDModelGroupDefinition group = (XSDModelGroupDefinition)
> model_iter.next();
> if(group_name.equals("GROUP1")){
> XSDModelGroup model_group = group.getModelGroup();
> model_group.getContents().add(particle);
> group.setModelGroup(model_group);
> }
> }
>
> sch.update();
>
> as you can see the group is created but the attribute on the complextype
> and the complex type is not shown
>
> - <xsd:group name="GROUP1">
> - <xsd:all>
> <xsd:element maxOccurs="2" minOccurs="1" name="item1_" type="item1" />
> </xsd:all>
> </xsd:group>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Eclipse API to remove elements and groups from Schema
Next Topic:Creating a sample XML instance from a XSD Schema
Goto Forum:
  


Current Time: Sat Apr 27 00:00:17 GMT 2024

Powered by FUDForum. Page generated in 0.03786 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top