|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||
See:
Description
| Interface Summary | |
|---|---|
| DOM4JCSSErrorHandler | CSS Error handler for DOM4J. |
| Class Summary | |
|---|---|
| CachedTableCellElement | Cached table cell element. |
| CachedTableElement | Cached table element. |
| CachedTableRowElement | Cached table row element. |
| CSSStylableElement | An element that is stylable with CSS. |
| DocumentFormatter | Builds the formatting structure for DOM4J documents. |
| DOM4JCSSStyleDeclaration | Style declaration for DOM4J. |
| DOM4JCSSStyleSheet | CSS Style Sheet for DOM4J. |
| DOM4JUserAgent<C> | User Agent based on DOM4J document trees. |
| DummyErrorHandler | CSS dummy error handler. |
| Log4jErrorHandler | Log4j error handler. |
| TableCellElement | Table cell element. |
| TableElement | Table element. |
| TableRowElement | Table row element. |
| XHTMLDocument | XHTML-specific implementation of a DOM4J Document. |
| XHTMLDocumentFactory | DocumentFactory for CSS-styled XHTML documents. |
| XHTMLElement | An XHTML element. |
Built on top of the DOM4J package, provides XHTML parsing with built-in support for CSS style sheets.
DOM4J is an XML DOM-like software package with better support for Java language constructs, like Collections. See http://dom4j.sourceforge.net/ for more information.
This implementation integrates DOM4J with the CSS DOM implementation found
in the info.informatica.doc.style.css package and subpackages.
This is the easiest way to use this package:
Reader re = ... [reader for XHTML document] InputSource source = new InputSource(re); SAXReader reader = new SAXReader(XHTMLDocumentFactory.getInstance()); reader.setEntityResolver(new DefaultEntityResolver()); Document document = reader.read(source);
And once you got the element you want style for (see, for example, the DOM4J Guide), just get it:
CSSStyleDeclaration style = ((CSSStylableElement)element).getComputedStyle();
String propertyValue = style.getPropertyValue("display");
The CSSStyleDeclaration interface may be hard to use, however,
so you may want to access the more specialized interface
CSS2ComputedProperties.
For complete access to this API, first configure the style declaration with a style database according to the target display device, for example:
((StyleDatabaseAware)style).setStyleDatabase(new Java2DStyleDatabase());or, alternatively, set the style database at the
XHTMLDocumentFactory
with the setStyleDatabase method (recommended).
Then, you just have to cast the style declaration with the
CSS2ComputedProperties interface and use it, for example:
Color color = Java2DStyleDatabase.getAWTColor(((CSS2ComputedProperties)style).getColor());Read the documentation of the individual classes for information on additional capabilities, like caching or the use of customized style sheets.
CSS4J uses a default user-agent style sheet as the basis for style
computations, although you can set a different one with the
setUserAgentStyleSheet method in XHTMLDocumentFactory.
User preferences can be specified with the setUserStyleSheet
method.
The DocumentFormatter class can be used to build a
formatting structure from the DOM4J document tree. You get the root
box, and then can recurse the contained boxes. For each box, you can
obtain the computed properties using the getComputedStyle
method. Note that this class is experimental and likely to have bugs.
|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||