- All Implemented Interfaces:
CSSDocument
,CSSNode
,Serializable
,Cloneable
,Branch
,Document
,Node
,Document
,Node
,DocumentStyle
- Direct Known Subclasses:
DOM4JUserAgent.AgentXHTMLDocumentFactory.AgentXHTMLDocument
Document
.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.sf.carte.doc.style.css.CSSDocument
CSSDocument.ComplianceMode
-
Field Summary
Fields inherited from class org.dom4j.tree.AbstractDocument
encoding
Fields inherited from class org.dom4j.tree.AbstractBranch
DEFAULT_CONTENT_LIST_SIZE
Fields inherited from class org.dom4j.tree.AbstractNode
NODE_TYPE_NAMES
Fields inherited from interface org.dom4j.Node
ANY_NODE, ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_REFERENCE_NODE, MAX_NODE_TYPE, NAMESPACE_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE, UNKNOWN_NODE
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
-
Constructor Summary
ModifierConstructorDescriptionprotected
protected
XHTMLDocument
(String name) protected
XHTMLDocument
(String name, DOMElement rootElement, DOMDocumentType docType) protected
XHTMLDocument
(DOMDocumentType docType) protected
XHTMLDocument
(DOMElement rootElement) protected
XHTMLDocument
(DOMElement rootElement, DOMDocumentType docType) -
Method Summary
Modifier and TypeMethodDescriptionboolean
addStyleSheet
(InputSource cssSrc) Adds a style sheet (contained by the given InputSource) to the global style sheet defined by the document's default style sheet and all the linked and embedded styles.createElement
(String name) Creates an element of the type specified.createElementNS
(String namespaceURI, String qualifiedName) protected ErrorHandler
protected String
void
Enables a style sheet set.Gets the absolute base URI of this node.Gets the base URL of this Document.Gets the document's canvas for the current target medium.Get the compatibility mode (compatMode
) attribute.Get the compliance mode of this document.Get the child node which is the document element of this document.protected XHTMLDocumentFactory
getElementById
(String elementId) Gets the document-level error handler.getFeature
(String feature, String version) Deprecated.Give the encoding used when the document was parsed, if known.Gets the style sheet set that was last selected.Get the referrer policy obtained through the 'Referrer-Policy' header or a meta element.Gets the title of the currently selected style sheet set.boolean
Deprecated.Gets the style database currently used to apply specific styles to this document.Gets the merged style sheet that applies to this document, resulting from the merge of the document's default style sheet, the document linked or embedded style sheets, and the non-important part of the user style sheet.A list containing all the style sheets explicitly linked into or embedded in a document.Gets the list of available alternate styles.This document's current target medium name.Gets an URL for the given URI, taking into account the Base URL if appropriate.Deprecated.boolean
Deprecated.Deprecated.boolean
Has any of the linked or embedded style sheets any error or warning ?boolean
isAuthorizedOrigin
(URL url) Determine whether the retrieval of the given URL is authorized.boolean
isSafeOrigin
(URL linkedURL) Is the provided URL a safe origin to load certain external resources?boolean
isVisitedURI
(String href) Has this URI been visited by the agent ?void
Deprecated.void
onMetaAdded
(String name, String attribute) void
onMetaRemoved
(String name, String attribute) openConnection
(URL url) Opens a connection for the given URL.openStream
(String uri) Opens an InputStream for the given URI, taking into account the Base URL if needed.void
Forces the cascade to be rebuilt the next time that a computed style is obtained.void
registerProperty
(CSSPropertyDefinition definition) Registers the definition of a custom property.void
setBaseURL
(URL baseURL) Sets the Base URL of this Document.void
setDocumentURI
(String documentURI) protected void
setReferrerPolicyHeader
(String policy) void
Selects a style sheet set, disabling the other non-persistent sheet sets.void
setStrictErrorChecking
(boolean strictErrorChecking) Deprecated.void
setTargetMedium
(String medium) Set the medium that will be used to compute the styles of this document.setUserData
(String key, Object data, UserDataHandler handler) Methods inherited from class org.dom4j.dom.DOMDocument
adoptNode, appendChild, cloneNode, compareDocumentPosition, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createEntityReference, createProcessingInstruction, createTextNode, getAttributes, getChildNodes, getDoctype, getDomConfig, getElementsByTagName, getElementsByTagNameNS, getFirstChild, getImplementation, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, importNode, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, removeChild, renameNode, replaceChild, setNodeValue, setPrefix, setTextContent, setXmlStandalone, setXmlVersion, supports
Methods inherited from class org.dom4j.tree.DefaultDocument
addDocType, addNode, addNode, clearContent, clone, contentList, getDocType, getEntityResolver, getName, getRootElement, getXMLEncoding, processingInstruction, processingInstructions, processingInstructions, removeNode, removeProcessingInstruction, rootElementAdded, setContent, setDocType, setDocumentFactory, setEntityResolver, setName
Methods inherited from class org.dom4j.tree.AbstractDocument
accept, add, addComment, addElement, addElement, addElement, addProcessingInstruction, addProcessingInstruction, asXML, asXPathResult, checkAddElementAllowed, childAdded, childRemoved, getDocument, getNodeType, getPath, getStringValue, getUniquePath, normalize, remove, setRootElement, setXMLEncoding, toString, write
Methods inherited from class org.dom4j.tree.AbstractBranch
add, add, add, addElement, appendContent, content, contentRemoved, createContentList, createContentList, createEmptyList, createResultList, createSingleResultList, elementByID, getContentAsStringValue, getContentAsText, getText, getTextTrim, hasContent, indexOf, invalidNodeTypeAddException, isReadOnly, node, nodeCount, nodeIterator, remove, remove, remove, setProcessingInstructions
Methods inherited from class org.dom4j.tree.AbstractNode
createPattern, createXPath, createXPathFilter, createXPathResult, detach, getNodeTypeName, getParent, getPath, getUniquePath, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setParent, setText, supportsParent, valueOf
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.dom4j.Branch
add, add, add, appendContent, content, elementByID, indexOf, node, nodeCount, nodeIterator, remove, remove, remove, setProcessingInstructions
Methods inherited from interface org.w3c.dom.Document
adoptNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createEntityReference, createProcessingInstruction, createTextNode, getDoctype, getDomConfig, getElementsByTagName, getElementsByTagNameNS, getImplementation, importNode, renameNode, setXmlStandalone, setXmlVersion
Methods inherited from interface org.dom4j.Node
createXPath, detach, getNodeTypeName, getParent, getPath, getText, getUniquePath, hasContent, isReadOnly, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setParent, setText, supportsParent, valueOf
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent
-
Field Details
-
XHTML_NAMESPACE_URI
- See Also:
-
-
Constructor Details
-
XHTMLDocument
protected XHTMLDocument() -
XHTMLDocument
-
XHTMLDocument
-
XHTMLDocument
-
XHTMLDocument
-
XHTMLDocument
-
-
Method Details
-
elementID
- Overrides:
elementID
in classAbstractBranch
-
getCompatMode
Get the compatibility mode (compatMode
) attribute.- Specified by:
getCompatMode
in interfaceCSSDocument
- Returns:
- the string "BackCompat" if document’s mode is
QUIRKS
, otherwise "CSS1Compat".
-
getComplianceMode
Description copied from interface:CSSDocument
Get the compliance mode of this document.The styling in this document operate under a compliance mode. Two modes are supported:
STRICT
andQUIRKS
.QUIRKS
andSTRICT
differ in the matching of class and ID selectors, and the default user agent sheet is slightly different.- Specified by:
getComplianceMode
in interfaceCSSDocument
- Returns:
- the compliance mode.
-
getOwnerDocument
Description copied from interface:CSSNode
- Specified by:
getOwnerDocument
in interfaceCSSNode
- Specified by:
getOwnerDocument
in interfaceNode
- Overrides:
getOwnerDocument
in classDOMDocument
-
getDocumentElement
Description copied from interface:CSSDocument
Get the child node which is the document element of this document.- Specified by:
getDocumentElement
in interfaceCSSDocument
- Specified by:
getDocumentElement
in interfaceDocument
- Overrides:
getDocumentElement
in classDOMDocument
- Returns:
- the document element.
-
getElementById
Description copied from interface:CSSDocument
- Specified by:
getElementById
in interfaceCSSDocument
- Specified by:
getElementById
in interfaceDocument
- Overrides:
getElementById
in classDOMDocument
-
createElement
Description copied from interface:CSSDocument
Creates an element of the type specified.The presence of
IMPLIED
attributes is implementation-dependent.- Specified by:
createElement
in interfaceCSSDocument
- Specified by:
createElement
in interfaceDocument
- Overrides:
createElement
in classDOMDocument
- Parameters:
name
- the tag name of the element to create.- Returns:
- the new
CSSElement
. - Throws:
DOMException
- INVALID_CHARACTER_ERR if the name is not an XML valid name.
-
createElementNS
Description copied from interface:CSSDocument
- Specified by:
createElementNS
in interfaceCSSDocument
- Specified by:
createElementNS
in interfaceDocument
- Overrides:
createElementNS
in classDOMDocument
- Throws:
DOMException
-
setUserData
- Specified by:
setUserData
in interfaceNode
- Overrides:
setUserData
in classDOMDocument
-
getInputEncoding
Give the encoding used when the document was parsed, if known.- Specified by:
getInputEncoding
in interfaceDocument
- Overrides:
getInputEncoding
in classDOMDocument
- Returns:
null
.
-
getFeature
Deprecated.- Specified by:
getFeature
in interfaceNode
- Overrides:
getFeature
in classDOMDocument
-
getStrictErrorChecking
Deprecated.- Specified by:
getStrictErrorChecking
in interfaceDocument
- Overrides:
getStrictErrorChecking
in classDOMDocument
-
setStrictErrorChecking
Deprecated.- Specified by:
setStrictErrorChecking
in interfaceDocument
- Overrides:
setStrictErrorChecking
in classDOMDocument
-
normalizeDocument
Deprecated.- Specified by:
normalizeDocument
in interfaceDocument
- Overrides:
normalizeDocument
in classDOMDocument
-
getXmlEncoding
Deprecated.Now deprecated, this method gave the encoding specified at the XML declaration.- Specified by:
getXmlEncoding
in interfaceDocument
- Overrides:
getXmlEncoding
in classDOMDocument
- Returns:
null
.
-
getXmlStandalone
Deprecated.Get whether this document is standalone as specified at the XML declaration.- Specified by:
getXmlStandalone
in interfaceDocument
- Overrides:
getXmlStandalone
in classDOMDocument
- Returns:
null
.
-
getXmlVersion
Deprecated.Get the version for the "XML" feature.- Specified by:
getXmlVersion
in interfaceDocument
- Overrides:
getXmlVersion
in classDOMDocument
- Returns:
null
.
-
registerProperty
Description copied from interface:CSSDocument
Registers the definition of a custom property.- Specified by:
registerProperty
in interfaceCSSDocument
- Parameters:
definition
- the definition.- See Also:
-
getStyleSheets
A list containing all the style sheets explicitly linked into or embedded in a document. For HTML documents, this includes external style sheets, included via the HTML LINK element, and inline STYLE elements. In XML, this includes external style sheets, included via style sheet processing instructions (see [XML StyleSheet]).- Specified by:
getStyleSheets
in interfaceCSSDocument
- Specified by:
getStyleSheets
in interfaceDocumentStyle
-
getStyleSheet
Gets the merged style sheet that applies to this document, resulting from the merge of the document's default style sheet, the document linked or embedded style sheets, and the non-important part of the user style sheet. Does not include overriden styles nor the 'important' part of the user-defined style sheet.The style sheet is lazily built.
- Specified by:
getStyleSheet
in interfaceCSSDocument
- Returns:
- the merged style sheet that applies to this document.
-
addStyleSheet
Adds a style sheet (contained by the given InputSource) to the global style sheet defined by the document's default style sheet and all the linked and embedded styles.- Parameters:
cssSrc
- the document's InputSource.- Returns:
true
if the parsing reported no errors or fatal errors, false otherwise.- Throws:
DOMException
- if a DOM problem is found parsing the sheet.IOException
- if a problem is found reading the sheet.
-
getStyleSheetSets
Gets the list of available alternate styles.- Specified by:
getStyleSheetSets
in interfaceCSSDocument
- Returns:
- the list of available alternate style titles.
-
getSelectedStyleSheetSet
Gets the title of the currently selected style sheet set.- Specified by:
getSelectedStyleSheetSet
in interfaceCSSDocument
- Returns:
- the title of the currently selected style sheet, the empty string if
none is selected, or
null
if there are style sheets from different style sheet sets that have their style sheet disabled flag unset.
-
setSelectedStyleSheetSet
Selects a style sheet set, disabling the other non-persistent sheet sets. If the name is the empty string, all non-persistent sheets will be disabled. Otherwise, if the name does not match any of the sets, does nothing.- Specified by:
setSelectedStyleSheetSet
in interfaceCSSDocument
- Parameters:
name
- the case-sensitive name of the set to select.
-
getLastStyleSheetSet
Gets the style sheet set that was last selected.- Specified by:
getLastStyleSheetSet
in interfaceCSSDocument
- Returns:
- the last selected style sheet set, or
null
if none.
-
enableStyleSheetsForSet
Enables a style sheet set. If the name does not match any of the sets, does nothing.- Specified by:
enableStyleSheetsForSet
in interfaceCSSDocument
- Parameters:
name
- the case-sensitive name of the set to enable.
-
getStyleDatabase
Gets the style database currently used to apply specific styles to this document.- Specified by:
getStyleDatabase
in interfaceCSSDocument
- Returns:
- the style database, or null if no style database has been selected.
-
getTargetMedium
This document's current target medium name.- Specified by:
getTargetMedium
in interfaceCSSDocument
- Returns:
- the target medium name of this document.
-
setTargetMedium
Set the medium that will be used to compute the styles of this document.- Specified by:
setTargetMedium
in interfaceCSSDocument
- Parameters:
medium
- the name of the target medium, like 'screen' or 'print'.- Throws:
CSSMediaException
- if the document is unable to target the given medium.
-
getCanvas
Gets the document's canvas for the current target medium.- Specified by:
getCanvas
in interfaceCSSDocument
- Returns:
- the canvas, or null if no target medium has been set, or the DeviceFactory does not support canvas for the target medium.
-
rebuildCascade
public void rebuildCascade()Description copied from interface:CSSDocument
Forces the cascade to be rebuilt the next time that a computed style is obtained.This method should be called after you modify the styles in a way that is not detected by the library (like modifying a value).
- Specified by:
rebuildCascade
in interfaceCSSDocument
-
getDocumentFactory
- Overrides:
getDocumentFactory
in classDOMDocument
-
createErrorHandler
-
getErrorHandler
Description copied from interface:CSSDocument
Gets the document-level error handler.- Specified by:
getErrorHandler
in interfaceCSSDocument
- Returns:
- the error handler.
-
hasStyleIssues
public boolean hasStyleIssues()Has any of the linked or embedded style sheets any error or warning ?- Specified by:
hasStyleIssues
in interfaceCSSDocument
- Returns:
true
if any of the linked or embedded style sheets has any NSAC or rule error or warning,false
otherwise.
-
onMetaAdded
-
onMetaRemoved
-
getBaseURL
Gets the base URL of this Document.If the Document's
head
element has abase
child element, the base URI is computed using the value of the href attribute of thebase
element. It can also be set with thesetBaseURL
method.- Specified by:
getBaseURL
in interfaceCSSDocument
- Returns:
- the base URL, or null if no base URL could be found.
-
getBaseURI
Gets the absolute base URI of this node.- Specified by:
getBaseURI
in interfaceNode
- Overrides:
getBaseURI
in classDOMDocument
- Returns:
- the absolute base URI of this node, or null if an absolute URI could not be obtained.
-
setBaseURL
Sets the Base URL of this Document.- Parameters:
baseURL
- the base URL.
-
getURL
Gets an URL for the given URI, taking into account the Base URL if appropriate.- Specified by:
getURL
in interfaceCSSDocument
- Parameters:
uri
- the uri.- Returns:
- the absolute URL.
- Throws:
MalformedURLException
- if the uri was wrong.
-
isSafeOrigin
Is the provided URL a safe origin to load certain external resources?- Specified by:
isSafeOrigin
in interfaceCSSDocument
- Parameters:
linkedURL
- the URL of the external resource.- Returns:
true
if is a safe origin,false
otherwise.
-
isAuthorizedOrigin
Determine whether the retrieval of the given URL is authorized.If the URL's protocol is not
http
norhttps
and document's base URL's scheme is neitherfile
norjar
, it is denied.- Specified by:
isAuthorizedOrigin
in interfaceCSSDocument
- Parameters:
url
- the URL to check.- Returns:
true
if allowed.
-
getReferrerPolicy
Get the referrer policy obtained through the 'Referrer-Policy' header or a meta element.- Specified by:
getReferrerPolicy
in interfaceCSSDocument
- Returns:
- the referrer policy, or the empty string if none was specified.
-
setReferrerPolicyHeader
-
setDocumentURI
- Specified by:
setDocumentURI
in interfaceDocument
- Overrides:
setDocumentURI
in classDOMDocument
-
getDocumentURI
- Specified by:
getDocumentURI
in interfaceDocument
- Overrides:
getDocumentURI
in classDOMDocument
-
openConnection
Opens a connection for the given URL.- Specified by:
openConnection
in interfaceCSSDocument
- Parameters:
url
- the URL to open a connection to.- Returns:
- the URL connection.
- Throws:
IOException
- if the connection could not be opened.
-
openStream
Opens an InputStream for the given URI, taking into account the Base URL if needed.- Parameters:
uri
- the uri to open a connection.- Returns:
- the InputStream.
- Throws:
IOException
- if the uri was wrong, or the stream could not be opened.
-
isVisitedURI
Description copied from interface:CSSDocument
Has this URI been visited by the agent ?- Specified by:
isVisitedURI
in interfaceCSSDocument
- Parameters:
href
- the URI.- Returns:
true
if visited,false
if not visited or the agent does not support history.
-