本文整理了Java中org.ccil.cowan.tagsoup.Parser
类的一些代码示例,展示了Parser
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser
类的具体详情如下:
包路径:org.ccil.cowan.tagsoup.Parser
类名称:Parser
[英]The SAX parser class.
[中]SAX解析器类。
代码示例来源:origin: rest-assured/rest-assured
slurper = new XmlSlurper(config.isValidating(), config.isNamespaceAware(), config.isAllowDocTypeDeclaration());
} else {
XMLReader p = new org.ccil.cowan.tagsoup.Parser();
slurper = new XmlSlurper(p);
代码示例来源:origin: seven332/EhViewer
/**
* Returns displayable styled text from the provided HTML string.
* Any <img> tags in the HTML will use the specified ImageGetter
* to request a representation of the image (use null if you don't
* want this) and the specified TagHandler to handle unknown tags
* (specify null if you don't want this).
*
* <p>This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.
*/
public static SpannableStringBuilder fromHtml(String source, ImageGetter imageGetter,
TagHandler tagHandler) {
Parser parser = new Parser();
try {
parser.setProperty(Parser.schemaProperty, HtmlParser.schema);
} catch (org.xml.sax.SAXNotRecognizedException e) {
// Should not happen.
throw new RuntimeException(e);
} catch (org.xml.sax.SAXNotSupportedException e) {
// Should not happen.
throw new RuntimeException(e);
}
HtmlToSpannedConverter converter =
new HtmlToSpannedConverter(source, imageGetter, tagHandler,
parser);
return converter.convert();
}
代码示例来源:origin: apache/tika
org.ccil.cowan.tagsoup.Parser parser = new org.ccil.cowan.tagsoup.Parser();
parser.setProperty(org.ccil.cowan.tagsoup.Parser.schemaProperty, schema);
parser.setContentHandler(handler);
parser.parse(new InputSource(new StringReader(codeAsHtml)));
代码示例来源:origin: fourlastor/dante
@Override public void parse(String string) {
org.ccil.cowan.tagsoup.Parser parser = new org.ccil.cowan.tagsoup.Parser();
parser.setContentHandler(this);
try {
parser.parse(new InputSource(new StringReader(string)));
} catch (IOException | SAXException e) {
throw new HtmlParsingException(e);
}
emptyBuffer();
}
代码示例来源:origin: com.github.livesense/org.liveSense.service.xssRemove
/**
* Creates a DeXSSParser with the following feature set:
* <ul>
* <li>{@link DeXSSFilterPipeline#BODY_ONLY} <code>true</code></li>
* </ul>
* And uses as parent a {@link org.ccil.cowan.tagsoup.Parser} with the following feature set:
* <ul>
* <li>{@link org.ccil.cowan.tagsoup.Parser#ignoreBogonsFeature} <code>true</code></li>
* <li>{@link org.ccil.cowan.tagsoup.Parser#defaultAttributesFeature} <code>false</code></li>
* </ul>
* TODO: Should be made more configurable.
*/
public DeXSSParser() throws SAXNotRecognizedException, SAXNotSupportedException {
super();
setFeature(DeXSSFilterPipeline.BODY_ONLY, true);
Parser parser = new Parser();
parser.setFeature(Parser.ignoreBogonsFeature, true);
parser.setFeature(Parser.defaultAttributesFeature, false);
setParent(parser);
}
}
代码示例来源:origin: com.xmlcalabash/xmlcalabash
private XdmNode tagSoup(String text) {
StringReader inputStream = new StringReader(text);
InputSource source = new InputSource(inputStream);
Parser parser = new Parser();
parser.setEntityResolver(runtime.getResolver());
SAXSource saxSource = new SAXSource(parser, source);
DocumentBuilder builder = runtime.getProcessor().newDocumentBuilder();
try {
XdmNode doc = builder.build(saxSource);
return doc;
} catch (Exception e) {
throw new XProcException(e);
}
}
代码示例来源:origin: org.ccil.cowan.tagsoup/tagsoup
public void parse (String systemid) throws IOException, SAXException {
parse(new InputSource(systemid));
}
代码示例来源:origin: org.ccil.cowan.tagsoup/tagsoup
public void setProperty(String name, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException
{
parser.setProperty(name, value);
}
代码示例来源:origin: org.ccil.cowan.tagsoup/tagsoup
public void setFeature(String name, boolean value)
throws SAXNotRecognizedException, SAXNotSupportedException
{
parser.setFeature(name, value);
}
代码示例来源:origin: apache/tika
new org.ccil.cowan.tagsoup.Parser();
parser.setProperty(
org.ccil.cowan.tagsoup.Parser.schemaProperty, schema);
parser.setFeature(
org.ccil.cowan.tagsoup.Parser.ignoreBogonsFeature, true);
parser.setContentHandler(new XHTMLDowngradeHandler(
new HtmlHandler(mapper, handler, metadata, context, extractScripts)));
parser.parse(reader.asInputSource());
代码示例来源:origin: gamesbyangelina/spritely
+ query);
Parser p = new Parser();
"http://www.colourlovers.com/ajax/search-palettes/_page_1?sortCol=votes&sortBy=desc&query="
+ query);
p.setContentHandler(handler);
p.parse(new InputSource(u.openStream()));
p.setContentHandler(pandler);
p.parse(new InputSource(new URL(s).openStream()));
代码示例来源:origin: com.github.livesense/org.liveSense.service.xssRemove
super();
Parser parser = new Parser();
parser.setFeature(Parser.defaultAttributesFeature, false);
parser.setFeature(Parser.useAttributes2Feature, true);
代码示例来源:origin: org.daisy.libs/com.xmlcalabash
private XdmNode tagSoup(String text) {
StringReader inputStream = new StringReader(text);
InputSource source = new InputSource(inputStream);
Parser parser = new Parser();
parser.setEntityResolver(runtime.getResolver());
SAXSource saxSource = new SAXSource(parser, source);
DocumentBuilder builder = runtime.getProcessor().newDocumentBuilder();
try {
XdmNode doc = builder.build(saxSource);
return doc;
} catch (Exception e) {
throw new XProcException(e);
}
}
代码示例来源:origin: rest-assured/rest-assured
slurper = new XmlSlurper(config.isValidating(), config.isNamespaceAware(), config.isAllowDocTypeDeclaration());
} else {
XMLReader p = new org.ccil.cowan.tagsoup.Parser();
slurper = new XmlSlurper(p);
代码示例来源:origin: net.sf.ofx4j/ofx4j
public void parseV1FromFirstElement(Reader reader) throws IOException, OFXParseException {
Parser parser = new Parser();
try {
parser.setFeature(Parser.restartElementsFeature, false);
}
catch (Exception e) {
throw new OFXParseException(e);
}
parser.setContentHandler(new TagSoupHandler(getContentHandler()));
try {
parser.parse(new InputSource(reader));
}
catch (SAXException e) {
if (e.getCause() instanceof OFXParseException) {
throw (OFXParseException) e.getCause();
}
throw new OFXParseException("Error parsing OFX document.", e);
}
}
代码示例来源:origin: gamesbyangelina/spritely
URL u = new URL("http://commons.wikimedia.org/wiki/" + query);
Parser p = new Parser();
p.setContentHandler(scraper);
HttpResponse response = client.execute(getRequest);
p.parse(new InputSource(response.getEntity().getContent()));
代码示例来源:origin: trezor/trezor-android
/**
* Returns displayable styled text from the provided HTML string.
* Any <img> tags in the HTML will use the specified ImageGetter
* to request a representation of the image (use null if you don't
* want this) and the specified TagHandler to handle unknown tags
* (specify null if you don't want this).
*
* <p>This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.
*/
public static Spanned fromHtml(String source, ImageGetter imageGetter,
TagHandler tagHandler) {
Parser parser = new Parser();
try {
parser.setProperty(Parser.schemaProperty, HtmlParser.schema);
} catch (org.xml.sax.SAXNotRecognizedException e) {
// Should not happen.
throw new RuntimeException(e);
} catch (org.xml.sax.SAXNotSupportedException e) {
// Should not happen.
throw new RuntimeException(e);
}
HtmlToSpannedConverter converter =
new HtmlToSpannedConverter(source, imageGetter, tagHandler,
parser);
return converter.convert();
}
代码示例来源:origin: org.ccil.cowan.tagsoup/tagsoup
protected SAXParserImpl() // used by factory, for prototypes
{
super();
parser = new org.ccil.cowan.tagsoup.Parser();
}
代码示例来源:origin: stoicflame/ofx4j
public void parseV1FromFirstElement(Reader reader) throws IOException, OFXParseException {
Parser parser = new Parser();
try {
parser.setFeature(Parser.restartElementsFeature, false);
}
catch (Exception e) {
throw new OFXParseException(e);
}
parser.setContentHandler(new TagSoupHandler(getContentHandler()));
try {
parser.parse(new InputSource(reader));
}
catch (SAXException e) {
if (e.getCause() instanceof OFXParseException) {
throw (OFXParseException) e.getCause();
}
throw new OFXParseException("Error parsing OFX document.", e);
}
}
代码示例来源:origin: zulip/zulip-android
final Context context = app.getApplicationContext();
final float density = context.getResources().getDisplayMetrics().density;
Parser parser = new Parser();
try {
parser.setProperty(Parser.schemaProperty, schema);
} catch (SAXNotRecognizedException | SAXNotSupportedException e) {
内容来源于网络,如有侵权,请联系作者删除!