Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » XSDEnumeration question
XSDEnumeration question [message #598433] Tue, 25 July 2006 06:35
Eclipse User
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: Sat Apr 19 00:41:46 EDT 2014

Powered by FUDForum. Page generated in 0.01853 seconds