\n
+)p
+(p
+"P2
+)p
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/command/test-command-inside-head.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/command/test-command-inside-head.html.canonical-sax-cust
new file mode 100644
index 00000000..ea9112b4
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/command/test-command-inside-head.html.canonical-sax-cust
@@ -0,0 +1,10 @@
+(HTML
+(head
+Aid outer
+)head
+(BODY
+(command
+x)head
+)command
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/doctype/test-ignore-invalid-doctype.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/doctype/test-ignore-invalid-doctype.html.canonical-sax-cust
new file mode 100644
index 00000000..cfb4d0d6
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/doctype/test-ignore-invalid-doctype.html.canonical-sax-cust
@@ -0,0 +1,9 @@
+#doctype
+(html
+x(html
+(head
+)head
+(body
+"stupid
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/error-handling/test-broken-pi.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/error-handling/test-broken-pi.html.canonical-sax-cust
new file mode 100644
index 00000000..f4cd441f
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/error-handling/test-broken-pi.html.canonical-sax-cust
@@ -0,0 +1,8 @@
+#?
+?a
+(HTML
+(head
+)head
+(body
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/error-handling/test-improperly-closed-tag.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/error-handling/test-improperly-closed-tag.html.canonical-sax-cust
new file mode 100644
index 00000000..ed454460
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/error-handling/test-improperly-closed-tag.html.canonical-sax-cust
@@ -0,0 +1,13 @@
+(html
+(head
+)head
+(body
+(div
+(span
+A<
+Aspan
+)span
+)div
+"\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/error-handling/test-report-errors-end-body-html.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/error-handling/test-report-errors-end-body-html.html.canonical-sax-cust
new file mode 100644
index 00000000..6abe3fd6
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/error-handling/test-report-errors-end-body-html.html.canonical-sax-cust
@@ -0,0 +1,10 @@
+(html
+(head
+)head
+(body
+"\n
+(div
+"not closed div\n
+)div
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-body-frameset.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-body-frameset.html.canonical-sax-cust
new file mode 100644
index 00000000..5b2e45da
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-body-frameset.html.canonical-sax-cust
@@ -0,0 +1,10 @@
+(HTML
+(head
+)head
+(frameset
+(frame
+Aid frame1
+)frame
+)frameset
+x(body
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-3555034.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-3555034.html.canonical-sax-cust
new file mode 100644
index 00000000..d05d1f63
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-3555034.html.canonical-sax-cust
@@ -0,0 +1,12 @@
+(HTML
+(head
+)head
+(frameset
+"\n
+x(p
+x)p
+"\n
+)frameset
+x(p
+x)p
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-body.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-body.html.canonical-sax-cust
new file mode 100644
index 00000000..2055fb55
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-body.html.canonical-sax-cust
@@ -0,0 +1,10 @@
+(HTML
+(head
+)head
+(body
+x(frameset
+x(frame
+Aid frame1
+x)frameset
+)body
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-head-text.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-head-text.html.canonical-sax-cust
new file mode 100644
index 00000000..c12ab8be
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-head-text.html.canonical-sax-cust
@@ -0,0 +1,14 @@
+(HTML
+(head
+(title
+"title
+)title
+)head
+(body
+"Some text
+x(frameset
+x(frame
+Aid frame1
+x)frameset
+)body
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-noframes.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-noframes.html.canonical-sax-cust
new file mode 100644
index 00000000..61664c42
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-noframes.html.canonical-sax-cust
@@ -0,0 +1,16 @@
+(html
+(head
+)head
+(frameset
+"\n
+(frame
+)frame
+"\n
+(noframes
+"hello
+x)noframes
+"\n
+)noframes
+)frameset
+x)html
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-text.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-text.html.canonical-sax-cust
new file mode 100644
index 00000000..934b80b2
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset-text.html.canonical-sax-cust
@@ -0,0 +1,11 @@
+(HTML
+(head
+)head
+(body
+"Some text
+x(frameset
+x(frame
+Aid frame1
+x)frameset
+)body
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset.html.canonical-sax-cust
new file mode 100644
index 00000000..b4ac62b7
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/frameset/test-frameset.html.canonical-sax-cust
@@ -0,0 +1,17 @@
+(html
+(head
+(title
+"first
+)title
+)head
+(frameset
+Acols 100%
+"\n
+(frame
+Aid frame1
+Asrc foo
+)frame
+"\n
+)frameset
+x)html
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/head/test-duplicated-head.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/head/test-duplicated-head.html.canonical-sax-cust
new file mode 100644
index 00000000..c2cbef09
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/head/test-duplicated-head.html.canonical-sax-cust
@@ -0,0 +1,11 @@
+(HTML
+(head
+x(head
+(title
+"x
+)title
+)head
+x)head
+(body
+)body
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/head/test-head-frame.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/head/test-head-frame.html.canonical-sax-cust
new file mode 100644
index 00000000..c8dad23b
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/head/test-head-frame.html.canonical-sax-cust
@@ -0,0 +1,8 @@
+(html
+(head
+Aid outer
+x(frame
+)head
+(body
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/input/test-input-self-closing.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/input/test-input-self-closing.html.canonical-sax-cust
new file mode 100644
index 00000000..ba9239eb
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/input/test-input-self-closing.html.canonical-sax-cust
@@ -0,0 +1,11 @@
+(html
+(head
+)head
+(body
+"\n
+(input
+Atype button
+)input
+"\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/insert-namespace/test-NPE-2942363.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/insert-namespace/test-NPE-2942363.html.canonical-sax-cust
new file mode 100644
index 00000000..2fe2d59d
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/insert-namespace/test-NPE-2942363.html.canonical-sax-cust
@@ -0,0 +1,7 @@
+x)div
+(HTML
+(head
+)head
+(body
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/li/test-li-inside-b.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/li/test-li-inside-b.html.canonical-sax-cust
new file mode 100644
index 00000000..bb6b2f28
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/li/test-li-inside-b.html.canonical-sax-cust
@@ -0,0 +1,21 @@
+(HTML
+(head
+)head
+(BODY
+(p
+(b
+"Leading Text
+)b
+)p
+(li
+"data1
+)li
+(li
+"data2
+)li
+"Closing Text
+x)b
+(p
+)p
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/li/test034.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/li/test034.html.canonical-sax-cust
new file mode 100644
index 00000000..910c003f
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/li/test034.html.canonical-sax-cust
@@ -0,0 +1,15 @@
+(HTML
+(head
+)head
+(BODY
+(li
+"Item1
+(ul
+x)li
+(li
+"Item2
+)li
+)ul
+)li
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-ignore-outside-content.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-ignore-outside-content.html.canonical-sax-cust
new file mode 100644
index 00000000..3e5f0bf3
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-ignore-outside-content.html.canonical-sax-cust
@@ -0,0 +1,13 @@
+(html
+(head
+)head
+(body
+"\n\n
+)body
+x(BODY
+x(p
+x(BODY
+x(a
+x)a
+x)p
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html
new file mode 100644
index 00000000..e0e5b98c
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html
@@ -0,0 +1,9 @@
+
+
+
Link1
+
+
Link2
+
Link3
+
+
+
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical
new file mode 100644
index 00000000..638c0cc3
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical
@@ -0,0 +1,22 @@
+(html
+(head
+)head
+(body
+"\n
+(a
+Ahref link1.html
+"Link1
+)a
+"\n\n
+(a
+Ahref link2.html
+"Link2
+)a
+"\n
+(a
+Ahref link3.html
+"Link3
+)a
+"\n\n\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical-frg b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical-frg
new file mode 100644
index 00000000..000bf717
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical-frg
@@ -0,0 +1,23 @@
+(html
+"\n
+(head
+)head
+(body
+"\n
+(a
+Ahref link1.html
+"Link1
+)a
+"\n\n
+(a
+Ahref link2.html
+"Link2
+)a
+"\n
+(a
+Ahref link3.html
+"Link3
+)a
+"\n\n\n\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical-html b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical-html
new file mode 100644
index 00000000..2f80a028
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical-html
@@ -0,0 +1,8 @@
+
+
Link1
+
+
Link2
+
Link3
+
+
+
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical-sax-cust
new file mode 100644
index 00000000..cfff5942
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical-sax-cust
@@ -0,0 +1,26 @@
+(html
+(head
+)head
+(body
+"\n
+(a
+Ahref link1.html
+"Link1
+)a
+"\n
+x)a
+"\n
+(a
+Ahref link2.html
+"Link2
+)a
+"\n
+(a
+Ahref link3.html
+"Link3
+)a
+"\n
+x)a
+"\n\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical-xni b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical-xni
new file mode 100644
index 00000000..6d2cfcbd
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times-valid-inbetween.html.canonical-xni
@@ -0,0 +1,31 @@
+startDocument [(1,1,0) (1,1,0) false]
+startElement (localpart="html",rawname="html") [(1,1,0) (1,7,6) false]
+startElement (localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
+endElement (localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
+startElement (localpart="body",rawname="body") [(2,1,7) (2,7,13) false]
+characters '
+'[(2,7,13) (3,1,14) false]
+startElement (localpart="a",rawname="a") [(3,1,14) (3,22,35) false]
+characters 'Link1'[(3,22,35) (3,27,40) false]
+endElement (localpart="a",rawname="a") [(3,27,40) (3,31,44) false]
+characters '
+'[(3,31,44) (4,1,45) false]
+characters '
+'[(4,5,49) (5,1,50) false]
+startElement (localpart="a",rawname="a") [(5,1,50) (5,22,71) false]
+characters 'Link2'[(5,22,71) (5,27,76) false]
+endElement (localpart="a",rawname="a") [(5,27,76) (5,31,80) false]
+characters '
+'[(5,31,80) (6,1,81) false]
+startElement (localpart="a",rawname="a") [(6,1,81) (6,22,102) false]
+characters 'Link3'[(6,22,102) (6,27,107) false]
+endElement (localpart="a",rawname="a") [(6,27,107) (6,31,111) false]
+characters '
+'[(6,31,111) (7,1,112) false]
+characters '
+'[(7,5,116) (8,1,117) false]
+characters '
+'[(9,8,132) (10,1,133) false]
+endElement (localpart="body",rawname="body") [(8,1,117) (8,8,124) false]
+endElement (localpart="html",rawname="html") [(9,1,125) (9,8,132) false]
+endDocument [(10,1,133) (10,1,133) false]
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html
new file mode 100644
index 00000000..540279bf
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html
@@ -0,0 +1,9 @@
+
+
+
Link1
+
+
Link2
+
+
Link3
+
+
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical
new file mode 100644
index 00000000..a5c28d1e
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical
@@ -0,0 +1,22 @@
+(html
+(head
+)head
+(body
+"\n
+(a
+Ahref link1.html
+"Link1
+)a
+"\n\n
+(a
+Ahref link2.html
+"Link2
+)a
+"\n\n
+(a
+Ahref link3.html
+"Link3
+)a
+"\n\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical-frg b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical-frg
new file mode 100644
index 00000000..5857a00c
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical-frg
@@ -0,0 +1,23 @@
+(html
+"\n
+(head
+)head
+(body
+"\n
+(a
+Ahref link1.html
+"Link1
+)a
+"\n\n
+(a
+Ahref link2.html
+"Link2
+)a
+"\n\n
+(a
+Ahref link3.html
+"Link3
+)a
+"\n\n\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical-html b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical-html
new file mode 100644
index 00000000..f174f828
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical-html
@@ -0,0 +1,8 @@
+
+
Link1
+
+
Link2
+
+
Link3
+
+
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical-sax-cust
new file mode 100644
index 00000000..91a8440b
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical-sax-cust
@@ -0,0 +1,26 @@
+(html
+(head
+)head
+(body
+"\n
+(a
+Ahref link1.html
+"Link1
+)a
+"\n
+x)a
+"\n
+(a
+Ahref link2.html
+"Link2
+)a
+"\n
+x)a
+"\n
+(a
+Ahref link3.html
+"Link3
+)a
+"\n\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical-xni b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical-xni
new file mode 100644
index 00000000..bec8aa2e
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a-two-times.html.canonical-xni
@@ -0,0 +1,31 @@
+startDocument [(1,1,0) (1,1,0) false]
+startElement (localpart="html",rawname="html") [(1,1,0) (1,7,6) false]
+startElement (localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
+endElement (localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
+startElement (localpart="body",rawname="body") [(2,1,7) (2,7,13) false]
+characters '
+'[(2,7,13) (3,1,14) false]
+startElement (localpart="a",rawname="a") [(3,1,14) (3,22,35) false]
+characters 'Link1'[(3,22,35) (3,27,40) false]
+endElement (localpart="a",rawname="a") [(3,27,40) (3,31,44) false]
+characters '
+'[(3,31,44) (4,1,45) false]
+characters '
+'[(4,5,49) (5,1,50) false]
+startElement (localpart="a",rawname="a") [(5,1,50) (5,22,71) false]
+characters 'Link2'[(5,22,71) (5,27,76) false]
+endElement (localpart="a",rawname="a") [(5,27,76) (5,31,80) false]
+characters '
+'[(5,31,80) (6,1,81) false]
+characters '
+'[(6,5,85) (7,1,86) false]
+startElement (localpart="a",rawname="a") [(7,1,86) (7,22,107) false]
+characters 'Link3'[(7,22,107) (7,27,112) false]
+endElement (localpart="a",rawname="a") [(7,27,112) (7,31,116) false]
+characters '
+'[(7,31,116) (8,1,117) false]
+characters '
+'[(9,8,132) (10,1,133) false]
+endElement (localpart="body",rawname="body") [(8,1,117) (8,8,124) false]
+endElement (localpart="html",rawname="html") [(9,1,125) (9,8,132) false]
+endDocument [(10,1,133) (10,1,133) false]
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html
new file mode 100644
index 00000000..8e57e9d6
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html
@@ -0,0 +1,7 @@
+
+
+
Link1
+
+
Link2
+
+
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical
new file mode 100644
index 00000000..c458c9a6
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical
@@ -0,0 +1,17 @@
+(html
+(head
+)head
+(body
+"\n
+(a
+Ahref link1.html
+"Link1
+)a
+"\n\n
+(a
+Ahref link2.html
+"Link2
+)a
+"\n\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical-frg b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical-frg
new file mode 100644
index 00000000..bb42dc38
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical-frg
@@ -0,0 +1,18 @@
+(html
+"\n
+(head
+)head
+(body
+"\n
+(a
+Ahref link1.html
+"Link1
+)a
+"\n\n
+(a
+Ahref link2.html
+"Link2
+)a
+"\n\n\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical-html b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical-html
new file mode 100644
index 00000000..9da308ce
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical-html
@@ -0,0 +1,6 @@
+
+
Link1
+
+
Link2
+
+
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical-sax-cust
new file mode 100644
index 00000000..d0b2b936
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical-sax-cust
@@ -0,0 +1,19 @@
+(html
+(head
+)head
+(body
+"\n
+(a
+Ahref link1.html
+"Link1
+)a
+"\n
+x)a
+"\n
+(a
+Ahref link2.html
+"Link2
+)a
+"\n\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical-xni b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical-xni
new file mode 100644
index 00000000..5ff935a2
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-a.html.canonical-xni
@@ -0,0 +1,24 @@
+startDocument [(1,1,0) (1,1,0) false]
+startElement (localpart="html",rawname="html") [(1,1,0) (1,7,6) false]
+startElement (localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
+endElement (localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
+startElement (localpart="body",rawname="body") [(2,1,7) (2,7,13) false]
+characters '
+'[(2,7,13) (3,1,14) false]
+startElement (localpart="a",rawname="a") [(3,1,14) (3,22,35) false]
+characters 'Link1'[(3,22,35) (3,27,40) false]
+endElement (localpart="a",rawname="a") [(3,27,40) (3,31,44) false]
+characters '
+'[(3,31,44) (4,1,45) false]
+characters '
+'[(4,5,49) (5,1,50) false]
+startElement (localpart="a",rawname="a") [(5,1,50) (5,22,71) false]
+characters 'Link2'[(5,22,71) (5,27,76) false]
+endElement (localpart="a",rawname="a") [(5,27,76) (5,31,80) false]
+characters '
+'[(5,31,80) (6,1,81) false]
+characters '
+'[(7,8,96) (8,1,97) false]
+endElement (localpart="body",rawname="body") [(6,1,81) (6,8,88) false]
+endElement (localpart="html",rawname="html") [(7,1,89) (7,8,96) false]
+endDocument [(8,1,97) (8,1,97) false]
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html
new file mode 100644
index 00000000..b020ebfe
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html
@@ -0,0 +1,25 @@
+
+
+
+
Codestin Search App
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical
new file mode 100644
index 00000000..4d19d5cf
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical
@@ -0,0 +1,60 @@
+!html
+p-//W3C//DTD XHTML 1.0 Transitional//EN
+shttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
+(html
+A{http://www.w3.org/2000/xmlns/}xmlns http://www.w3.org/1999/xhtml
+(head
+"\n
+(title
+"Test
+)title
+"\n
+(meta
+Acontent text/html; charset=utf-8
+Ahttp-equiv content-type
+)meta
+"\n
+)head
+(body
+"\n
+(table
+"\n\t
+(TBODY
+(tr
+"\n\t\t
+(td
+"\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t
+)td
+"\n\t\t
+(td
+"\n\t\t\t
+(a
+Ahref view_download
+"Wird gesucht!
+)a
+"\n\t\t
+)td
+"\n\t
+)tr
+"\n
+)TBODY
+)table
+"\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical-frg b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical-frg
new file mode 100644
index 00000000..2d8b15f9
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical-frg
@@ -0,0 +1,59 @@
+"\n
+(html
+Axmlns http://www.w3.org/1999/xhtml
+"\n
+(head
+"\n
+(title
+"Test
+)title
+"\n
+(meta
+Acontent text/html; charset=utf-8
+Ahttp-equiv content-type
+)meta
+"\n\n
+)head
+(body
+"\n
+(table
+"\n\t
+(TBODY
+(tr
+"\n\t\t
+(td
+"\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t
+)td
+"\n\t\t
+(td
+"\n\t\t\t
+(a
+Ahref view_download
+"Wird gesucht!
+)a
+"\n\t\t
+)td
+"\n\t
+)tr
+"\n
+)TBODY
+)table
+"\n\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical-html b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical-html
new file mode 100644
index 00000000..0c4d5fa9
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical-html
@@ -0,0 +1,21 @@
+
+
Codestin Search App
+
+
+
+	
+		
+			
+			
+			
+			
+			
+			
+			
+		 |
+		
+			Wird gesucht!
+		 |
+	
+
+
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical-sax-cust
new file mode 100644
index 00000000..6bdfcb75
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical-sax-cust
@@ -0,0 +1,66 @@
+!html
+p-//W3C//DTD XHTML 1.0 Transitional//EN
+shttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
+(html
+A{http://www.w3.org/2000/xmlns/}xmlns http://www.w3.org/1999/xhtml
+(head
+"\n
+(title
+"Test
+)title
+"\n
+(meta
+Acontent text/html; charset=utf-8
+Ahttp-equiv content-type
+)meta
+"\n
+)head
+(body
+"\n
+(table
+"\n\t
+(TBODY
+(tr
+"\n\t\t
+(td
+"\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t
+x)a
+"\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t
+x)a
+"\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t
+x)a
+"\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t
+)td
+"\n\t\t
+(td
+"\n\t\t\t
+(a
+Ahref view_download
+"Wird gesucht!
+)a
+"\n\t\t
+)td
+"\n\t
+)tr
+"\n
+)TBODY
+)table
+"\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical-xni b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical-xni
new file mode 100644
index 00000000..eb535a30
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex3.html.canonical-xni
@@ -0,0 +1,76 @@
+startDocument [(1,1,0) (1,1,0) false]
+doctypeDecl [(1,1,0) (1,122,121) false]
+startElement (prefix="",localpart="html",rawname="html",uri="http://www.w3.org/1999/xhtml") [(2,1,122) (2,44,165) false]
+startElement (prefix="",localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml") [(3,1,166) (3,7,172) false]
+characters '
+'[(3,7,172) (4,1,173) false]
+startElement (prefix="",localpart="title",rawname="title",uri="http://www.w3.org/1999/xhtml") [(4,1,173) (4,8,180) false]
+characters 'Test'[(4,8,180) (4,12,184) false]
+endElement (prefix="",localpart="title",rawname="title",uri="http://www.w3.org/1999/xhtml") [(4,12,184) (4,20,192) false]
+characters '
+'[(4,20,192) (5,1,193) false]
+emptyElement (prefix="",localpart="meta",rawname="meta",uri="http://www.w3.org/1999/xhtml") [(5,1,193) (5,70,262) false]
+characters '
+'[(5,70,262) (6,1,263) false]
+endElement (prefix="",localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml") [(6,1,263) (6,8,270) false]
+startElement (prefix="",localpart="body",rawname="body",uri="http://www.w3.org/1999/xhtml") [(7,1,271) (7,7,277) false]
+characters '
+'[(7,7,277) (8,1,278) false]
+startElement (prefix="",localpart="table",rawname="table",uri="http://www.w3.org/1999/xhtml") [(8,1,278) (8,8,285) false]
+characters '
+ '[(8,8,285) (9,2,287) false]
+startElement (localpart="TBODY",rawname="TBODY",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
+startElement (prefix="",localpart="tr",rawname="tr",uri="http://www.w3.org/1999/xhtml") [(9,2,287) (9,6,291) false]
+characters '
+ '[(9,6,291) (10,3,294) false]
+startElement (prefix="",localpart="td",rawname="td",uri="http://www.w3.org/1999/xhtml") [(10,3,294) (10,7,298) false]
+characters '
+ '[(10,7,298) (11,4,302) false]
+startElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(11,4,302) (11,15,313) false]
+endElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(11,15,313) (11,19,317) false]
+characters '
+ '[(11,19,317) (12,4,321) false]
+characters '
+ '[(12,8,325) (13,4,329) false]
+startElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(13,4,329) (13,15,340) false]
+endElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(13,15,340) (13,19,344) false]
+characters '
+ '[(13,19,344) (14,4,348) false]
+characters '
+ '[(14,8,352) (15,4,356) false]
+startElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(15,4,356) (15,15,367) false]
+endElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(15,15,367) (15,19,371) false]
+characters '
+ '[(15,19,371) (16,4,375) false]
+characters '
+ '[(16,8,379) (17,4,383) false]
+startElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(17,4,383) (17,15,394) false]
+endElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(17,15,394) (17,19,398) false]
+characters '
+ '[(17,19,398) (18,3,401) false]
+endElement (prefix="",localpart="td",rawname="td",uri="http://www.w3.org/1999/xhtml") [(18,3,401) (18,8,406) false]
+characters '
+ '[(18,8,406) (19,3,409) false]
+startElement (prefix="",localpart="td",rawname="td",uri="http://www.w3.org/1999/xhtml") [(19,3,409) (19,7,413) false]
+characters '
+ '[(19,7,413) (20,4,417) false]
+startElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(20,4,417) (20,28,441) false]
+characters 'Wird gesucht!'[(20,28,441) (20,41,454) false]
+endElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(20,41,454) (20,45,458) false]
+characters '
+ '[(20,45,458) (21,3,461) false]
+endElement (prefix="",localpart="td",rawname="td",uri="http://www.w3.org/1999/xhtml") [(21,3,461) (21,8,466) false]
+characters '
+ '[(21,8,466) (22,2,468) false]
+endElement (prefix="",localpart="tr",rawname="tr",uri="http://www.w3.org/1999/xhtml") [(22,2,468) (22,7,473) false]
+characters '
+'[(22,7,473) (23,1,474) false]
+endElement (localpart="TBODY",rawname="TBODY",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
+endElement (prefix="",localpart="table",rawname="table",uri="http://www.w3.org/1999/xhtml") [(23,1,474) (23,9,482) false]
+characters '
+'[(23,9,482) (24,1,483) false]
+characters '
+'[(25,8,498) (26,1,499) false]
+endElement (prefix="",localpart="body",rawname="body",uri="http://www.w3.org/1999/xhtml") [(24,1,483) (24,8,490) false]
+endElement (prefix="",localpart="html",rawname="html",uri="http://www.w3.org/1999/xhtml") [(25,1,491) (25,8,498) false]
+endDocument [(26,1,499) (26,1,499) false]
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html
new file mode 100644
index 00000000..75177add
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html
@@ -0,0 +1,26 @@
+
+
+
+
Codestin Search App
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical
new file mode 100644
index 00000000..f63fdd2c
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical
@@ -0,0 +1,60 @@
+!html
+p-//W3C//DTD XHTML 1.0 Transitional//EN
+shttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
+(html
+A{http://www.w3.org/2000/xmlns/}xmlns http://www.w3.org/1999/xhtml
+(head
+"\n
+(title
+"Test
+)title
+"\n
+(meta
+Acontent text/html; charset=utf-8
+Ahttp-equiv content-type
+)meta
+"\n
+)head
+(body
+"\n
+(table
+"\n\t
+(TBODY
+(tr
+"\n\t\t
+(td
+"\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t
+)td
+"\n\t\t
+(td
+"\n\t\t\t
+(a
+Ahref view_download
+"Wird gesucht!
+)a
+"\n\t\t
+)td
+"\n\t
+)tr
+"\n
+)TBODY
+)table
+"\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical-frg b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical-frg
new file mode 100644
index 00000000..df001f10
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical-frg
@@ -0,0 +1,59 @@
+"\n
+(html
+Axmlns http://www.w3.org/1999/xhtml
+"\n
+(head
+"\n
+(title
+"Test
+)title
+"\n
+(meta
+Acontent text/html; charset=utf-8
+Ahttp-equiv content-type
+)meta
+"\n\n
+)head
+(body
+"\n
+(table
+"\n\t
+(TBODY
+(tr
+"\n\t\t
+(td
+"\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t\n\t\t
+)td
+"\n\t\t
+(td
+"\n\t\t\t
+(a
+Ahref view_download
+"Wird gesucht!
+)a
+"\n\t\t
+)td
+"\n\t
+)tr
+"\n
+)TBODY
+)table
+"\n\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical-html b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical-html
new file mode 100644
index 00000000..8129944f
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical-html
@@ -0,0 +1,22 @@
+
+
Codestin Search App
+
+
+
+	
+		
+			
+			
+			
+			
+			
+			
+			
+			
+		 |
+		
+			Wird gesucht!
+		 |
+	
+
+
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical-sax-cust
new file mode 100644
index 00000000..8eb081bb
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical-sax-cust
@@ -0,0 +1,68 @@
+!html
+p-//W3C//DTD XHTML 1.0 Transitional//EN
+shttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
+(html
+A{http://www.w3.org/2000/xmlns/}xmlns http://www.w3.org/1999/xhtml
+(head
+"\n
+(title
+"Test
+)title
+"\n
+(meta
+Acontent text/html; charset=utf-8
+Ahttp-equiv content-type
+)meta
+"\n
+)head
+(body
+"\n
+(table
+"\n\t
+(TBODY
+(tr
+"\n\t\t
+(td
+"\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t
+x)a
+"\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t
+x)a
+"\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t
+x)a
+"\n\t\t\t
+(a
+Ahref
+)a
+"\n\t\t\t
+x)a
+"\n\t\t
+)td
+"\n\t\t
+(td
+"\n\t\t\t
+(a
+Ahref view_download
+"Wird gesucht!
+)a
+"\n\t\t
+)td
+"\n\t
+)tr
+"\n
+)TBODY
+)table
+"\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical-xni b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical-xni
new file mode 100644
index 00000000..4c108937
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/misc/test-superfluous-complex4.html.canonical-xni
@@ -0,0 +1,78 @@
+startDocument [(1,1,0) (1,1,0) false]
+doctypeDecl [(1,1,0) (1,122,121) false]
+startElement (prefix="",localpart="html",rawname="html",uri="http://www.w3.org/1999/xhtml") [(2,1,122) (2,44,165) false]
+startElement (prefix="",localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml") [(3,1,166) (3,7,172) false]
+characters '
+'[(3,7,172) (4,1,173) false]
+startElement (prefix="",localpart="title",rawname="title",uri="http://www.w3.org/1999/xhtml") [(4,1,173) (4,8,180) false]
+characters 'Test'[(4,8,180) (4,12,184) false]
+endElement (prefix="",localpart="title",rawname="title",uri="http://www.w3.org/1999/xhtml") [(4,12,184) (4,20,192) false]
+characters '
+'[(4,20,192) (5,1,193) false]
+emptyElement (prefix="",localpart="meta",rawname="meta",uri="http://www.w3.org/1999/xhtml") [(5,1,193) (5,70,262) false]
+characters '
+'[(5,70,262) (6,1,263) false]
+endElement (prefix="",localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml") [(6,1,263) (6,8,270) false]
+startElement (prefix="",localpart="body",rawname="body",uri="http://www.w3.org/1999/xhtml") [(7,1,271) (7,7,277) false]
+characters '
+'[(7,7,277) (8,1,278) false]
+startElement (prefix="",localpart="table",rawname="table",uri="http://www.w3.org/1999/xhtml") [(8,1,278) (8,8,285) false]
+characters '
+ '[(8,8,285) (9,2,287) false]
+startElement (localpart="TBODY",rawname="TBODY",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
+startElement (prefix="",localpart="tr",rawname="tr",uri="http://www.w3.org/1999/xhtml") [(9,2,287) (9,6,291) false]
+characters '
+ '[(9,6,291) (10,3,294) false]
+startElement (prefix="",localpart="td",rawname="td",uri="http://www.w3.org/1999/xhtml") [(10,3,294) (10,7,298) false]
+characters '
+ '[(10,7,298) (11,4,302) false]
+startElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(11,4,302) (11,15,313) false]
+endElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(11,15,313) (11,19,317) false]
+characters '
+ '[(11,19,317) (12,4,321) false]
+characters '
+ '[(12,8,325) (13,4,329) false]
+startElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(13,4,329) (13,15,340) false]
+endElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(13,15,340) (13,19,344) false]
+characters '
+ '[(13,19,344) (14,4,348) false]
+characters '
+ '[(14,8,352) (15,4,356) false]
+startElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(15,4,356) (15,15,367) false]
+endElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(15,15,367) (15,19,371) false]
+characters '
+ '[(15,19,371) (16,4,375) false]
+characters '
+ '[(16,8,379) (17,4,383) false]
+startElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(17,4,383) (17,15,394) false]
+endElement (prefix="",localpart="a",rawname="a",uri="http://www.w3.org/1999/xhtml") [(17,15,394) (17,19,398) false]
+characters '
+ '[(17,19,398) (18,4,402) false]
+characters '
+ '[(18,8,406) (19,3,409) false]
+endElement (prefix="",localpart="td",rawname="td",uri="http://www.w3.org/1999/xhtml") [(19,3,409) (19,8,414) false]
+characters '
+ '[(19,8,414) (20,3,417) false]
+startElement (localpart="td",rawname="td") [(20,3,417) (20,7,421) false]
+characters '
+ '[(20,7,421) (21,4,425) false]
+startElement (localpart="a",rawname="a") [(21,4,425) (21,28,449) false]
+characters 'Wird gesucht!'[(21,28,449) (21,41,462) false]
+endElement (localpart="a",rawname="a") [(21,41,462) (21,45,466) false]
+characters '
+ '[(21,45,466) (22,3,469) false]
+endElement (localpart="td",rawname="td") [(22,3,469) (22,8,474) false]
+characters '
+ '[(22,8,474) (23,2,476) false]
+endElement (prefix="",localpart="tr",rawname="tr",uri="http://www.w3.org/1999/xhtml") [(23,2,476) (23,7,481) false]
+characters '
+'[(23,7,481) (24,1,482) false]
+endElement (localpart="TBODY",rawname="TBODY",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
+endElement (prefix="",localpart="table",rawname="table",uri="http://www.w3.org/1999/xhtml") [(24,1,482) (24,9,490) false]
+characters '
+'[(24,9,490) (25,1,491) false]
+characters '
+'[(26,8,506) (27,1,507) false]
+endElement (prefix="",localpart="body",rawname="body",uri="http://www.w3.org/1999/xhtml") [(25,1,491) (25,8,498) false]
+endElement (prefix="",localpart="html",rawname="html",uri="http://www.w3.org/1999/xhtml") [(26,1,499) (26,8,506) false]
+endDocument [(27,1,507) (27,1,507) false]
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/nobr/test-nobr_closes_nobr.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/nobr/test-nobr_closes_nobr.html.canonical-sax-cust
new file mode 100644
index 00000000..d2b4e7b5
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/nobr/test-nobr_closes_nobr.html.canonical-sax-cust
@@ -0,0 +1,13 @@
+(HTML
+(head
+)head
+(BODY
+(nobr
+"hello
+)nobr
+(nobr
+"world
+)nobr
+x)nobr
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/noembed/test-noembed-noembed.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/noembed/test-noembed-noembed.html.canonical-sax-cust
new file mode 100644
index 00000000..6f9b8dc8
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/noembed/test-noembed-noembed.html.canonical-sax-cust
@@ -0,0 +1,10 @@
+(HTML
+(head
+)head
+(BODY
+(noembed
+"
+)noembed
+x)noembed
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/normalize-attrs/test061.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/normalize-attrs/test061.html.canonical-sax-cust
new file mode 100644
index 00000000..4cd435e4
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/normalize-attrs/test061.html.canonical-sax-cust
@@ -0,0 +1,23 @@
+(html
+(HEAD
+(meta
+Acontent no-cache
+Ahttp-equiv Pragma
+)meta
+"\n
+x(head
+"\n
+(title
+"Title
+)title
+"\n
+(meta
+Acontent text/html; charset=iso-8859-1
+Ahttp-equiv Content-Type
+)meta
+"\n
+)HEAD
+(body
+"\n
+)body
+)html
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/parse-noscript-content-false/test-noscript-close-inside-attribute.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/parse-noscript-content-false/test-noscript-close-inside-attribute.html.canonical-sax-cust
new file mode 100644
index 00000000..0f818c4e
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/parse-noscript-content-false/test-noscript-close-inside-attribute.html.canonical-sax-cust
@@ -0,0 +1,13 @@
+(HTML
+(head
+)head
+(BODY
+(div
+(noscript
+"
+x)noscript
+)div
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/parse-noscript-content-false/test-noscript-close-inside-comment.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/parse-noscript-content-false/test-noscript-close-inside-comment.html.canonical-sax-cust
new file mode 100644
index 00000000..0113ee8d
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/parse-noscript-content-false/test-noscript-close-inside-comment.html.canonical-sax-cust
@@ -0,0 +1,13 @@
+(HTML
+(head
+)head
+(BODY
+(div
+(noscript
+"
+x)noscript
+)div
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/parse-noscript-content-false/test-noscript-close-inside-comment2.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/parse-noscript-content-false/test-noscript-close-inside-comment2.html.canonical-sax-cust
new file mode 100644
index 00000000..0113ee8d
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/parse-noscript-content-false/test-noscript-close-inside-comment2.html.canonical-sax-cust
@@ -0,0 +1,13 @@
+(HTML
+(head
+)head
+(BODY
+(div
+(noscript
+"
+x)noscript
+)div
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/test-noscript.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/test-noscript.html.canonical-sax-cust
new file mode 100644
index 00000000..fb5df51a
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/test-noscript.html.canonical-sax-cust
@@ -0,0 +1,15 @@
+(HTML
+(HEAD
+(noscript
+)noscript
+)HEAD
+(BODY
+(div
+"hello
+(span
+"world
+)span
+x)noscript
+)div
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/test-script-and-noscript.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/test-script-and-noscript.html.canonical-sax-cust
new file mode 100644
index 00000000..724ecde0
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/noscript/test-script-and-noscript.html.canonical-sax-cust
@@ -0,0 +1,13 @@
+(HTML
+(HEAD
+(script
+)script
+(noscript
+)noscript
+)HEAD
+(BODY
+(div
+x)noscript
+)div
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/plain-attr-values/test-attr-plain-normalize.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/plain-attr-values/test-attr-plain-normalize.html.canonical-sax-cust
new file mode 100644
index 00000000..eb3c44f6
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/plain-attr-values/test-attr-plain-normalize.html.canonical-sax-cust
@@ -0,0 +1,46 @@
+(HTML
+(head
+)head
+(BODY
+(div
+Aa abcd
+)div
+"\n
+(div
+Aa abcd
+)div
+"\n
+(div
+Aa abcd
+)div
+"\n
+(div
+Aa abcd
+)div
+"\n
+(div
+Aa abcd
+)div
+"\n
+(div
+Aa ab cd
+)div
+"\n
+(div
+Aa ab cd
+)div
+"\n
+(div
+Aa ab c d
+)div
+"\n\n
+(div
+Aa <
+)div
+"\n
+(div
+Aa < >
+)div
+"\n
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/plain-attr-values/test-attr-plain.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/plain-attr-values/test-attr-plain.html.canonical-sax-cust
new file mode 100644
index 00000000..c8a22b35
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/plain-attr-values/test-attr-plain.html.canonical-sax-cust
@@ -0,0 +1,73 @@
+(HTML
+(head
+)head
+(BODY
+(div
+Aa abcd
+)div
+"\n
+(div
+Aa <
+)div
+"\n
+(div
+Aa *
+)div
+"\n
+(div
+Aa B
+)div
+"\n
+(div
+Aa BCDEF
+)div
+"\n
+(div
+Aa aB
+)div
+"\n
+(div
+Aa B
+)div
+"\n
+(div
+Aa B
+)div
+"\n
+(div
+Aa
+)div
+"\n
+(div
+Aa B abc
+)div
+"\n
+(div
+Aa Ü
+)div
+"\n
+(div
+Aa Üabc
+)div
+"\n
+(div
+Aa Ü abc
+)div
+"\n
+(div
+Aa Ü=abc
+)div
+"\n
+(div
+Aa Ü
+)div
+"\n
+(div
+Aa Üabc
+)div
+"\n
+(div
+Aa &abc;abc
+)div
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/plain-attr-values/test-not-quoted-attr-plain-normalize.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/plain-attr-values/test-not-quoted-attr-plain-normalize.html.canonical-sax-cust
new file mode 100644
index 00000000..0679bedb
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/plain-attr-values/test-not-quoted-attr-plain-normalize.html.canonical-sax-cust
@@ -0,0 +1,51 @@
+(HTML
+(head
+)head
+(BODY
+(div
+Aa abcd
+)div
+"\n
+(div
+Aa abcd
+)div
+"\n
+(div
+Aa abcd
+)div
+"\n
+(div
+Aa abcd
+)div
+"\n
+(div
+Aa abcd
+)div
+"\n
+(div
+Aa ab
+Acd
+)div
+"\n
+(div
+Aa ab
+Acd
+)div
+"\n
+(div
+Aa ab
+Ac
+Ad
+)div
+"\n\n
+(div
+Aa <
+)div
+"\n
+(div
+A>
+Aa <
+)div
+"\n
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/plain-attr-values/test-not-quoted-attr-plain.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/plain-attr-values/test-not-quoted-attr-plain.html.canonical-sax-cust
new file mode 100644
index 00000000..62244ed5
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/plain-attr-values/test-not-quoted-attr-plain.html.canonical-sax-cust
@@ -0,0 +1,79 @@
+(HTML
+(head
+)head
+(BODY
+(div
+Aa abcd
+)div
+"\n
+(div
+Aa <
+)div
+"\n
+(div
+Aa *
+)div
+"\n
+(div
+Aa B
+)div
+"\n
+(div
+Aa BCDEF
+)div
+"\n
+(div
+Aa aB
+)div
+"\n
+(div
+Aa B
+)div
+"\n
+(div
+Aa B
+)div
+"\n
+(div
+Aa
+)div
+"\n
+(div
+Aa B
+Aabc
+)div
+"\n
+(div
+Aa Ü
+)div
+"\n
+(div
+Aa Üabc
+)div
+"\n
+(div
+Aa Ü
+Aabc'
+)div
+"\n
+(div
+Aa Ü
+)div
+"\n
+(div
+Aa Üabc
+)div
+"\n
+(div
+Aa &abc;abc
+)div
+"\n\n
+(div
+Aa
+)div
+"\n
+(div
+Aa
+)div
+)BODY
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/script/test-script-before-html.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/script/test-script-before-html.html.canonical-sax-cust
new file mode 100644
index 00000000..820af377
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/script/test-script-before-html.html.canonical-sax-cust
@@ -0,0 +1,11 @@
+(HTML
+(HEAD
+(script
+"var i = 7;
+)script
+x(html
+)HEAD
+(body
+"x
+)body
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/script/test-script-comment-close-tag-in-code.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/script/test-script-comment-close-tag-in-code.html.canonical-sax-cust
new file mode 100644
index 00000000..900bd084
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/script/test-script-comment-close-tag-in-code.html.canonical-sax-cust
@@ -0,0 +1,14 @@
+(HTML
+(head
+)head
+(body
+(script
+"
+x)script
+"abc
+)body
+)HTML
diff --git a/src/test/resources/org/htmlunit/cyberneko/testfiles/script/test-script-in-script.html.canonical-sax-cust b/src/test/resources/org/htmlunit/cyberneko/testfiles/script/test-script-in-script.html.canonical-sax-cust
new file mode 100644
index 00000000..227d2a9c
--- /dev/null
+++ b/src/test/resources/org/htmlunit/cyberneko/testfiles/script/test-script-in-script.html.canonical-sax-cust
@@ -0,0 +1,11 @@
+(HTML
+(head
+(script
+"outer