org.jsoup.nodes.DocumentType Java Examples

The following examples show how to use org.jsoup.nodes.DocumentType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HtmlVisitor.java    From compiler with Apache License 2.0 5 votes vote down vote up
public void visit(DocumentType node) {
	Ast.Element.Builder b = Ast.Element.newBuilder();
	b.setKind(ElementKind.DOC_TYPE);
	b.setTag("!DOCTYPE");
	for (Attribute n : node.attributes()) {
		visit(n);
		b.addAttributes(attributes.pop());
	}
	elements.peek().add(b.build());
}
 
Example #2
Source File: Evaluator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean matches(Element root, Element element) {
      	List<Node> family = element.childNodes();
          for (Node n : family) {
              if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false;
          }
      	return true;
}
 
Example #3
Source File: Evaluator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean matches(Element root, Element element) {
      	List<Node> family = element.childNodes();
          for (Node n : family) {
              if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false;
          }
      	return true;
}
 
Example #4
Source File: Evaluator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean matches(Element root, Element element) {
      	List<Node> family = element.childNodes();
          for (Node n : family) {
              if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false;
          }
      	return true;
}
 
Example #5
Source File: Evaluator.java    From jsoup-learning with MIT License 5 votes vote down vote up
@Override
public boolean matches(Element root, Element element) {
      	List<Node> family = element.childNodes();
      	for (int i = 0; i < family.size(); i++) {
      		Node n = family.get(i);
      		if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false; 
      	}
      	return true;
}
 
Example #6
Source File: BootstrapHandler.java    From flow with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the bootstrap page for the given context.
 *
 * @param context
 *            Context to generate bootstrap page for.
 * @return A document with the corresponding HTML page.
 */
@Override
public Document getBootstrapPage(BootstrapContext context) {
    DeploymentConfiguration config = context.getSession()
            .getConfiguration();

    Document document = new Document("");
    DocumentType doctype = new DocumentType("html", "", "");
    document.appendChild(doctype);

    Element html = document.appendElement("html");
    html.attr("lang", context.getUI().getLocale().getLanguage());
    Element head = html.appendElement("head");
    html.appendElement("body");

    List<Element> dependenciesToInlineInBody = setupDocumentHead(head,
            context);
    dependenciesToInlineInBody.forEach(
            dependency -> document.body().appendChild(dependency));
    setupDocumentBody(document);

    document.outputSettings().prettyPrint(false);

    BootstrapUtils.getInlineTargets(context)
            .ifPresent(targets -> handleInlineTargets(context, head,
                    document.body(), targets));

    BootstrapUtils.getInitialPageSettings(context).ifPresent(
            initialPageSettings -> handleInitialPageSettings(context,
                    head, initialPageSettings));

    if (!config.isProductionMode()) {
        UsageStatisticsExporter
                .exportUsageStatisticsToDocument(document);
    }

    setupPwa(document, context);

    if (!config.isProductionMode()) {
        showWebpackErrors(document);
    }

    BootstrapPageResponse response = new BootstrapPageResponse(
            context.getRequest(), context.getSession(),
            context.getResponse(), document, context.getUI(),
            context.getUriResolver());
    context.getSession().getService().modifyBootstrapPage(response);

    return document;
}