Class CmsXmlPage
- All Implemented Interfaces:
I_CmsXmlDocument
This implementation consists of several named elements optionally available for various languages. The data of each element is accessible via its name and language. The content of each element is stored as CDATA, links within the content are processed and are separately accessible as entries of a CmsLinkTable.
- Since:
- 6.0.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Name of the name attribute of the elements node.static final String
Name of the language attribute of the elements node.static final String
Name of the name attribute of the elements node.static final String
Name of the element node.static final String
Name of the elements node.static final String
Name of the link node.static final String
Name of the links node.static final String
Name of the page node.static final String
Name of the page node.static final String
Property to check if relative links are allowed.static final String
The DTD address of the OpenCms xmlpage.Fields inherited from class org.opencms.xml.A_CmsXmlDocument
m_conversion, m_document, m_elementLocales, m_elementNames, m_encoding, m_file, m_locales
-
Constructor Summary
ConstructorDescriptionCmsXmlPage
(Locale locale, String encoding) Creates an empty XML page in the provided locale using the provided encoding.CmsXmlPage
(org.dom4j.Document document, String encoding) Creates a new CmsXmlPage based on the provided document and encoding. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given locale to this XML document.void
Adds a new, empty value with the given name and locale to this XML document.boolean
Returns if relative links are accepted (and left unprocessed).Returns the content definition object used for this XML document.Returns the content handler associated with the content definition of this XML document.getLinkProcessor
(CmsObject cms, CmsLinkTable linkTable) Returns a link processor for the values of this XML document.getLinkTable
(String name, Locale locale) Returns the link table of an element.Returns a List of all available elements paths (Strings) used in this document for the given locale.protected void
initDocument
(org.dom4j.Document document, String encoding, CmsXmlContentDefinition definition) Initializes an XML document based on the provided document, encoding and content definition.boolean
Checks if the element of a page object is enabled.void
removeValue
(String name, Locale locale) Removes an existing value with the given name and locale from this XML document.void
renameValue
(String oldValue, String newValue, Locale locale) Renames the page-element value from the old to the new one.protected void
setAllowRelativeLinks
(boolean value) Sets the parameter that controls the relative link generation.void
setEnabled
(String name, Locale locale, boolean isEnabled) Sets the enabled flag of an already existing element.protected void
Sets the file this XML page content is written to.void
setStringValue
(CmsObject cms, String name, Locale locale, String content) Sets the data of an already existing value.Validates the content of this XML document.Methods inherited from class org.opencms.xml.A_CmsXmlDocument
addBookmark, addLocale, clearBookmarks, copyLocale, copyLocale, correctXmlStructure, createDeepElementCopy, getBestMatchingLocale, getBookmark, getBookmark, getBookmarkName, getBookmarks, getConversion, getEncoding, getFile, getIndexCount, getLocales, getLocales, getStringValue, getStringValue, getSubValues, getTempDataCache, getValue, getValue, getValueInternal, getValues, getValues, hasLocale, hasValue, hasValue, initDocument, isAutoCorrectionEnabled, isEnabled, marshal, marshal, moveLocale, removeBookmark, removeLocale, setConversion, toString, updateLocaleNodeSorting, validateXmlStructure
-
Field Details
-
ATTRIBUTE_ENABLED
Name of the name attribute of the elements node.- See Also:
-
ATTRIBUTE_LANGUAGE
Name of the language attribute of the elements node.- See Also:
-
ATTRIBUTE_NAME
Name of the name attribute of the elements node.- See Also:
-
NODE_CONTENT
Name of the element node.- See Also:
-
NODE_ELEMENTS
Name of the elements node.- See Also:
-
NODE_LINK
Name of the link node.- See Also:
-
NODE_LINKS
Name of the links node.- See Also:
-
NODE_PAGE
Name of the page node.- See Also:
-
NODE_PAGES
Name of the page node.- See Also:
-
PROPERTY_ALLOW_RELATIVE
Property to check if relative links are allowed.- See Also:
-
XMLPAGE_XSD_SYSTEM_ID
The DTD address of the OpenCms xmlpage.- See Also:
-
-
Constructor Details
-
CmsXmlPage
Creates a new CmsXmlPage based on the provided document and encoding.The encoding is used for marshalling the XML document later.
- Parameters:
document
- the document to create the CmsXmlPage fromencoding
- the encoding of the xml page
-
CmsXmlPage
Creates an empty XML page in the provided locale using the provided encoding.The page is initialized according to the minimal necessary xml structure. The encoding is used for marshalling the XML document later.
- Parameters:
locale
- the initial locale of the XML pageencoding
- the encoding of the XML page
-
-
Method Details
-
addLocale
Description copied from interface:I_CmsXmlDocument
Adds the given locale to this XML document.- Parameters:
cms
- the current users OpenCms contextlocale
- the locale to add- Throws:
CmsXmlException
- in case the locale already existed, or if something else goes wrong- See Also:
-
addValue
Adds a new, empty value with the given name and locale to this XML document.- Parameters:
name
- the name of the valuelocale
- the locale of the value- Throws:
CmsIllegalArgumentException
- if the name contains an index ("[<number>]") or the value for the given locale already exists in the xmlpage.
-
getAllowRelativeLinks
Returns if relative links are accepted (and left unprocessed).- Returns:
- true if relative links are allowed
-
getContentDefinition
Description copied from interface:I_CmsXmlDocument
Returns the content definition object used for this XML document.- Returns:
- the content definition object used for this XML document
- Throws:
CmsRuntimeException
- See Also:
-
getHandler
Description copied from interface:I_CmsXmlDocument
Returns the content handler associated with the content definition of this XML document.This is a shortcut for
getContentDefinition().getContentHandler()
.- Returns:
- the content handler associated with the content definition of this XML document
- See Also:
-
getLinkProcessor
Description copied from interface:I_CmsXmlDocument
Returns a link processor for the values of this XML document.- Parameters:
cms
- the current OpenCms user context that provides access to the link processorlinkTable
- the table with the links to process- Returns:
- a link processor for the values of this XML document
- See Also:
-
getLinkTable
Returns the link table of an element.- Parameters:
name
- name of the elementlocale
- locale of the element- Returns:
- the link table
-
getNames
Description copied from interface:I_CmsXmlDocument
Returns a List of all available elements paths (Strings) used in this document for the given locale.If no element for the given locale is available, an empty list is returned.
- Specified by:
getNames
in interfaceI_CmsXmlDocument
- Overrides:
getNames
in classA_CmsXmlDocument
- Parameters:
locale
- the locale to look up the elements paths for- Returns:
- a List of all available elements paths (Strings) used in this document for the given locale
- See Also:
-
isEnabled
Checks if the element of a page object is enabled.- Specified by:
isEnabled
in interfaceI_CmsXmlDocument
- Overrides:
isEnabled
in classA_CmsXmlDocument
- Parameters:
name
- the name of the elementlocale
- the locale of the element- Returns:
- true if the element exists and is not disabled
- See Also:
-
removeValue
Removes an existing value with the given name and locale from this XML document.- Parameters:
name
- the name of the valuelocale
- the locale of the value
-
renameValue
public void renameValue(String oldValue, String newValue, Locale locale) throws CmsIllegalArgumentException Renames the page-element value from the old to the new one.- Parameters:
oldValue
- the old valuenewValue
- the new valuelocale
- the locale- Throws:
CmsIllegalArgumentException
- if the name contains an index ("[<number>]"), the new value for the given locale already exists in the xmlpage or the the old value does not exist for the locale in the xmlpage.
-
setEnabled
Sets the enabled flag of an already existing element.Note: if isEnabled is set to true, the attribute is removed since true is the default
- Parameters:
name
- name name of the elementlocale
- locale of the elementisEnabled
- enabled flag for the element
-
setStringValue
public void setStringValue(CmsObject cms, String name, Locale locale, String content) throws CmsXmlException Sets the data of an already existing value.The data will be enclosed as CDATA within the xml page structure. When setting the element data, the content of this element will be processed automatically.
- Parameters:
cms
- the cms objectname
- name of the elementlocale
- locale of the elementcontent
- character data (CDATA) of the element- Throws:
CmsXmlException
- if something goes wrong
-
validate
Description copied from interface:I_CmsXmlDocument
Validates the content of this XML document.To check for errors in a single document locale only, use
CmsXmlContentErrorHandler.hasErrors(Locale)
in the result object.- Parameters:
cms
- the current OpenCms user context- Returns:
- an error handler instance that provides information about the errors or warnings that have been found
- See Also:
-
initDocument
protected void initDocument(org.dom4j.Document document, String encoding, CmsXmlContentDefinition definition) Description copied from class:A_CmsXmlDocument
Initializes an XML document based on the provided document, encoding and content definition.- Specified by:
initDocument
in classA_CmsXmlDocument
- Parameters:
document
- the base XML document to use for initializingencoding
- the encoding to use when marshalling the document laterdefinition
- the content definition to use- See Also:
-
setAllowRelativeLinks
Sets the parameter that controls the relative link generation.- Parameters:
value
- the parameter that controls the relative link generation
-
setFile
Sets the file this XML page content is written to.- Parameters:
file
- the file this XML page content is written to
-