Interface I_CmsXmlSchemaType

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static org.dom4j.Namespace XSI_NAMESPACE
      The schema instance namespace.
      static org.dom4j.QName XSI_NAMESPACE_ATTRIBUTE_NO_SCHEMA_LOCATION
      Constant for the XML schema attribute "noNamespaceSchemaLocation" in the XML schema instance namespace.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void appendXmlSchema​(org.dom4j.Element root)
      Appends an XML representation of this schema type to the given XML element.
      I_CmsXmlContentValue createValue​(I_CmsXmlDocument document, org.dom4j.Element element, java.util.Locale locale)
      Creates a XML content value object for this type.
      org.dom4j.Element generateXml​(CmsObject cms, I_CmsXmlDocument document, org.dom4j.Element root, java.util.Locale locale)
      Appends an XML for a new, empty node of this schema type to the given root element.
      int getChoiceMaxOccurs()
      Returns the maximum occurrences of choice options for this type in the current schema.
      CmsXmlContentDefinition getContentDefinition()
      Returns the content definition this schema type belongs to.
      java.lang.String getDefault​(java.util.Locale locale)
      Returns the default value for a node of this type in the current schema.
      int getMaxOccurs()
      Returns the maximum occurrences of this type in the current schema.
      int getMinOccurs()
      Returns the minimum occurrences of this type in the current schema.
      java.lang.String getName()
      Returns the XML element node name of this type in the current schema.
      java.lang.String getSchemaDefinition()
      Returns a String representation of the XML definition for this schema type.
      java.lang.String getTypeName()
      Returns the schema type name.
      boolean isChoiceOption()
      Returns true if this type is an option inside of a choice sequence.
      boolean isChoiceType()
      Returns true if this type defines a choice sequence.
      boolean isSimpleType()
      Returns true if this is a simple type, or false if this type is a nested schema.
      I_CmsXmlSchemaType newInstance​(java.lang.String name, java.lang.String minOccurs, java.lang.String maxOccurs)
      Creates a new instance of this XML schema type initialized with the given values.
      void setContentDefinition​(CmsXmlContentDefinition contentDefinition)
      Sets the content definition this schema type belongs to.
      void setDefault​(java.lang.String defaultValue)
      Sets the default value for a node of this type in the current schema.
      boolean validateValue​(java.lang.String value)
      Checks if a given value is valid according to the validation rule (regular expression) used for validation of this schema type in the XML schema.
      • Methods inherited from interface java.lang.Comparable

        compareTo
    • Field Detail

      • XSI_NAMESPACE

        static final org.dom4j.Namespace XSI_NAMESPACE
        The schema instance namespace.
      • XSI_NAMESPACE_ATTRIBUTE_NO_SCHEMA_LOCATION

        static final org.dom4j.QName XSI_NAMESPACE_ATTRIBUTE_NO_SCHEMA_LOCATION
        Constant for the XML schema attribute "noNamespaceSchemaLocation" in the XML schema instance namespace.
    • Method Detail

      • appendXmlSchema

        void appendXmlSchema​(org.dom4j.Element root)
        Appends an XML representation of this schema type to the given XML element.

        This is used to dynamically build a XML schema from an instance of a CmsXmlContentDefinition class.

        Parameters:
        root - the element to append the XML to
      • createValue

        I_CmsXmlContentValue createValue​(I_CmsXmlDocument document,
                                         org.dom4j.Element element,
                                         java.util.Locale locale)
        Creates a XML content value object for this type.

        Parameters:
        document - the XML content instance this value belongs to
        element - the XML element to create the value from
        locale - the locale to create the value for
        Returns:
        the created XML content value object
      • generateXml

        org.dom4j.Element generateXml​(CmsObject cms,
                                      I_CmsXmlDocument document,
                                      org.dom4j.Element root,
                                      java.util.Locale locale)
        Appends an XML for a new, empty node of this schema type to the given root element.

        This is used to dynamically build a vaild XML content object from an initialized CmsXmlContentDefinition class.

        Important: This method can only be used during initialization of a XML content object, not to add values to an already initialized XML content. To add values after initialization, use CmsXmlContent.addValue(CmsObject, String, Locale, int).

        Parameters:
        cms - the current users OpenCms context
        document - the document the XML is generated for
        root - the element to append the XML to
        locale - the locale to generate the element default content for
        Returns:
        the generated XML element
      • getChoiceMaxOccurs

        int getChoiceMaxOccurs()
        Returns the maximum occurrences of choice options for this type in the current schema.

        This will be greater than 0 only if isChoiceType() is true.

        Returns:
        the maximum occurrences of choice options for this type in the current schema
      • getContentDefinition

        CmsXmlContentDefinition getContentDefinition()
        Returns the content definition this schema type belongs to.

        If the value belongs to a nested content, then the nested content definition is returned. This means that for documents with nested schemas, the content definition of a value is not necessarily equal to the content definition of the document itself, which can be obtained using I_CmsXmlContentValue.getDocument().

        Returns:
        the content definition this schema type belongs to
      • getMaxOccurs

        int getMaxOccurs()
        Returns the maximum occurrences of this type in the current schema.

        Returns:
        the maximum occurrences of this type in the current schema
      • getMinOccurs

        int getMinOccurs()
        Returns the minimum occurrences of this type in the current schema.

        Returns:
        the minimum occurrences of this type in the current schema
      • getName

        java.lang.String getName()
        Returns the XML element node name of this type in the current schema.

        The XML element node name can be configured in the schema. For example, the node name could be "Title", "Teaser" or "Text". The XML schema controls what node names are allowed.

        Returns:
        the XML node name of this type in the current schema
      • getSchemaDefinition

        java.lang.String getSchemaDefinition()
        Returns a String representation of the XML definition for this schema type.

        Returns:
        a String representation of the XML definition for this schema type
      • getTypeName

        java.lang.String getTypeName()
        Returns the schema type name.

        By convention, a XML schema type name has the form "OpenCms + ${name}". Examples are "OpenCmsString" or "OpenCmsBoolean".

        The schema type name is fixed by the implementation.

        Returns:
        the schema type name
      • isChoiceOption

        boolean isChoiceOption()
        Returns true if this type is an option inside of a choice sequence.

        This method is intended to check if this type is a node inside a choice sequence. In order to check if this type defines a choice sequence, use isChoiceType().

        Returns:
        true if this node defines a choice sequence
      • isChoiceType

        boolean isChoiceType()
        Returns true if this type defines a choice sequence.

        This method is intended to check if this type is a node defining a choice sequence. In order to check if this type is an option inside of a choice sequence, use isChoiceOption().

        Returns:
        true if this node defines a choice sequence
      • newInstance

        I_CmsXmlSchemaType newInstance​(java.lang.String name,
                                       java.lang.String minOccurs,
                                       java.lang.String maxOccurs)
        Creates a new instance of this XML schema type initialized with the given values.

        Parameters:
        name - the name to use in the xml document
        minOccurs - minimum number of occurrences
        maxOccurs - maximum number of occurrences
        Returns:
        a new instance of this XML content type initialized with the given values
      • setContentDefinition

        void setContentDefinition​(CmsXmlContentDefinition contentDefinition)
        Sets the content definition this schema type belongs to.

        This is done automatically when the scheme type is added to a content definition. Usually there is no need to call this method from the application.

        Parameters:
        contentDefinition - the content definition to set
      • setDefault

        void setDefault​(java.lang.String defaultValue)
        Sets the default value for a node of this type in the current schema.

        Parameters:
        defaultValue - the default value to set