Skip to content

Commit 0ebf6f2

Browse files
committed
Add basic tests for HTML 5 serialization
See https://www.w3.org/TR/xslt-xquery-serialization-31/#html-output
1 parent 15c478c commit 0ebf6f2

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

exist-core/src/test/xquery/xquery3/serialize.xql

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,3 +865,65 @@ function ser:serialize-xml-134() {
865865
}
866866
return serialize((1 to 4)!text{.}, $params)
867867
};
868+
869+
declare
870+
%test:assertEquals('<!DOCTYPE html> <option selected></option>')
871+
function ser:serialize-html-5-boolean-attribute-names() {
872+
let $params := map {
873+
"method" : "html",
874+
"html-version": 5.0
875+
}
876+
return
877+
<option selected="selected"/>
878+
=> serialize($params)
879+
=> normalize-space()
880+
};
881+
882+
declare
883+
%test:assertEquals('<!DOCTYPE html> <br>')
884+
function ser:serialize-html-5-empty-tags() {
885+
let $params := map {
886+
"method" : "html",
887+
"html-version": 5.0
888+
}
889+
return
890+
<br/>
891+
=> serialize($params)
892+
=> normalize-space()
893+
};
894+
895+
declare
896+
%test:assertEquals('<!DOCTYPE html> <foo><style>ul > li { color:red; }</style><script>if (a < b) foo()</script></foo>')
897+
function ser:serialize-html-5-raw-text-elements() {
898+
let $params := map {
899+
"method" : "html",
900+
"html-version": 5.0
901+
}
902+
return
903+
<foo>
904+
<style>{``[ul > li {
905+
color:red;
906+
}]``}</style>
907+
<script>{``[if (a < b) foo()]``}</script>
908+
</foo>
909+
=> serialize($params)
910+
=> normalize-space()
911+
};
912+
913+
declare
914+
%test:assertEquals('<!DOCTYPE html> <foo><title>ul &amp;gt; li { color:red; }</title><textarea>if (a &amp;lt; b) foo()</textarea></foo>')
915+
function ser:serialize-html-5-needs-escape-elements() {
916+
let $params := map {
917+
"method" : "html",
918+
"html-version": 5.0
919+
}
920+
return
921+
<foo>
922+
<title>{``[ul > li {
923+
color:red;
924+
}]``}</title>
925+
<textarea>{``[if (a < b) foo()]``}</textarea>
926+
</foo>
927+
=> serialize($params)
928+
=> normalize-space()
929+
};

0 commit comments

Comments
 (0)