Package org.htmlparser

Examples of org.htmlparser.PrototypicalNodeFactory


            "<!--\n"+
            "   Whats gonna happen now ?\n"+
            "-->\n"+
            "<TEST>\n"+
            "</TEST>\n");
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(15);
        // The first node should be a Remark
        assertTrue("First node should be a Remark",node[0] instanceof Remark);
        Remark Remark = (Remark)node[0];
        assertStringEquals("Raw String of the Remark #1","<!-- saved from url=(0022)http://internet.e-mail -->",Remark.toHtml());
View Full Code Here


     */
    public void testRemarkWithBlankLine() throws ParserException {
        createParser("<!--\n"+
        "\n"+
        "-->");
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a Remark",node[0] instanceof Remark);
        Remark Remark = (Remark)node[0];
        assertEquals("Expected contents","\n\n",Remark.getText());

View Full Code Here

     * by Claude Duguay.
     * If it is a comment with nothing in it, parser crashes
     */
    public void testRemarkWithNothing() throws ParserException {
        createParser("<!-->");
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a Remark",node[0] instanceof Remark);
        Remark Remark = (Remark)node[0];
        assertEquals("Expected contents","",Remark.getText());

View Full Code Here

     * @param endLine int the expected end line number of the tag
     * @throws ParserException if there is an exception during parsing
     */
    private void testLineNumber(String xml, int numNodes, int useNode, int expectedStartLine, int expectedEndLine) throws ParserException {
        createParser(xml);
        parser.setNodeFactory (new PrototypicalNodeFactory (new CustomTag ()));
        parseAndAssertNodeCount(numNodes);
        assertType("custom node",CustomTag.class,node[useNode]);
        CustomTag tag = (CustomTag)node[useNode];
        assertEquals("start line", expectedStartLine, tag.getStartingLineNumber ());
        assertEquals("end line", expectedEndLine, tag.getEndTag ().getEndingLineNumber ());
View Full Code Here

     */
    public void testTagWithinRemark() throws ParserException {
        createParser("<!-- \n"+
        "<A>\n"+
        "bcd -->");
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a Remark",node[0] instanceof Remark);
        Remark Remark = (Remark)node[0];
        assertStringEquals("Expected contents"," \n<A>\nbcd ",Remark.getText());

View Full Code Here

    public void testInvalidTag() throws ParserException {
        createParser("<!\n"+
        "-\n"+
        "-\n"+
        "ssd -->");
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a Tag but was "+node[0],node[0] instanceof Tag);
        Tag tag = (Tag)node[0];
        assertStringEquals("Expected contents","!\n"+
        "-\n"+
View Full Code Here

     * Bug reported by John Zook [594301]
     * If dashes exist in a comment, they dont get added to the comment text
     */
    public void testDashesInComment() throws ParserException{
        createParser("<!-- -- -->");
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a Remark but was "+node[0],node[0] instanceof Remark);
        Remark Remark = (Remark)node[0];
        assertEquals("Remark Node contents"," -- ",Remark.getText());
    }
View Full Code Here

            + "<BODY>\n"
            + "<!-- Id: html-sgml.sgm,v 1.5 1995/05/26 21:29:50 connolly Exp  -->\n"
            + "</BODY>\n"
            + "</HTML>\n"
            );
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(18);
        assertTrue("Node should be a Remark but was "+node[12],node[12] instanceof Remark);
        Remark Remark = (Remark)node[12];
        assertEquals("Remark Node contents"," Id: html-sgml.sgm,v 1.5 1995/05/26 21:29:50 connolly Exp  ",Remark.getText());
    }
View Full Code Here

            + "<BODY>\n"
            + "<!-- another -- -- comment -->\n"
            + "</BODY>\n"
            + "</HTML>\n"
            );
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(18);
        assertTrue("Node should be a Remark but was "+node[12],node[12] instanceof Remark);
        Remark Remark = (Remark)node[12];
        assertEquals("Remark Node contents"," another -- -- comment ",Remark.getText());
    }
View Full Code Here

            + "<BODY>\n"
            + "<!>\n"
            + "</BODY>\n"
            + "</HTML>\n"
            );
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(18);
        assertTrue("Node should be a Remark but was "+node[12],node[12] instanceof Remark);
        Remark Remark = (Remark)node[12];
        assertEquals("Remark Node contents","",Remark.getText());
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.PrototypicalNodeFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.