当前位置: 首页>>代码示例>>Java>>正文


Java DOMAnalyzer.stylesToDomInherited方法代码示例

本文整理汇总了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();
}
 
开发者ID:JayStGelais,项目名称:easy-mail,代码行数:9,代码来源:HtmlProcessor.java

示例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();
    }

}
 
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:47,代码来源:ComputeStyles.java

示例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();
    }

}
 
开发者ID:radkovo,项目名称:CSSBox,代码行数:47,代码来源:ComputeStyles.java


注:本文中的org.fit.cssbox.css.DOMAnalyzer.stylesToDomInherited方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。