本文整理汇总了Java中org.fit.cssbox.css.DOMAnalyzer.stylesToDomInherited方法的典型用法代码示例。如果您正苦于以下问题:Java DOMAnalyzer.stylesToDomInherited方法的具体用法?Java DOMAnalyzer.stylesToDomInherited怎么用?Java DOMAnalyzer.stylesToDomInherited使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fit.cssbox.css.DOMAnalyzer
的用法示例。
在下文中一共展示了DOMAnalyzer.stylesToDomInherited方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyEffectiveStylesToStyleAttributes
import org.fit.cssbox.css.DOMAnalyzer; //导入方法依赖的package包/类
private static void applyEffectiveStylesToStyleAttributes(final Document doc, final URL relativeUrl) {
DOMAnalyzer da = new DOMAnalyzer(doc, relativeUrl);
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.stylesToDomInherited();
}
示例2: main
import org.fit.cssbox.css.DOMAnalyzer; //导入方法依赖的package包/类
/**
* @param args
*/
public static void main(String[] args)
{
if (args.length != 2)
{
System.err.println("Usage: ComputeStyles <url> <output_file>");
System.exit(0);
}
try {
//Open the network connection
DocumentSource docSource = new DefaultDocumentSource(args[0]);
//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
//Compute the styles
System.err.println("Computing style...");
da.stylesToDomInherited();
//Save the output
PrintStream os = new PrintStream(new FileOutputStream(args[1]));
Output out = new NormalOutput(doc);
out.dumpTo(os);
os.close();
docSource.close();
System.err.println("Done.");
} catch (Exception e) {
System.err.println("Error: "+e.getMessage());
e.printStackTrace();
}
}
示例3: main
import org.fit.cssbox.css.DOMAnalyzer; //导入方法依赖的package包/类
/**
* @param args
*/
public static void main(String[] args)
{
if (args.length != 2)
{
System.err.println("Usage: ComputeStyles <url> <output_file>");
System.exit(0);
}
try {
//Open the network connection
DocumentSource docSource = new DefaultDocumentSource(args[0]);
//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
//Compute the styles
System.err.println("Computing style...");
da.stylesToDomInherited();
//Save the output
OutputStream os = new FileOutputStream(args[1]);
Output out = new NormalOutput(doc);
out.dumpTo(os);
os.close();
docSource.close();
System.err.println("Done.");
} catch (Exception e) {
System.err.println("Error: "+e.getMessage());
e.printStackTrace();
}
}