It works insofa as it inline the style. And this is ok in a browser. But i loos the comment and @media quiries.
Can anybody help me on how to keep those.
// DocumentSource docSource = new StreamDocumentSource(BasicConfigBean.class.getResourceAsStream("/TemplateTestCss.html"), null, null);
DocumentSource docSource = new StringDocumentSource(file);
//Parse the input document
DOMSource parser = new DefaultDOMSource(docSource);
Document doc = parser.parse();
//Create the CSS analyzer
DOMAnalyzer da = new DOMAnalyzer(doc, docSource.getURL());
// da.attributesToStyles(); //convert the HTML presentation attributes to inline styles
// da.addStyleSheet(null, CSSNorm.stdStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the standard style sheet
// da.addStyleSheet(null, CSSNorm.userStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the additional style sheet
da.getStyleSheets(); //load the author style sheets
da.localizeStyles();
//Compute the styles
System.err.println("Computing style...");
da.stylesToDomInherited();
// doc.
Output out = new NormalOutput(doc, false);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have the folllowin test.:
See code below.
It works insofa as it inline the style. And this is ok in a browser. But i loos the comment and @media quiries.
Can anybody help me on how to keep those.
// DocumentSource docSource = new StreamDocumentSource(BasicConfigBean.class.getResourceAsStream("/TemplateTestCss.html"), null, null);
DocumentSource docSource = new StringDocumentSource(file);
//Parse the input document
DOMSource parser = new DefaultDOMSource(docSource);
// da.attributesToStyles(); //convert the HTML presentation attributes to inline styles
// da.addStyleSheet(null, CSSNorm.stdStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the standard style sheet
// da.addStyleSheet(null, CSSNorm.userStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the additional style sheet
da.getStyleSheets(); //load the author style sheets
da.localizeStyles();
//Compute the styles
System.err.println("Computing style...");
da.stylesToDomInherited();
// doc.
Output out = new NormalOutput(doc, false);