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
FieldsModifier and TypeFieldDescriptionstatic final StringName of the name attribute of the elements node.static final StringName of the language attribute of the elements node.static final StringName of the name attribute of the elements node.static final StringName of the element node.static final StringName of the elements node.static final StringName of the link node.static final StringName of the links node.static final StringName of the page node.static final StringName of the page node.static final StringProperty to check if relative links are allowed.static final StringThe 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
ConstructorsConstructorDescriptionCmsXmlPage(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 TypeMethodDescriptionvoidAdds the given locale to this XML document.voidAdds a new, empty value with the given name and locale to this XML document.booleanReturns 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 voidinitDocument(org.dom4j.Document document, String encoding, CmsXmlContentDefinition definition) Initializes an XML document based on the provided document, encoding and content definition.booleanChecks if the element of a page object is enabled.voidremoveValue(String name, Locale locale) Removes an existing value with the given name and locale from this XML document.voidrenameValue(String oldValue, String newValue, Locale locale) Renames the page-element value from the old to the new one.protected voidsetAllowRelativeLinks(boolean value) Sets the parameter that controls the relative link generation.voidsetEnabled(String name, Locale locale, boolean isEnabled) Sets the enabled flag of an already existing element.protected voidSets the file this XML page content is written to.voidsetStringValue(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_CmsXmlDocumentAdds 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_CmsXmlDocumentReturns 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_CmsXmlDocumentReturns 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_CmsXmlDocumentReturns 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_CmsXmlDocumentReturns 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:
getNamesin interfaceI_CmsXmlDocument- Overrides:
getNamesin 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:
isEnabledin interfaceI_CmsXmlDocument- Overrides:
isEnabledin 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_CmsXmlDocumentValidates 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_CmsXmlDocumentInitializes an XML document based on the provided document, encoding and content definition.- Specified by:
initDocumentin 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
-