Interface I_CmsXmlSchemaType
-
- All Superinterfaces:
java.lang.Comparable<I_CmsXmlSchemaType>
- All Known Subinterfaces:
I_CmsXmlContentValue
- All Known Implementing Classes:
A_CmsXmlContentValue
,A_CmsXmlValueCdataBase
,A_CmsXmlValueTextBase
,CmsXmlBooleanValue
,CmsXmlCategoryValue
,CmsXmlColorValue
,CmsXmlDateTimeValue
,CmsXmlDisplayFormatterValue
,CmsXmlDynamicCategoryValue
,CmsXmlHtmlValue
,CmsXmlLocaleValue
,CmsXmlNestedContentDefinition
,CmsXmlPlainTextStringValue
,CmsXmlSerialDateValue
,CmsXmlStringValue
,CmsXmlVarLinkValue
,CmsXmlVfsFileValue
,CmsXmlVfsImageValue
public interface I_CmsXmlSchemaType extends java.lang.Comparable<I_CmsXmlSchemaType>
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:
I_CmsXmlContentValue
-
-
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()
Returnstrue
if this type is an option inside of a choice sequence.boolean
isChoiceType()
Returnstrue
if this type defines a choice sequence.boolean
isSimpleType()
Returnstrue
if this is a simple type, orfalse
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.
-
-
-
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 toelement
- the XML element to create the value fromlocale
- 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 contextdocument
- the document the XML is generated forroot
- the element to append the XML tolocale
- 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()
istrue
.- 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
-
getDefault
java.lang.String getDefault(java.util.Locale locale)
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:
I_CmsXmlContentHandler.getDefault(CmsObject, I_CmsXmlContentValue, Locale)
-
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()
Returnstrue
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()
Returnstrue
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()
Returnstrue
if this is a simple type, orfalse
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:
CmsXmlNestedContentDefinition
-
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 documentminOccurs
- minimum number of occurrencesmaxOccurs
- 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
-
validateValue
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.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:
I_CmsXmlContentHandler.resolveValidation(CmsObject, I_CmsXmlContentValue, org.opencms.xml.content.CmsXmlContentErrorHandler)
-
-