Skip to content

Commit 936a796

Browse files
committed
[feature] Add missing exist:output-doctype option to fn:serialize
1 parent d355d5c commit 936a796

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

exist-core/src/main/java/org/exist/xquery/util/SerializerUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ public Sequence getDefaultValue() {
185185
* for Exist xquery specific functions
186186
*/
187187
public enum ExistParameterConvention implements ParameterConvention<QName> {
188+
OUTPUT_DOCTYPE(EXistOutputKeys.OUTPUT_DOCTYPE, Type.BOOLEAN, Cardinality.ZERO_OR_ONE, BooleanValue.FALSE),
188189
EXPAND_XINCLUDE(EXistOutputKeys.EXPAND_XINCLUDES, Type.BOOLEAN, Cardinality.ZERO_OR_ONE, BooleanValue.TRUE),
189190
PROCESS_XSL_PI(EXistOutputKeys.PROCESS_XSL_PI, Type.BOOLEAN, Cardinality.ZERO_OR_ONE, BooleanValue.TRUE),
190191
JSON_IGNORE_WHITE_SPACE_TEXT_NODES(EXistOutputKeys.JSON_IGNORE_WHITESPACE_TEXT_NODES, Type.BOOLEAN, Cardinality.ZERO_OR_ONE, BooleanValue.TRUE),

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ declare variable $ser:test-xml := document {
132132
<elem a="abc"><!--comment--><b>123</b></elem>
133133
};
134134

135+
declare variable $ser:test-xml-with-doctype := '<!DOCTYPE bookmap PUBLIC "-//OASIS//DTD DITA BookMap//EN" "bookmap.dtd"><bookmap id="bookmap-1"/>';
136+
135137
declare variable $ser:collection-name := "serialization-test";
136138

137139
declare variable $ser:collection := "/db/" || $ser:collection-name;
@@ -142,7 +144,8 @@ function ser:setup() {
142144
xmldb:create-collection("/db", $ser:collection-name),
143145
xmldb:store($ser:collection, "test.xml", $ser:test-xml),
144146
xmldb:store($ser:collection, "test-xsl.xml", $ser:test-xsl),
145-
xmldb:store($ser:collection, "test.xsl", $ser:xsl)
147+
xmldb:store($ser:collection, "test.xsl", $ser:xsl),
148+
xmldb:store($ser:collection, "test-with-doctype.xml", $ser:test-xml-with-doctype)
146149
};
147150

148151
declare
@@ -701,6 +704,22 @@ function ser:adaptive-xs-strings-map-params() {
701704
ser:adaptive-map-params($input, ",")
702705
};
703706

707+
declare
708+
%test:assertXPath("contains($result, '-//OASIS//DTD DITA BookMap//EN') and contains($result, 'bookmap.dtd')")
709+
function ser:exist-output-doctype-true() {
710+
let $doc := doc($ser:collection || "/test-with-doctype.xml")
711+
return
712+
fn:serialize($doc, map { xs:QName("exist:output-doctype"): fn:true() })
713+
};
714+
715+
declare
716+
%test:assertXPath("not(contains($result, '-//OASIS//DTD DITA BookMap//EN')) and not(contains($result, 'bookmap.dtd'))")
717+
function ser:exist-output-doctype-false() {
718+
let $doc := doc($ser:collection || "/test-with-doctype.xml")
719+
return
720+
fn:serialize($doc, map { xs:QName("exist:output-doctype"): fn:false() })
721+
};
722+
704723
declare
705724
%test:assertXPath("contains($result, 'include')")
706725
function ser:exist-expand-xinclude-false() {

0 commit comments

Comments
 (0)