|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface 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
.
I_CmsXmlContentValue
Field Summary | |
---|---|
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 | |
---|---|
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. |
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 |
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 |
---|
static final org.dom4j.Namespace XSI_NAMESPACE
static final org.dom4j.QName XSI_NAMESPACE_ATTRIBUTE_NO_SCHEMA_LOCATION
Method Detail |
---|
void appendXmlSchema(org.dom4j.Element root)
This is used to dynamically build a XML schema from an instance of a
CmsXmlContentDefinition
class.
root
- the element to append the XML toI_CmsXmlContentValue createValue(I_CmsXmlDocument document, org.dom4j.Element element, java.util.Locale locale)
document
- the XML content instance this value belongs toelement
- the XML element to create the value fromlocale
- the locale to create the value for
org.dom4j.Element generateXml(CmsObject cms, I_CmsXmlDocument document, org.dom4j.Element root, java.util.Locale locale)
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)
.
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
CmsXmlContentDefinition getContentDefinition()
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()
.
java.lang.String getDefault(java.util.Locale locale)
locale
- the locale to generate the default value for
I_CmsXmlContentHandler.getDefault(CmsObject, I_CmsXmlContentValue, Locale)
int getMaxOccurs()
int getMinOccurs()
java.lang.String getName()
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.
java.lang.String getSchemaDefinition()
java.lang.String getTypeName()
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.
boolean isSimpleType()
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
.
CmsXmlNestedContentDefinition
I_CmsXmlSchemaType newInstance(java.lang.String name, java.lang.String minOccurs, java.lang.String maxOccurs)
name
- the name to use in the xml documentminOccurs
- minimum number of occurrencesmaxOccurs
- maximum number of occurrences
void setContentDefinition(CmsXmlContentDefinition contentDefinition)
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.
contentDefinition
- the content definition to setvoid setDefault(java.lang.String defaultValue)
defaultValue
- the default value to setboolean validateValue(java.lang.String value)
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)
.
value
- the value to validate
I_CmsXmlContentHandler.resolveValidation(CmsObject, I_CmsXmlContentValue, org.opencms.xml.content.CmsXmlContentErrorHandler)
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |