Package com.openhtmltopdf.simple.extend
Class XhtmlCssOnlyNamespaceHandler
- java.lang.Object
-
- com.openhtmltopdf.simple.NoNamespaceHandler
-
- com.openhtmltopdf.simple.extend.XhtmlCssOnlyNamespaceHandler
-
- All Implemented Interfaces:
NamespaceHandler
- Direct Known Subclasses:
XhtmlNamespaceHandler
public class XhtmlCssOnlyNamespaceHandler extends NoNamespaceHandler
Handles xhtml but only css styling is honored, no presentational html attributes (see css 2.1 spec, 6.4.4)
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
_contentLanguageMetaValue
private static StylesheetInfo
_defaultStylesheet
private static boolean
_defaultStylesheetError
(package private) static java.lang.String
_namespace
Description of the Field
-
Constructor Summary
Constructors Constructor Description XhtmlCssOnlyNamespaceHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
collapseWhiteSpace(java.lang.String text)
protected java.lang.String
convertToLength(java.lang.String value)
private org.w3c.dom.Element
findFirstChild(org.w3c.dom.Element parent, java.lang.String targetName)
java.lang.String
getAnchorName(org.w3c.dom.Element e)
protected java.lang.String
getAttribute(org.w3c.dom.Element e, java.lang.String attrName)
java.lang.String
getClass(org.w3c.dom.Element e)
Gets the class attribute of the XhtmlNamespaceHandler objectprivate java.lang.String
getContentLanguageMetaTag(org.w3c.dom.Document doc)
Get the Content-Language meta tag value from the head section of the doc or the empty string.StylesheetInfo
getDefaultStylesheet(StylesheetFactory factory)
private java.io.InputStream
getDefaultStylesheetStream()
java.lang.String
getDocumentTitle(org.w3c.dom.Document doc)
Returns the title of the document as located in the contents of /html/head/title, or "" if none could be found.java.lang.String
getElementStyling(org.w3c.dom.Element e)
Gets the elementStyling attribute of the XhtmlNamespaceHandler objectjava.lang.String
getID(org.w3c.dom.Element e)
Gets the iD attribute of the XhtmlNamespaceHandler objectjava.lang.String
getLang(org.w3c.dom.Element e)
Gets the language of an element as specified (in order of precedence) by the lang attribute on the element itself, the first ancestor with a lang attribute, the Content-Language meta tag or the empty string.java.lang.String
getLinkUri(org.w3c.dom.Element e)
Gets the linkUri attribute of the XhtmlNamespaceHandler objectprivate java.util.Map<java.lang.String,java.lang.String>
getMetaInfo(org.w3c.dom.Document doc)
java.lang.String
getNamespace()
Gets the namespace attribute of the XhtmlNamespaceHandler objectStylesheetInfo[]
getStylesheets(org.w3c.dom.Document doc)
Gets the stylesheetLinks attribute of the XhtmlNamespaceHandler objectprotected boolean
isInteger(java.lang.String value)
protected StylesheetInfo
readLinkElement(org.w3c.dom.Element link)
protected StylesheetInfo
readStyleElement(org.w3c.dom.Element style)
private static java.lang.String
readTextContent(org.w3c.dom.Element element)
-
Methods inherited from class com.openhtmltopdf.simple.NoNamespaceHandler
getAttributeValue, getAttributeValue, getImageSourceURI, getNonCssStyling, isFormElement, isImageElement
-
-
-
-
Field Detail
-
_namespace
static final java.lang.String _namespace
Description of the Field- See Also:
- Constant Field Values
-
_defaultStylesheet
private static StylesheetInfo _defaultStylesheet
-
_defaultStylesheetError
private static boolean _defaultStylesheetError
-
_contentLanguageMetaValue
private java.lang.String _contentLanguageMetaValue
-
-
Method Detail
-
getNamespace
public java.lang.String getNamespace()
Gets the namespace attribute of the XhtmlNamespaceHandler object- Specified by:
getNamespace
in interfaceNamespaceHandler
- Overrides:
getNamespace
in classNoNamespaceHandler
- Returns:
- The namespace value
-
getClass
public java.lang.String getClass(org.w3c.dom.Element e)
Gets the class attribute of the XhtmlNamespaceHandler object- Specified by:
getClass
in interfaceNamespaceHandler
- Overrides:
getClass
in classNoNamespaceHandler
- Parameters:
e
- PARAM- Returns:
- The class value
-
getID
public java.lang.String getID(org.w3c.dom.Element e)
Gets the iD attribute of the XhtmlNamespaceHandler object- Specified by:
getID
in interfaceNamespaceHandler
- Overrides:
getID
in classNoNamespaceHandler
- Parameters:
e
- PARAM- Returns:
- The iD value
-
convertToLength
protected java.lang.String convertToLength(java.lang.String value)
-
isInteger
protected boolean isInteger(java.lang.String value)
-
getAttribute
protected java.lang.String getAttribute(org.w3c.dom.Element e, java.lang.String attrName)
-
readTextContent
private static java.lang.String readTextContent(org.w3c.dom.Element element)
-
collapseWhiteSpace
private static java.lang.String collapseWhiteSpace(java.lang.String text)
-
getLinkUri
public java.lang.String getLinkUri(org.w3c.dom.Element e)
Gets the linkUri attribute of the XhtmlNamespaceHandler object- Specified by:
getLinkUri
in interfaceNamespaceHandler
- Overrides:
getLinkUri
in classNoNamespaceHandler
- Parameters:
e
- PARAM- Returns:
- The linkUri value
-
getAnchorName
public java.lang.String getAnchorName(org.w3c.dom.Element e)
- Specified by:
getAnchorName
in interfaceNamespaceHandler
- Overrides:
getAnchorName
in classNoNamespaceHandler
-
getElementStyling
public java.lang.String getElementStyling(org.w3c.dom.Element e)
Gets the elementStyling attribute of the XhtmlNamespaceHandler object- Specified by:
getElementStyling
in interfaceNamespaceHandler
- Overrides:
getElementStyling
in classNoNamespaceHandler
- Parameters:
e
- PARAM- Returns:
- The elementStyling value
-
getDocumentTitle
public java.lang.String getDocumentTitle(org.w3c.dom.Document doc)
Returns the title of the document as located in the contents of /html/head/title, or "" if none could be found.- Specified by:
getDocumentTitle
in interfaceNamespaceHandler
- Overrides:
getDocumentTitle
in classNoNamespaceHandler
- Parameters:
doc
- the document to search for a title- Returns:
- The document's title, or "" if none found
-
findFirstChild
private org.w3c.dom.Element findFirstChild(org.w3c.dom.Element parent, java.lang.String targetName)
-
readStyleElement
protected StylesheetInfo readStyleElement(org.w3c.dom.Element style)
-
readLinkElement
protected StylesheetInfo readLinkElement(org.w3c.dom.Element link)
-
getStylesheets
public StylesheetInfo[] getStylesheets(org.w3c.dom.Document doc)
Gets the stylesheetLinks attribute of the XhtmlNamespaceHandler object- Specified by:
getStylesheets
in interfaceNamespaceHandler
- Overrides:
getStylesheets
in classNoNamespaceHandler
- Parameters:
doc
- PARAM- Returns:
- The stylesheetLinks value
-
getDefaultStylesheet
public StylesheetInfo getDefaultStylesheet(StylesheetFactory factory)
- Specified by:
getDefaultStylesheet
in interfaceNamespaceHandler
- Overrides:
getDefaultStylesheet
in classNoNamespaceHandler
- Returns:
- the default CSS stylesheet for this namespace
-
getDefaultStylesheetStream
private java.io.InputStream getDefaultStylesheetStream()
-
getMetaInfo
private java.util.Map<java.lang.String,java.lang.String> getMetaInfo(org.w3c.dom.Document doc)
-
getContentLanguageMetaTag
private java.lang.String getContentLanguageMetaTag(org.w3c.dom.Document doc)
Get the Content-Language meta tag value from the head section of the doc or the empty string. Caches value so can be called multiple times without performance issues.
-
getLang
public java.lang.String getLang(org.w3c.dom.Element e)
Gets the language of an element as specified (in order of precedence) by the lang attribute on the element itself, the first ancestor with a lang attribute, the Content-Language meta tag or the empty string.- Specified by:
getLang
in interfaceNamespaceHandler
- Overrides:
getLang
in classNoNamespaceHandler
- Parameters:
e
- PARAM- Returns:
- The lang value
-
-