int attrPropCount = readShort();
for (int i = 0; i < attrPropCount; i++)
{
SchemaProperty prop = readPropertyData();
if (!prop.isAttribute())
throw new SchemaTypeLoaderException("Attribute property " + i + " is not an attribute", _name, _handle, SchemaTypeLoaderException.WRONG_PROPERTY_TYPE);
attrProperties.put(prop.getName(), prop);
}
SchemaParticle contentModel = null;
Map elemProperties = null;
int isAll = 0;
if (complexVariety == SchemaType.ELEMENT_CONTENT || complexVariety == SchemaType.MIXED_CONTENT)
{
// Content Model Tree
isAll = readShort();
SchemaParticle[] parts = readParticleArray();
if (parts.length == 1)
contentModel = parts[0];
else if (parts.length == 0)
contentModel = null;
else
throw new SchemaTypeLoaderException("Content model not well-formed", _name, _handle, SchemaTypeLoaderException.MALFORMED_CONTENT_MODEL);
// Element Property Table
elemProperties = new LinkedHashMap();
int elemPropCount = readShort();
for (int i = 0; i < elemPropCount; i++)
{
SchemaProperty prop = readPropertyData();
if (prop.isAttribute())
throw new SchemaTypeLoaderException("Element property " + i + " is not an element", _name, _handle, SchemaTypeLoaderException.WRONG_PROPERTY_TYPE);
elemProperties.put(prop.getName(), prop);
}
}
impl.setContentModel(contentModel, attrModel, elemProperties, attrProperties, isAll == 1);
StscComplexTypeResolver.WildcardResult wcElt = StscComplexTypeResolver.summarizeEltWildcards(contentModel);
StscComplexTypeResolver.WildcardResult wcAttr = StscComplexTypeResolver.summarizeAttrWildcards(attrModel);
impl.setWildcardSummary(wcElt.typedWildcards, wcElt.hasWildcards, wcAttr.typedWildcards, wcAttr.hasWildcards);
}
if (!isComplexType || complexVariety == SchemaType.SIMPLE_CONTENT)
{
int simpleVariety = readShort();
impl.setSimpleTypeVariety(simpleVariety);
boolean isStringEnum = ((flags & FLAG_STRINGENUM) != 0);
impl.setOrdered((flags & FLAG_ORDERED) != 0 ? SchemaType.UNORDERED : ((flags & FLAG_TOTAL_ORDER) != 0 ? SchemaType.TOTAL_ORDER : SchemaType.PARTIAL_ORDER));
impl.setBounded((flags & FLAG_BOUNDED) != 0);
impl.setFinite((flags & FLAG_FINITE) != 0);
impl.setNumeric((flags & FLAG_NUMERIC) != 0);
impl.setUnionOfLists((flags & FLAG_UNION_OF_LISTS) != 0);
impl.setSimpleFinal((flags & FLAG_FINAL_REST) != 0,
(flags & FLAG_FINAL_LIST) != 0,
(flags & FLAG_FINAL_UNION) != 0);
XmlValueRef[] facets = new XmlValueRef[SchemaType.LAST_FACET + 1];
boolean[] fixedFacets = new boolean[SchemaType.LAST_FACET + 1];
int facetCount = readShort();
for (int i = 0; i < facetCount; i++)
{
int facetCode = readShort();
facets[facetCode] = readXmlValueObject();
fixedFacets[facetCode] = (readShort() == 1);
}
impl.setBasicFacets(facets, fixedFacets);
impl.setWhiteSpaceRule(readShort());
impl.setPatternFacet((flags & FLAG_HAS_PATTERN) != 0);
int patternCount = readShort();
org.apache.xmlbeans.impl.regex.RegularExpression[] patterns = new org.apache.xmlbeans.impl.regex.RegularExpression[patternCount];
for (int i = 0; i < patternCount; i++)
{
patterns[i] = new org.apache.xmlbeans.impl.regex.RegularExpression(readString(), "X");
}
impl.setPatterns(patterns);
int enumCount = readShort();
XmlValueRef[] enumValues = new XmlValueRef[enumCount];
for (int i = 0; i < enumCount; i++)
{
enumValues[i] = readXmlValueObject();
}
impl.setEnumerationValues(enumCount == 0 ? null : enumValues);
impl.setBaseEnumTypeRef(readTypeRef());
if (isStringEnum)
{
int seCount = readShort();
SchemaStringEnumEntry[] entries = new SchemaStringEnumEntry[seCount];
for (int i = 0; i < seCount; i++)
{
entries[i] = new SchemaStringEnumEntryImpl(readString(), readShort(), readString());
}
impl.setStringEnumEntries(entries);
}
switch (simpleVariety)
{
case SchemaType.ATOMIC:
impl.setPrimitiveTypeRef(readTypeRef());
impl.setDecimalSize(readInt());
break;
case SchemaType.LIST:
impl.setPrimitiveTypeRef(BuiltinSchemaTypeSystem.ST_ANY_SIMPLE.getRef());
impl.setListItemTypeRef(readTypeRef());
break;
case SchemaType.UNION:
impl.setPrimitiveTypeRef(BuiltinSchemaTypeSystem.ST_ANY_SIMPLE.getRef());
impl.setUnionMemberTypeRefs(readTypeRefArray());
break;
default:
throw new SchemaTypeLoaderException("Simple type does not have a recognized variety", _name, _handle, SchemaTypeLoaderException.WRONG_SIMPLE_VARIETY);
}
}
impl.setFilename(readString());
// Set the container for global, attribute or document types
if (impl.getName() != null)
{
SchemaContainer container = getContainer(impl.getName().getNamespaceURI());
checkContainerNotNull(container, impl.getName());
impl.setContainer(container);
}
else if (impl.isDocumentType())
{
QName name = impl.getDocumentElementName();
if (name != null)
{
SchemaContainer container = getContainer(name.getNamespaceURI());
checkContainerNotNull(container, name);
impl.setContainer(container);
}
}
else if (impl.isAttributeType())
{
QName name = impl.getAttributeTypeAttributeName();
if (name != null)
{
SchemaContainer container = getContainer(name.getNamespaceURI());
checkContainerNotNull(container, name);
impl.setContainer(container);
}
}
return impl;
}
catch (SchemaTypeLoaderException e)
{
throw e;
}
catch (Exception e)
{
throw new SchemaTypeLoaderException("Cannot load type from typesystem", _name, _handle, SchemaTypeLoaderException.NESTED_EXCEPTION, e);
}
finally
{
readEnd();
}