Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » XSDEnumeration question
XSDEnumeration question [message #598433] Tue, 25 July 2006 10:35
Eclipse UserFriend
Originally posted by: ashish.deshpande.cc

Hello everyone,
I am having some trouble with enumeration facets. Here's my code snippet:

public void testEnumerationSchema () throws Exception {
XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
schema.setSchemaForSchemaQNamePrefix("xsd");
schema.getQNamePrefixToNamespaceMap().put(schema.getSchemaFo rSchemaQNamePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);

// Create element
XSDElementDeclaration xsdEl =
XSDFactory.eINSTANCE.createXSDElementDeclaration();
xsdEl.setName("foo");
// Create an enumeration simple type.
XSDSimpleTypeDefinition definition =
XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();

definition.setBaseTypeDefinition(schema.getSchemaForSchema() .resolveSimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_ URI_2001,
"string"));
XSDEnumerationFacet facet =
XSDFactory.eINSTANCE.createXSDEnumerationFacet();
facet.setLexicalValue("abc");
definition.getFacetContents().add(facet);
// Add simple type to element
xsdEl.setTypeDefinition(definition);
// Add element to the schema.
schema.getContents().add(xsdEl);

// Print using XSDResourceSet
printSchemaToOutputStream(schema, System.out);
}

This produces the following output:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="foo" type="null"/>
</xsd:schema>

As you can see, there is no enumeration. I have searched this newsgroup
but couldn't find an answer. What am I doing wrong?

Thanks for your help.
-Ashish
Previous Topic:About org.eclipse.xsd.provider
Next Topic:XSDEnumeration question
Goto Forum:
  


Current Time: Tue Apr 16 21:02:26 GMT 2024

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

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

Back to the top