本文整理汇总了Java中org.apache.html.dom.HTMLDocumentImpl类的典型用法代码示例。如果您正苦于以下问题:Java HTMLDocumentImpl类的具体用法?Java HTMLDocumentImpl怎么用?Java HTMLDocumentImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HTMLDocumentImpl类属于org.apache.html.dom包,在下文中一共展示了HTMLDocumentImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseDocument
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
private HTMLDocumentImpl parseDocument(String htmlData) throws DiscoveryException
{
OpenID4JavaDOMParser parser = new OpenID4JavaDOMParser();
try
{
parser.parse(OpenID4JavaDOMParser.createInputSource(htmlData));
}
catch (Exception e)
{
throw new DiscoveryException("Error parsing HTML message",
OpenIDException.DISCOVERY_HTML_PARSE_ERROR, e);
}
if (parser.isIgnoredHeadStartElement())
{
throw new DiscoveryException(
"HTML response must have exactly one HEAD element.",
OpenIDException.DISCOVERY_HTML_PARSE_ERROR);
}
return (HTMLDocumentImpl) parser.getDocument();
}
示例2: parseDocument
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
private HTMLDocumentImpl parseDocument(String htmlData) throws YadisException
{
OpenID4JavaDOMParser parser = new OpenID4JavaDOMParser();
try
{
parser.parse(OpenID4JavaDOMParser.createInputSource(htmlData));
}
catch (Exception e)
{
throw new YadisException("Error parsing HTML message",
OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE, e);
}
if (parser.isIgnoredHeadStartElement())
{
throw new YadisException("HTML response must have exactly one HEAD element.",
OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE);
}
return (HTMLDocumentImpl) parser.getDocument();
}
示例3: parseHTML
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
/**
* 从指定流解析HTML
*
* @param in
* 输入流
* @param charSet
* 字符集,为null时自动检测
* @return 解析后的DocumentFragment对象
* @throws SAXException
* XML语法异常时抛出
* @throws IOException
* IO操作错误时抛出
*/
public static DocumentFragment parseHTML(InputStream in, String charSet) throws SAXException, IOException {
if (parser == null)
throw new UnsupportedOperationException(
"HTML parser module not loaded, to activate this feature, you must add JEF common-ioc.jar to classpath");
InputSource source;
if (charSet != null) {
source = new InputSource(new XmlFixedReader(new InputStreamReader(in, charSet)));
source.setEncoding(charSet);
} else {
source = new InputSource(in);
}
synchronized (parser) {
HTMLDocument document = new HTMLDocumentImpl();
DocumentFragment fragment = document.createDocumentFragment();
parser.parse(source, fragment);
return fragment;
}
}
示例4: Html5ScriptElementImpl
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
/**
* Constructs new script element.
*
* @param owner Document which owns this element.
* @param name Name of the element.
*/
public Html5ScriptElementImpl(HTMLDocumentImpl document, String name) {
super(document, name);
_fetchRegistry = FetchRegistry.getInstance();
_browserScriptEngineManager = BrowserScriptEngineManager.getInstance();
_alreadyStarted = false;
_parserInserted = false;
_wasParserInserted = false;
_forceAsync = true;
_readyToBeParserExecuted = false;
_creatorDocument = (document instanceof Html5DocumentImpl)? (Html5DocumentImpl)document : null;
_creatorParser = (document instanceof Html5DocumentImpl)? ((Html5DocumentImpl)document).getParser() : null;
_parserInserted = _creatorParser.isParserTask(); //
}
示例5: parseHtml
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
public void parseHtml(String htmlData, HtmlResult result)
throws DiscoveryException
{
if (DEBUG)
_log.debug("Parsing HTML data:\n" + htmlData);
HTMLDocumentImpl doc = this.parseDocument(htmlData);
NodeList heads = doc.getElementsByTagName("head");
if (heads.getLength() != 1)
throw new DiscoveryException(
"HTML response must have exactly one HEAD element, "
+ "found " + heads.getLength() + " : "
+ heads.toString(),
OpenIDException.DISCOVERY_HTML_PARSE_ERROR);
HTMLHeadElement head = (HTMLHeadElement) doc.getHead();
NodeList linkElements = head.getElementsByTagName("LINK");
for (int i = 0, len = linkElements.getLength(); i < len; i++)
{
HTMLLinkElement linkElement = (HTMLLinkElement) linkElements.item(i);
setResult(linkElement.getRel(), linkElement.getHref(), result);
}
if (DEBUG)
_log.debug("HTML discovery result:\n" + result);
}
示例6: parseTagSoup
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
private DocumentFragment parseTagSoup(InputSource input) throws Exception {
HTMLDocumentImpl doc = new HTMLDocumentImpl();
DocumentFragment frag = doc.createDocumentFragment();
DOMBuilder builder = new DOMBuilder(doc, frag);
org.ccil.cowan.tagsoup.Parser reader = new org.ccil.cowan.tagsoup.Parser();
reader.setContentHandler(builder);
reader.setFeature(org.ccil.cowan.tagsoup.Parser.ignoreBogonsFeature, true);
reader.setFeature(org.ccil.cowan.tagsoup.Parser.bogonsEmptyFeature, false);
reader.setProperty("http://xml.org/sax/properties/lexical-handler", builder);
reader.parse(input);
return frag;
}
示例7: jsoup2HTML
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
public static DocumentFragment jsoup2HTML(org.jsoup.nodes.Document jsoupDocument) {
HTMLDocumentImpl htmlDoc = new HTMLDocumentImpl();
htmlDoc.setErrorChecking(false);
DocumentFragment fragment = htmlDoc.createDocumentFragment();
createDOM(jsoupDocument, fragment, htmlDoc, new HashMap<String, String>());
return fragment;
}
示例8: parse
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
public static Node parse(String content) throws SAXException, IOException {
DOMFragmentParser parser = new DOMFragmentParser();
HTMLDocument document = new HTMLDocumentImpl();
DocumentFragment fragment = document.createDocumentFragment();
InputSource is = new InputSource(new StringReader(content));
parser.parse(is, fragment);
return fragment;
}
示例9: jsoup2HTML
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
public static DocumentFragment jsoup2HTML(
org.jsoup.nodes.Document jsoupDocument) {
HTMLDocumentImpl htmlDoc = new HTMLDocumentImpl();
htmlDoc.setErrorChecking(false);
DocumentFragment fragment = htmlDoc.createDocumentFragment();
createDOM(jsoupDocument, fragment, htmlDoc,
new HashMap<String, String>());
return fragment;
}
示例10: parse
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
public static Node parse( String content ) throws SAXException, IOException {
DOMFragmentParser parser = new DOMFragmentParser();
HTMLDocument document = new HTMLDocumentImpl();
DocumentFragment fragment = document.createDocumentFragment();
InputSource is = new InputSource( new StringReader( content ) );
parser.parse( is, fragment );
return fragment;
}
示例11: getHtmlMeta
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
public String getHtmlMeta(String input) throws YadisException
{
String xrdsLocation = null;
HTMLDocumentImpl doc = this.parseDocument(input);
if (DEBUG)
{
try
{
_log.debug("document:\n" + OpenID4JavaDOMParser.toXmlString(doc));
} catch (TransformerException e)
{
_log.debug("An exception occurs while transforming the document to string in debugging.", e);
}
}
NodeList heads = doc.getElementsByTagName("head");
if (heads.getLength() != 1)
throw new YadisException(
"HTML response must have exactly one HEAD element, "
+ "found " + heads.getLength() + " : "
+ heads.toString(),
OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE);
HTMLHeadElement head = (HTMLHeadElement) doc.getHead();
NodeList metaElements = head.getElementsByTagName("META");
if (metaElements == null || metaElements.getLength() == 0)
{
if (DEBUG)
_log.debug("No <meta> element found under <html><head>. " +
"See Yadis specification, section 6.2.5/1.");
}
else
{
for (int i = 0, len = metaElements.getLength(); i < len; i++)
{
HTMLMetaElement metaElement = (HTMLMetaElement) metaElements.item(i);
String httpEquiv = metaElement.getHttpEquiv();
if (YadisResolver.YADIS_XRDS_LOCATION.equalsIgnoreCase(httpEquiv))
{
if (xrdsLocation != null)
throw new YadisException(
"More than one "
+ YadisResolver.YADIS_XRDS_LOCATION
+ "META tags found in HEAD: "
+ head.toString(),
OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE);
xrdsLocation = metaElement.getContent();
if (DEBUG)
_log.debug("Found " + YadisResolver.YADIS_XRDS_LOCATION
+ " META tags.");
}
}
}
return xrdsLocation;
}
示例12: newDocument
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
/**
* @inheritDoc
*/
public SimpleHtmlDocument newDocument() {
return new SimpleHtmlDocument(new HTMLDocumentImpl());
}
示例13: Html5IFrameElementImpl
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
/**
* Constructs new iframe element.
*
* @param owner Document which owns this element.
* @param name Name of the element.
*/
public Html5IFrameElementImpl(HTMLDocumentImpl owner, String name) {
super(owner, name);
}
示例14: Html5ElementImpl
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
/**
* Constructs new element.
*
* @param owner Document which owns this element.
* @param name Name of the element.
*/
public Html5ElementImpl(HTMLDocumentImpl owner, String tagName) {
super(owner, tagName);
}
示例15: newPlainDocument
import org.apache.html.dom.HTMLDocumentImpl; //导入依赖的package包/类
/**
* @return an unenclosed Document. This is used only by the SimpleDocument
* no arg constructor
*/
HTMLDocument newPlainDocument() {
return new HTMLDocumentImpl();
}