Skip to content

Commit

Permalink
[test] add tests with QName options
Browse files Browse the repository at this point in the history
eXist-db specific extensions to serialization options can also be set using the
QName instead of plain strings.
Add one test per option using the non-default value.
  • Loading branch information
line-o committed Mar 20, 2023
1 parent 5a7e87f commit 65ad971
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions exist-core/src/test/xquery/xquery3/serialize.xql
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,13 @@ function ser:exist-output-doctype-true() {
map { "exist:output-doctype": true() })
};

declare
%test:assertXPath("contains($result, '-//OASIS//DTD DITA BookMap//EN') and contains($result, 'bookmap.dtd')")
function ser:exist-output-doctype-true-QName() {
serialize(doc($ser:collection || "/test-with-doctype.xml"),
map { xs:QName("exist:output-doctype"): true() })
};

declare
%test:assertXPath("not(contains($result, '-//OASIS//DTD DITA BookMap//EN')) and not(contains($result, 'bookmap.dtd'))")
function ser:exist-output-doctype-false() {
Expand All @@ -692,13 +699,27 @@ function ser:exist-expand-xinclude-true() {
map { "exist:expand-xincludes": true() })
};

declare
%test:assertXPath("contains($result, 'comment')")
function ser:exist-expand-xinclude-true-QName() {
serialize($ser:xi-doc,
map { xs:QName("exist:expand-xincludes"): true() })
};

declare
%test:assertEquals('<?pi?><elem xmlns:exist="http://exist.sourceforge.net/NS/exist" exist:id="2" exist:source="test.xml" a="abc"><!--comment--><b exist:id="2.3">123</b></elem>')
function ser:exist-add-exist-id-all() {
serialize(doc($ser:collection || "/test.xml"),
map { "exist:add-exist-id": "all" })
};

declare
%test:assertEquals('<?pi?><elem xmlns:exist="http://exist.sourceforge.net/NS/exist" exist:id="2" exist:source="test.xml" a="abc"><!--comment--><b exist:id="2.3">123</b></elem>')
function ser:exist-add-exist-id-all-QName() {
serialize(doc($ser:collection || "/test.xml"),
map { xs:QName("exist:add-exist-id"): "all" })
};

declare
%test:assertEquals('<?pi?><elem xmlns:exist="http://exist.sourceforge.net/NS/exist" exist:id="2" exist:source="test.xml" a="abc"><!--comment--><b>123</b></elem>')
function ser:exist-add-exist-id-element() {
Expand Down Expand Up @@ -729,13 +750,36 @@ function ser:exist-jsonp() {
)
};

declare
%test:assertEquals('functionName({"author":["John Doe","Robert Smith"]})')
function ser:exist-jsonp-QName() {
serialize(
<book>
<author>John Doe</author>
<author>Robert Smith</author>
</book>,
map {
"method": "json",
"media-type": "application/json",
xs:QName("exist:jsonp"): "functionName"
}
)
};

declare
%test:assertEquals('processed')
function ser:exist-process-xsl-pi-true() {
serialize(doc($ser:collection || "/test-xsl.xml"),
map { "exist:process-xsl-pi": true() })
};

declare
%test:assertEquals('processed')
function ser:exist-process-xsl-pi-true-QName() {
serialize(doc($ser:collection || "/test-xsl.xml"),
map { xs:QName("exist:process-xsl-pi"): true() })
};

declare
%test:assertXPath("contains($result, 'stylesheet')")
function ser:exist-process-xsl-pi-false() {
Expand Down

0 comments on commit 65ad971

Please sign in to comment.