public class OutputStyledElementsFactory {
public OutputStyledElementList createOutputStyledElements(Document dom) {
final OutputStyledElementList outputElementList =
new OutputStyledElementList();
// iterate over the dom, extracting all the elements into a list
final OutputStylesFactory factory = new OutputStylesFactory();
WalkingDOMVisitor visitor = new WalkingDOMVisitorStub() {
public void visit(Element element) {
OutputStyles outputStyles = null;
Styles styles = element.getStyles();
if (styles != null) {
outputStyles = factory.create(element.getName(), styles);
}
OutputStyledElement outputElement =
new OutputStyledElement(element, outputStyles);
outputElementList.add(outputElement);
}
};
DOMWalker walker = new DOMWalker(visitor);
walker.walk(dom);
return outputElementList;