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 #566954] Mon, 31 March 2003 19:55
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>
Previous Topic:Eclipse API to remove elements and groups from Schema
Next Topic:Eclipse API to remove elements and groups from Schema
Goto Forum:
  


Current Time: Tue Apr 23 14:56:08 GMT 2024

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

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

Back to the top