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_contentLanguageMetaValueprivate static StylesheetInfo_defaultStylesheetprivate static boolean_defaultStylesheetError(package private) static java.lang.String_namespaceDescription 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.StringcollapseWhiteSpace(java.lang.String text)protected java.lang.StringconvertToLength(java.lang.String value)private org.w3c.dom.ElementfindFirstChild(org.w3c.dom.Element parent, java.lang.String targetName)java.lang.StringgetAnchorName(org.w3c.dom.Element e)protected java.lang.StringgetAttribute(org.w3c.dom.Element e, java.lang.String attrName)java.lang.StringgetClass(org.w3c.dom.Element e)Gets the class attribute of the XhtmlNamespaceHandler objectprivate java.lang.StringgetContentLanguageMetaTag(org.w3c.dom.Document doc)Get the Content-Language meta tag value from the head section of the doc or the empty string.StylesheetInfogetDefaultStylesheet(StylesheetFactory factory)private java.io.InputStreamgetDefaultStylesheetStream()java.lang.StringgetDocumentTitle(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.StringgetElementStyling(org.w3c.dom.Element e)Gets the elementStyling attribute of the XhtmlNamespaceHandler objectjava.lang.StringgetID(org.w3c.dom.Element e)Gets the iD attribute of the XhtmlNamespaceHandler objectjava.lang.StringgetLang(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.StringgetLinkUri(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.StringgetNamespace()Gets the namespace attribute of the XhtmlNamespaceHandler objectStylesheetInfo[]getStylesheets(org.w3c.dom.Document doc)Gets the stylesheetLinks attribute of the XhtmlNamespaceHandler objectprotected booleanisInteger(java.lang.String value)protected StylesheetInforeadLinkElement(org.w3c.dom.Element link)protected StylesheetInforeadStyleElement(org.w3c.dom.Element style)private static java.lang.StringreadTextContent(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:
getNamespacein interfaceNamespaceHandler- Overrides:
getNamespacein 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:
getClassin interfaceNamespaceHandler- Overrides:
getClassin 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:
getIDin interfaceNamespaceHandler- Overrides:
getIDin 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:
getLinkUriin interfaceNamespaceHandler- Overrides:
getLinkUriin classNoNamespaceHandler- Parameters:
e- PARAM- Returns:
- The linkUri value
-
getAnchorName
public java.lang.String getAnchorName(org.w3c.dom.Element e)
- Specified by:
getAnchorNamein interfaceNamespaceHandler- Overrides:
getAnchorNamein classNoNamespaceHandler
-
getElementStyling
public java.lang.String getElementStyling(org.w3c.dom.Element e)
Gets the elementStyling attribute of the XhtmlNamespaceHandler object- Specified by:
getElementStylingin interfaceNamespaceHandler- Overrides:
getElementStylingin 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:
getDocumentTitlein interfaceNamespaceHandler- Overrides:
getDocumentTitlein 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:
getStylesheetsin interfaceNamespaceHandler- Overrides:
getStylesheetsin classNoNamespaceHandler- Parameters:
doc- PARAM- Returns:
- The stylesheetLinks value
-
getDefaultStylesheet
public StylesheetInfo getDefaultStylesheet(StylesheetFactory factory)
- Specified by:
getDefaultStylesheetin interfaceNamespaceHandler- Overrides:
getDefaultStylesheetin 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:
getLangin interfaceNamespaceHandler- Overrides:
getLangin classNoNamespaceHandler- Parameters:
e- PARAM- Returns:
- The lang value
-
-