本文整理汇总了Java中org.cyberneko.html.HTMLConfiguration.setFeature方法的典型用法代码示例。如果您正苦于以下问题:Java HTMLConfiguration.setFeature方法的具体用法?Java HTMLConfiguration.setFeature怎么用?Java HTMLConfiguration.setFeature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cyberneko.html.HTMLConfiguration
的用法示例。
在下文中一共展示了HTMLConfiguration.setFeature方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseFragmentImpl
import org.cyberneko.html.HTMLConfiguration; //导入方法依赖的package包/类
@Override
protected DocumentFragment parseFragmentImpl(String source) throws GadgetException {
DocumentHandler handler;
HTMLConfiguration config = newConfiguration();
// http://cyberneko.org/html/features/balance-tags/document-fragment
// deprecated http://cyberneko.org/html/features/document-fragment
config.setFeature("http://cyberneko.org/html/features/balance-tags/document-fragment", true);
config.setProperty("http://cyberneko.org/html/properties/balance-tags/fragment-context-stack",
new QName[]{new QName(null, "HTML", "HTML", null), new QName(null, "BODY", "BODY", null)});
try {
handler = parseHtmlImpl(source, config, new NekoPatchTagBalancer());
} catch (IOException ioe) {
return null;
}
return handler.getFragment();
}
示例2: DOMFragmentParser
import org.cyberneko.html.HTMLConfiguration; //导入方法依赖的package包/类
/** Default constructor. */
public DOMFragmentParser() {
fParserConfiguration = new HTMLConfiguration();
fParserConfiguration.addRecognizedFeatures(RECOGNIZED_FEATURES);
fParserConfiguration.addRecognizedProperties(RECOGNIZED_PROPERTIES);
fParserConfiguration.setFeature(DOCUMENT_FRAGMENT, true);
fParserConfiguration.setDocumentHandler(this);
}
示例3: newConfiguration
import org.cyberneko.html.HTMLConfiguration; //导入方法依赖的package包/类
protected HTMLConfiguration newConfiguration() {
HTMLConfiguration config = new HTMLConfiguration();
// Maintain original case for elements and attributes
config.setProperty("http://cyberneko.org/html/properties/names/elems", "match");
config.setProperty("http://cyberneko.org/html/properties/names/attrs", "no-change");
// Get notified of entity and character references
config.setFeature("http://apache.org/xml/features/scanner/notify-char-refs", true);
config.setFeature("http://cyberneko.org/html/features/scanner/notify-builtin-refs", true);
config.setFeature("http://xml.org/sax/features/namespaces", true);
return config;
}