public I_CmsXmlSchemaType getContentType(Element typeElement, Set<CmsXmlContentDefinition> nestedDefinitions)
    throws CmsXmlException {

        if (!CmsXmlContentDefinition.XSD_NODE_ELEMENT.equals(typeElement.getQName())) {
            throw new CmsXmlException(Messages.get().container(Messages.ERR_INVALID_CD_SCHEMA_STRUCTURE_0));
        }
        if (typeElement.elements().size() > 0) {
            throw new CmsXmlException(Messages.get().container(Messages.ERR_INVALID_CD_SCHEMA_STRUCTURE_0));
        }

        String elementName = typeElement.attributeValue(CmsXmlContentDefinition.XSD_ATTRIBUTE_NAME);
        String typeName = typeElement.attributeValue(CmsXmlContentDefinition.XSD_ATTRIBUTE_TYPE);
        String defaultValue = typeElement.attributeValue(CmsXmlContentDefinition.XSD_ATTRIBUTE_DEFAULT);
        String maxOccrs = typeElement.attributeValue(CmsXmlContentDefinition.XSD_ATTRIBUTE_MAX_OCCURS);
        String minOccrs = typeElement.attributeValue(CmsXmlContentDefinition.XSD_ATTRIBUTE_MIN_OCCURS);

        if (CmsStringUtil.isEmpty(elementName)) {
            throw new CmsXmlException(
                Messages.get().container(
                    Messages.ERR_EL_MISSING_ATTRIBUTE_2,
                    typeElement.getName(),
                    CmsXmlContentDefinition.XSD_ATTRIBUTE_NAME));
        }
        if (CmsStringUtil.isEmpty(typeName)) {
            throw new CmsXmlException(
                Messages.get().container(
                    Messages.ERR_EL_MISSING_ATTRIBUTE_2,
                    typeElement.getName(),
                    CmsXmlContentDefinition.XSD_ATTRIBUTE_TYPE));
        }

        boolean simpleType = true;
        I_CmsXmlSchemaType schemaType = m_registeredTypes.get(typeName);
        if (schemaType == null) {

            // the name is not a simple type, try to resolve from the nested schemas
            Iterator<CmsXmlContentDefinition> i = nestedDefinitions.iterator();
            while (i.hasNext()) {

                CmsXmlContentDefinition cd = i.next();
                if (typeName.equals(cd.getTypeName())) {

                    simpleType = false;
                    return new CmsXmlNestedContentDefinition(cd, elementName, minOccrs, maxOccrs);
                }
            }

            if (simpleType) {
                throw new CmsXmlException(Messages.get().container(Messages.ERR_UNKNOWN_SCHEMA_1, typeName));
            }
        }

        if (simpleType && (schemaType != null)) {
            schemaType = schemaType.newInstance(elementName, minOccrs, maxOccrs);

            if (CmsStringUtil.isNotEmpty(defaultValue)) {
                schemaType.setDefault(defaultValue);
            }
        }

        return schemaType;
    }
public I_CmsXmlSchemaType getContentType ( Element typeElement , Set < CmsXmlContentDefinition > nestedDefinitions ) throws CmsXmlException { if ( ! CmsXmlContentDefinition . XSD_NODE_ELEMENT . equals ( typeElement . getQName ( ) ) ) { throw new CmsXmlException ( Messages . get ( ) . container ( Messages . ERR_INVALID_CD_SCHEMA_STRUCTURE_0 ) ) ; } if ( typeElement . elements ( ) . size ( ) > 0 ) { throw new CmsXmlException ( Messages . get ( ) . container ( Messages . ERR_INVALID_CD_SCHEMA_STRUCTURE_0 ) ) ; } String elementName = typeElement . attributeValue ( CmsXmlContentDefinition . XSD_ATTRIBUTE_NAME ) ; String typeName = typeElement . attributeValue ( CmsXmlContentDefinition . XSD_ATTRIBUTE_TYPE ) ; String defaultValue = typeElement . attributeValue ( CmsXmlContentDefinition . XSD_ATTRIBUTE_DEFAULT ) ; String maxOccrs = typeElement . attributeValue ( CmsXmlContentDefinition . XSD_ATTRIBUTE_MAX_OCCURS ) ; String minOccrs = typeElement . attributeValue ( CmsXmlContentDefinition . XSD_ATTRIBUTE_MIN_OCCURS ) ; if ( CmsStringUtil . isEmpty ( elementName ) ) { throw new CmsXmlException ( Messages . get ( ) . container ( Messages . ERR_EL_MISSING_ATTRIBUTE_2 , typeElement . getName ( ) , CmsXmlContentDefinition . XSD_ATTRIBUTE_NAME ) ) ; } if ( CmsStringUtil . isEmpty ( typeName ) ) { throw new CmsXmlException ( Messages . get ( ) . container ( Messages . ERR_EL_MISSING_ATTRIBUTE_2 , typeElement . getName ( ) , CmsXmlContentDefinition . XSD_ATTRIBUTE_TYPE ) ) ; } boolean simpleType = true ; I_CmsXmlSchemaType schemaType = m_registeredTypes . get ( typeName ) ; if ( schemaType == null ) { Iterator < CmsXmlContentDefinition > i = nestedDefinitions . iterator ( ) ; while ( i . hasNext ( ) ) { CmsXmlContentDefinition cd = i . next ( ) ; if ( typeName . equals ( cd . getTypeName ( ) ) ) { simpleType = false ; return new CmsXmlNestedContentDefinition ( cd , elementName , minOccrs , maxOccrs ) ; } } if ( simpleType ) { throw new CmsXmlException ( Messages . get ( ) . container ( Messages . ERR_UNKNOWN_SCHEMA_1 , typeName ) ) ; } } if ( simpleType && ( schemaType != null ) ) { schemaType = schemaType . newInstance ( elementName , minOccrs , maxOccrs ) ; if ( CmsStringUtil . isNotEmpty ( defaultValue ) ) { schemaType . setDefault ( defaultValue ) ; } } return schemaType ; }
Generates an initialized instance of a XML content type definition
from the given XML schema element.<p>

@param typeElement the element to generate the XML content type definition from
@param nestedDefinitions the nested (included) XML content sub-definitions

@return an initialized instance of a XML content type definition
@throws CmsXmlException in case the element does not describe a valid XML content type definition