Skip to content

Commit 0023fee

Browse files
committed
[feature] Enable output-doctype by default in APIs
1 parent 2d3ec78 commit 0023fee

File tree

10 files changed

+15
-9
lines changed

10 files changed

+15
-9
lines changed

exist-core/src/main/java/org/exist/http/RESTServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ public void doGet(final DBBroker broker, final Txn transaction, final HttpServle
355355
outputProperties.setProperty(EXistOutputKeys.OUTPUT_DOCTYPE, option);
356356
} else {
357357
// set output-doctype by configuration
358-
final String outputDocType = broker.getConfiguration().getProperty(Serializer.PROPERTY_OUTPUT_DOCTYPE, "no");
358+
final String outputDocType = broker.getConfiguration().getProperty(Serializer.PROPERTY_OUTPUT_DOCTYPE, "yes");
359359
outputProperties.setProperty(EXistOutputKeys.OUTPUT_DOCTYPE, outputDocType);
360360
}
361361
if ((option = getParameter(request, Source)) != null && !safeMode) {

exist-core/src/main/java/org/exist/xmldb/LocalCollection.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public class LocalCollection extends AbstractLocal implements EXistCollection {
8989
defaultProperties.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, "yes");
9090
defaultProperties.setProperty(EXistOutputKeys.PROCESS_XSL_PI, "no");
9191
defaultProperties.setProperty(NORMALIZE_HTML, "no");
92+
defaultProperties.setProperty(EXistOutputKeys.OUTPUT_DOCTYPE, "yes");
9293
}
9394

9495
private final XmldbURI path;

exist-core/src/main/java/org/exist/xmlrpc/RpcConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ private String getDocumentAsString(final XmldbURI docUri, final Map<String, Obje
664664

665665
private void serialize(final DBBroker broker, final Properties properties, final ConsumerE<Serializer, SAXException> toSaxFunction, final Writer writer) throws SAXException, IOException {
666666
if (!properties.containsKey(EXistOutputKeys.OUTPUT_DOCTYPE)) {
667-
final String outputDocType = broker.getConfiguration().getProperty(Serializer.PROPERTY_OUTPUT_DOCTYPE, "no");
667+
final String outputDocType = broker.getConfiguration().getProperty(Serializer.PROPERTY_OUTPUT_DOCTYPE, "yes");
668668
properties.setProperty(EXistOutputKeys.OUTPUT_DOCTYPE, outputDocType);
669669
}
670670

exist-core/src/test/java/org/exist/http/RESTServiceTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,8 @@ public void getDocTypeDefault() throws IOException {
12431243

12441244
final String response = readResponse(connect.getInputStream());
12451245

1246-
assertEquals("<bookmap id=\"bookmap-1\"/>\r\n", response);
1246+
assertEquals("<!DOCTYPE bookmap PUBLIC \"-//OASIS//DTD DITA BookMap//EN\" \"bookmap.dtd\">\r\n" +
1247+
"<bookmap id=\"bookmap-1\"/>\r\n", response);
12471248

12481249
} finally {
12491250
connect.disconnect();

exist-core/src/test/java/org/exist/xmldb/SerializationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public void xqueryUpdateNsTest() throws XMLDBException {
171171
@Test
172172
public void getDocTypeDefault() throws XMLDBException {
173173
final Resource res = testCollection.getResource(TEST_XML_DOC_WITH_DOCTYPE_URI.lastSegmentString());
174-
assertEquals("<bookmap id=\"bookmap-1\"/>", res.getContent());
174+
assertEquals(XML_WITH_DOCTYPE, res.getContent());
175175
}
176176

177177
@Test

exist-core/src/test/resources-filtered/conf.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,10 @@
739739
Remember to add a statement like this to your client code:
740740
service.setProperty("compress-output", "yes");
741741
to uncompress the retrieved result in the client too.
742+
743+
- output-doctype:
744+
should the Doctype Declaration for a document be serialized
745+
if it is present?
742746
743747
- enable-xinclude:
744748
should the database expand XInclude tags by default?
@@ -764,7 +768,7 @@
764768
Set the parameter to "yes" to enable this feature.
765769
766770
-->
767-
<serializer add-exist-id="none" compress-output="no" enable-xinclude="yes"
771+
<serializer add-exist-id="none" compress-output="no" output-doctype="yes" enable-xinclude="yes"
768772
enable-xsl="no" indent="yes" match-tagging-attributes="no"
769773
match-tagging-elements="no">
770774
<!--

exist-distribution/src/main/config/conf.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@
815815
Set the parameter to "yes" to enable this feature.
816816
817817
-->
818-
<serializer add-exist-id="none" compress-output="no" output-doctype="no" enable-xinclude="yes"
818+
<serializer add-exist-id="none" compress-output="no" output-doctype="yes" enable-xinclude="yes"
819819
enable-xsl="no" indent="yes" match-tagging-attributes="no"
820820
match-tagging-elements="no">
821821
<!--

extensions/webdav/src/main/resources/org/exist/webdav/webdav.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828
#process-xsl-pi=no
2929
#encoding=UTF-8
3030
#omit-xml-declaration=no
31-
output-doctype=false
31+
output-doctype=yes

extensions/webdav/src/test/java/org/exist/webdav/SerializationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,6 @@ public void getDocTypeDefault() throws IOException, NotAuthorizedException, BadR
101101
assertEquals("application/xml", ((File) resource).contentType);
102102
final java.io.File tempRetrieveFile = TEMP_FOLDER.newFile();
103103
resource.downloadTo(tempRetrieveFile, null);
104-
assertEquals("<bookmap id=\"bookmap-1\"/>", new String(Files.readAllBytes(tempRetrieveFile.toPath()), UTF_8));
104+
assertEquals(XML_WITH_DOCTYPE, new String(Files.readAllBytes(tempRetrieveFile.toPath()), UTF_8));
105105
}
106106
}

schema/conf.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@
302302
</xs:simpleType>
303303
</xs:attribute>
304304
<xs:attribute name="compress-output" type="yes_no" default="no"/>
305-
<xs:attribute name="output-doctype" type="yes_no" default="no"/>
305+
<xs:attribute name="output-doctype" type="yes_no" default="yes"/>
306306
<xs:attribute name="enable-xinclude" type="yes_no" default="yes"/>
307307
<xs:attribute name="enable-xsl" type="yes_no" default="no"/>
308308
<xs:attribute name="indent" type="yes_no" default="yes"/>

0 commit comments

Comments
 (0)