*/
public static AttributeDecl convertAttribute(Attribute dtdAttribute,
Schema schema)
throws DTDException {
AttributeDecl schemaAttribute = new AttributeDecl(schema,
dtdAttribute.getName());
SimpleType type = null;
if (dtdAttribute.isStringType())
{
type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.STRING_TYPE) );
}
else if (dtdAttribute.isIDType())
{
type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.ID_TYPE) );
}
else if (dtdAttribute.isIDREFType())
{
type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.IDREF_TYPE) );
}
else if (dtdAttribute.isIDREFSType())
{
type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.IDREFS_TYPE) );
}
else if (dtdAttribute.isENTITYType())
{
type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.ENTITY_TYPE) );
}
else if (dtdAttribute.isENTITIESType())
{
type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.ENTITIES_TYPE) );
}
else if (dtdAttribute.isNMTOKENType())
{
type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.NMTOKEN_TYPE) );
}
else if (dtdAttribute.isNMTOKENSType())
{
type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.NMTOKENS_TYPE) );
}
else if (dtdAttribute.isNOTATIONType())
{
type = schema.createSimpleType(null,
schema.getBuiltInTypeName(SimpleTypesFactory.NOTATION_TYPE),
"restriction");
Iterator values = dtdAttribute.getValues();
FacetFactory facetFactory = FacetFactory.getInstance();
while (values.hasNext()) {
Facet facet = facetFactory.createFacet(
Facet.ENUMERATION, (String) values.next());
facet.setOwningType(type);
type.addFacet(facet);
}
}
else if (dtdAttribute.isEnumerationType())
{
type = schema.createSimpleType(null,
schema.getBuiltInTypeName(SimpleTypesFactory.NMTOKEN_TYPE),
"restriction");
Iterator values = dtdAttribute.getValues();
FacetFactory facetFactory = FacetFactory.getInstance();
while (values.hasNext()) {
Facet facet = facetFactory.createFacet(
Facet.ENUMERATION, (String)values.next());
facet.setOwningType(type);
type.addFacet(facet);
}
}
else
{
String err = "DTD to Schema converter: DTD attribute \"" + dtdAttribute.getName();
err += "\" has unspecified type.";
throw new DTDException(err);
}
schemaAttribute.setSimpleType(type);
if (dtdAttribute.isREQUIRED()) {
schemaAttribute.setUse(AttributeDecl.USE_REQUIRED);
} else if (dtdAttribute.isIMPLIED()) {
schemaAttribute.setUse(AttributeDecl.USE_OPTIONAL);
} else if (dtdAttribute.isFIXED()) {
} else { // DTD attribute is of "DEFAULT" type
schemaAttribute.setDefaultValue(dtdAttribute.getDefaultValue());
}
return schemaAttribute;
} //-- convertAttribute