Interface I_CmsXmlSchemaType

All Superinterfaces:
Comparable<I_CmsXmlSchemaType>
All Known Subinterfaces:
I_CmsXmlContentValue
All Known Implementing Classes:
A_CmsXmlContentValue, A_CmsXmlValueCdataBase, A_CmsXmlValueTextBase, CmsXmlAccessRestrictionValue, CmsXmlBooleanValue, CmsXmlCategoryValue, CmsXmlColorValue, CmsXmlDateTimeValue, CmsXmlDisplayFormatterValue, CmsXmlDynamicCategoryValue, CmsXmlHtmlValue, CmsXmlLocaleValue, CmsXmlNestedContentDefinition, CmsXmlPlainTextStringValue, CmsXmlSerialDateValue, CmsXmlStringValue, CmsXmlVarLinkValue, CmsXmlVfsFileValue, CmsXmlVfsImageValue

Describes a type in an OpenCms XML schema based content definition.

A XML content definition in OpenCms basically consists of a sequence of nodes in the following format:

<xsd:element name="title" type="cmsStringType" minOccurs="0" maxOccurs="unbounded" default="Some text" />.

Internally, each configured element in a XML schema is represented by an instance of this interface. This allows for constructing or changing the XML schema through the provided API.

Note that this class only describes the definition of a value in the XML schema. It is not the representation of an actual value from a XML file, for this you need an instance of a I_CmsXmlContentValue.

Since:
6.0.0
See Also:
  • Field Summary

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

    Modifier and Type
    Method
    Description
    void
    appendXmlSchema(org.dom4j.Element root)
    Appends an XML representation of this schema type to the given XML element.
    createValue(I_CmsXmlDocument document, org.dom4j.Element element, Locale locale)
    Creates a XML content value object for this type.
    org.dom4j.Element
    generateXml(CmsObject cms, I_CmsXmlDocument document, org.dom4j.Element root, Locale locale)
    Appends an XML for a new, empty node of this schema type to the given root element.
    int
    Returns the maximum occurrences of choice options for this type in the current schema.
    Returns the content definition this schema type belongs to.
    Returns the default value for a node of this type in the current schema.
    int
    Returns the maximum occurrences of this type in the current schema.
    int
    Returns the minimum occurrences of this type in the current schema.
    Returns the XML element node name of this type in the current schema.
    Returns a String representation of the XML definition for this schema type.
    Returns the schema type name.
    boolean
    Returns true if this type is an option inside of a choice sequence.
    boolean
    Returns true if this type defines a choice sequence.
    boolean
    Returns true if this is a simple type, or false if this type is a nested schema.
    newInstance(String name, String minOccurs, String maxOccurs)
    Creates a new instance of this XML schema type initialized with the given values.
    void
    Sets the content definition this schema type belongs to.
    void
    setDefault(String defaultValue)
    Sets the default value for a node of this type in the current schema.
    boolean
    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 Details

    • 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 Details

    • 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, 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, 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

      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

      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
    • getDefault

      Returns the default value for a node of this type in the current schema.

      Parameters:
      locale - the locale to generate the default value for
      Returns:
      the default value for a node of this type in the current schema
      See Also:
    • getMaxOccurs

      Returns the maximum occurrences of this type in the current schema.

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

      Returns the minimum occurrences of this type in the current schema.

      Returns:
      the minimum occurrences of this type in the current schema
    • 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

      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

      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
    • isSimpleType

      boolean isSimpleType()
      Returns true if this is a simple type, or false if this type is a nested schema.

      If a value is a nested schema, it must be an instance of CmsXmlNestedContentDefinition.

      Returns:
      true if this is a simple type, or false if this type is a nested schema
      See Also:
    • newInstance

      I_CmsXmlSchemaType newInstance(String name, String minOccurs, 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

      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(String defaultValue)
      Sets the default value for a node of this type in the current schema.

      Parameters:
      defaultValue - the default value to set
    • validateValue

      boolean validateValue(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.

      To have a more refined validation according to the special requirements of the content type, use custom validation rules in the appinfo which are processed with I_CmsXmlContentHandler.resolveValidation(CmsObject, I_CmsXmlContentValue, org.opencms.xml.content.CmsXmlContentErrorHandler).

      Parameters:
      value - the value to validate
      Returns:
      the validation rule (regular expression) used for this schema type in the XML schema
      See Also: