restrictionDomNode.setAttributeNS(null, "base",
baseType.getName());
}
// simple type definition to be used, to get the facets
XSSimpleTypeDefinition simpleTypeDefn = null;
if (typeDefn instanceof XSComplexTypeDefinition) {
XSComplexTypeDefinition complexTypeDefn = (XSComplexTypeDefinition) typeDefn;
simpleTypeDefn = complexTypeDefn.getSimpleType();
}
else {
simpleTypeDefn = (XSSimpleTypeDefinition) typeDefn;
}
// handling single-valued Facets
XSObjectList facets = simpleTypeDefn.getFacets();
for (int facetIdx = 0; facetIdx < facets.getLength(); facetIdx++) {
XSFacet facet = (XSFacet) facets.item(facetIdx);
String facetName = getFacetName(facet.getFacetKind());
String facetValue = facet.getLexicalFacetValue();
Element facetDomNode = document.createElementNS(
XSD_LANGUAGE_URI,
XSD_LANGUAGE_PREFIX +
facetName);
facetDomNode.setAttributeNS(null, "value", facetValue);
restrictionDomNode.appendChild(facetDomNode);
}
// handling multi-valued Facets ("enumeration" or "pattern")
XSObjectList mvFacets = simpleTypeDefn.getMultiValueFacets();
for (int mvFacetIdx = 0; mvFacetIdx < mvFacets.getLength();
mvFacetIdx++) {
XSMultiValueFacet mvFacet = (XSMultiValueFacet)
mvFacets.item(mvFacetIdx);
StringList facetValues = mvFacet.getLexicalFacetValues();