Java 类org.jsoup.nodes.Document.OutputSettings.Syntax 实例源码

项目:common    文件:DocumentTest.java   
@Test public void testHtmlAndXmlSyntax() {
    String h = "<!DOCTYPE html><body><img async checked='checked' src='&<>\"'>&lt;&gt;&amp;&quot;<foo />bar";
    Document doc = Jsoup.parse(h);

    doc.outputSettings().syntax(Syntax.html);
    assertEquals("<!doctype html>\n" +
            "<html>\n" +
            " <head></head>\n" +
            " <body>\n" +
            "  <img async checked src=\"&amp;<>&quot;\">&lt;&gt;&amp;\"\n" +
            "  <foo />bar\n" +
            " </body>\n" +
            "</html>", doc.html());

    doc.outputSettings().syntax(Document.OutputSettings.Syntax.xml);
    assertEquals("<!DOCTYPE html>\n" +
            "<html>\n" +
            " <head></head>\n" +
            " <body>\n" +
            "  <img async=\"\" checked=\"checked\" src=\"&amp;<>&quot;\" />&lt;&gt;&amp;\"\n" +
            "  <foo />bar\n" +
            " </body>\n" +
            "</html>", doc.html());
}
项目:astor    文件:DocumentTest.java   
@Test public void testHtmlAndXmlSyntax() {
    String h = "<!DOCTYPE html><body><img async checked='checked' src='&<>\"'>&lt;&gt;&amp;&quot;<foo />bar";
    Document doc = Jsoup.parse(h);

    doc.outputSettings().syntax(Syntax.html);
    assertEquals("<!doctype html>\n" +
            "<html>\n" +
            " <head></head>\n" +
            " <body>\n" +
            "  <img async checked src=\"&amp;<>&quot;\">&lt;&gt;&amp;\"\n" +
            "  <foo />bar\n" +
            " </body>\n" +
            "</html>", doc.html());

    doc.outputSettings().syntax(Document.OutputSettings.Syntax.xml);
    assertEquals("<!DOCTYPE html>\n" +
            "<html>\n" +
            " <head></head>\n" +
            " <body>\n" +
            "  <img async=\"\" checked=\"checked\" src=\"&amp;<>&quot;\" />&lt;&gt;&amp;\"\n" +
            "  <foo />bar\n" +
            " </body>\n" +
            "</html>", doc.html());
}
项目:astor    文件:DocumentType.java   
@Override
void outerHtmlHead(Appendable accum, int depth, Document.OutputSettings out) throws IOException {
    if (out.syntax() == Syntax.html && !has(PUBLIC_ID) && !has(SYSTEM_ID)) {
        // looks like a html5 doctype, go lowercase for aesthetics
        accum.append("<!doctype");
    } else {
        accum.append("<!DOCTYPE");
    }
    if (has(NAME))
        accum.append(" ").append(attr(NAME));
    if (has(PUB_SYS_KEY))
        accum.append(" ").append(attr(PUB_SYS_KEY));
    if (has(PUBLIC_ID))
        accum.append(" \"").append(attr(PUBLIC_ID)).append('"');
    if (has(SYSTEM_ID))
        accum.append(" \"").append(attr(SYSTEM_ID)).append('"');
    accum.append('>');
}
项目:astor    文件:DocumentTest.java   
@Test public void testHtmlAndXmlSyntax() {
    String h = "<!DOCTYPE html><body><img async checked='checked' src='&<>\"'>&lt;&gt;&amp;&quot;<foo />bar";
    Document doc = Jsoup.parse(h);

    doc.outputSettings().syntax(Syntax.html);
    assertEquals("<!doctype html>\n" +
            "<html>\n" +
            " <head></head>\n" +
            " <body>\n" +
            "  <img async checked src=\"&amp;<>&quot;\">&lt;&gt;&amp;\"\n" +
            "  <foo />bar\n" +
            " </body>\n" +
            "</html>", doc.html());

    doc.outputSettings().syntax(Document.OutputSettings.Syntax.xml);
    assertEquals("<!DOCTYPE html>\n" +
            "<html>\n" +
            " <head></head>\n" +
            " <body>\n" +
            "  <img async=\"\" checked=\"checked\" src=\"&amp;<>&quot;\" />&lt;&gt;&amp;\"\n" +
            "  <foo />bar\n" +
            " </body>\n" +
            "</html>", doc.html());
}
项目:astor    文件:DocumentType.java   
@Override
void outerHtmlHead(Appendable accum, int depth, Document.OutputSettings out) throws IOException {
    if (out.syntax() == Syntax.html && !has(PUBLIC_ID) && !has(SYSTEM_ID)) {
        // looks like a html5 doctype, go lowercase for aesthetics
        accum.append("<!doctype");
    } else {
        accum.append("<!DOCTYPE");
    }
    if (has(NAME))
        accum.append(" ").append(attr(NAME));
    if (has(PUB_SYS_KEY))
        accum.append(" ").append(attr(PUB_SYS_KEY));
    if (has(PUBLIC_ID))
        accum.append(" \"").append(attr(PUBLIC_ID)).append('"');
    if (has(SYSTEM_ID))
        accum.append(" \"").append(attr(SYSTEM_ID)).append('"');
    accum.append('>');
}
项目:astor    文件:DocumentTest.java   
@Test public void testHtmlAndXmlSyntax() {
    String h = "<!DOCTYPE html><body><img async checked='checked' src='&<>\"'>&lt;&gt;&amp;&quot;<foo />bar";
    Document doc = Jsoup.parse(h);

    doc.outputSettings().syntax(Syntax.html);
    assertEquals("<!doctype html>\n" +
            "<html>\n" +
            " <head></head>\n" +
            " <body>\n" +
            "  <img async checked src=\"&amp;<>&quot;\">&lt;&gt;&amp;\"\n" +
            "  <foo />bar\n" +
            " </body>\n" +
            "</html>", doc.html());

    doc.outputSettings().syntax(Document.OutputSettings.Syntax.xml);
    assertEquals("<!DOCTYPE html>\n" +
            "<html>\n" +
            " <head></head>\n" +
            " <body>\n" +
            "  <img async=\"\" checked=\"checked\" src=\"&amp;<>&quot;\" />&lt;&gt;&amp;\"\n" +
            "  <foo />bar\n" +
            " </body>\n" +
            "</html>", doc.html());
}
项目:common    文件:DocumentTest.java   
private Document createXmlDocument(String version, String charset, boolean addDecl) {
    final Document doc = new Document("");
    doc.appendElement("root").text("node");
    doc.outputSettings().syntax(Syntax.xml);

    if( addDecl == true ) {
        XmlDeclaration decl = new XmlDeclaration("xml", "", false);
        decl.attr("version", version);
        decl.attr("encoding", charset);
        doc.prependChild(decl);
    }

    return doc;
}
项目:astor    文件:DocumentTest.java   
private Document createXmlDocument(String version, String charset, boolean addDecl) {
    final Document doc = new Document("");
    doc.appendElement("root").text("node");
    doc.outputSettings().syntax(Syntax.xml);

    if( addDecl == true ) {
        XmlDeclaration decl = new XmlDeclaration("xml", "", false);
        decl.attr("version", version);
        decl.attr("encoding", charset);
        doc.prependChild(decl);
    }

    return doc;
}
项目:astor    文件:DocumentTest.java   
private Document createXmlDocument(String version, String charset, boolean addDecl) {
    final Document doc = new Document("");
    doc.appendElement("root").text("node");
    doc.outputSettings().syntax(Syntax.xml);

    if( addDecl == true ) {
        XmlDeclaration decl = new XmlDeclaration("xml", false);
        decl.attr("version", version);
        decl.attr("encoding", charset);
        doc.prependChild(decl);
    }

    return doc;
}
项目:astor    文件:DocumentTest.java   
private Document createXmlDocument(String version, String charset, boolean addDecl) {
    final Document doc = new Document("");
    doc.appendElement("root").text("node");
    doc.outputSettings().syntax(Syntax.xml);

    if( addDecl == true ) {
        XmlDeclaration decl = new XmlDeclaration("xml", false);
        decl.attr("version", version);
        decl.attr("encoding", charset);
        doc.prependChild(decl);
    }

    return doc;
}
项目:common    文件:DocumentTest.java   
@Test public void htmlParseDefaultsToHtmlOutputSyntax() {
    Document doc = Jsoup.parse("x");
    assertEquals(Syntax.html, doc.outputSettings().syntax());
}
项目:CrawlerPack    文件:PrefixXmlTreeBuilder.java   
protected void initialiseParse(String input, String baseUri, ParseErrorList errors) {
    super.initialiseParse(input, baseUri, errors);
    this.stack.add(this.doc);
    this.doc.outputSettings().syntax(Syntax.xml);
}
项目:astor    文件:DocumentTest.java   
@Test public void htmlParseDefaultsToHtmlOutputSyntax() {
    Document doc = Jsoup.parse("x");
    assertEquals(Syntax.html, doc.outputSettings().syntax());
}
项目:astor    文件:DocumentTest.java   
@Test public void htmlParseDefaultsToHtmlOutputSyntax() {
    Document doc = Jsoup.parse("x");
    assertEquals(Syntax.html, doc.outputSettings().syntax());
}
项目:astor    文件:DocumentTest.java   
@Test public void htmlParseDefaultsToHtmlOutputSyntax() {
    Document doc = Jsoup.parse("x");
    assertEquals(Syntax.html, doc.outputSettings().syntax());
}