diff --git a/exist-core/src/main/java/org/exist/client/InteractiveClient.java b/exist-core/src/main/java/org/exist/client/InteractiveClient.java index cea242b147a..08e306233b9 100644 --- a/exist-core/src/main/java/org/exist/client/InteractiveClient.java +++ b/exist-core/src/main/java/org/exist/client/InteractiveClient.java @@ -92,7 +92,6 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static java.time.ZoneOffset.UTC; import static javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION; -import static org.exist.storage.serializers.EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION; import static org.exist.storage.serializers.EXistOutputKeys.OUTPUT_DOCTYPE; import static org.xmldb.api.base.ResourceType.XML_RESOURCE; @@ -150,7 +149,6 @@ public class InteractiveClient { DEFAULT_PROPERTIES.setProperty(EDITOR, EDIT_CMD); DEFAULT_PROPERTIES.setProperty(INDENT, "true"); DEFAULT_PROPERTIES.setProperty(OMIT_XML_DECLARATION, "no"); - DEFAULT_PROPERTIES.setProperty(OMIT_ORIGINAL_XML_DECLARATION, "no"); DEFAULT_PROPERTIES.setProperty(OUTPUT_DOCTYPE, "true"); DEFAULT_PROPERTIES.setProperty(ENCODING, ENCODING_DEFAULT.name()); DEFAULT_PROPERTIES.setProperty(COLORS, "false"); diff --git a/exist-core/src/main/java/org/exist/http/RESTServer.java b/exist-core/src/main/java/org/exist/http/RESTServer.java index 0d2164f8d9f..d9ccad2894d 100644 --- a/exist-core/src/main/java/org/exist/http/RESTServer.java +++ b/exist-core/src/main/java/org/exist/http/RESTServer.java @@ -128,7 +128,6 @@ public class RESTServer { public final static Properties defaultOutputKeysProperties = new Properties(); static { - defaultOutputKeysProperties.setProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, "no"); defaultOutputKeysProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); defaultOutputKeysProperties.setProperty(OutputKeys.INDENT, "yes"); defaultOutputKeysProperties.setProperty(OutputKeys.MEDIA_TYPE, @@ -368,14 +367,6 @@ public void doGet(final DBBroker broker, final Txn transaction, final HttpServle final String omitXmlDeclaration = broker.getConfiguration().getProperty(Serializer.PROPERTY_OMIT_XML_DECLARATION, "yes"); outputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, omitXmlDeclaration); } - if ((option = getParameter(request, Omit_Original_Xml_Declaration)) != null) { - // take user query-string specified omit-original-xml-declaration setting - outputProperties.setProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, option); - } else { - // set omit-original-xml-declaration by configuration - final String omitOriginalXmlDeclaration = broker.getConfiguration().getProperty(Serializer.PROPERTY_OMIT_ORIGINAL_XML_DECLARATION, "no"); - outputProperties.setProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, omitOriginalXmlDeclaration); - } if ((option = getParameter(request, Source)) != null && !safeMode) { source = "yes".equals(option); } @@ -498,10 +489,9 @@ public void doGet(final DBBroker broker, final Txn transaction, final HttpServle // found an XQuery or XProc resource, fixup request values final String pathInfo = pathUri.trimFromBeginning(servletPath).toString(); - // reset any output-doctype, omit-xml-declaration, or omit-original-xml-declaration properties, as these can conflict with others set via XQuery Serialization settings + // reset any output-doctype, or omit-xml-declaration properties, as these can conflict with others set via XQuery Serialization settings outputProperties.setProperty(EXistOutputKeys.OUTPUT_DOCTYPE, "no"); outputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - outputProperties.setProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, "yes"); // Should we display the source of the XQuery or XProc or execute it final Descriptor descriptor = Descriptor.getDescriptorSingleton(); diff --git a/exist-core/src/main/java/org/exist/http/RESTServerParameter.java b/exist-core/src/main/java/org/exist/http/RESTServerParameter.java index 0cf607c1f05..8ff153e1e90 100644 --- a/exist-core/src/main/java/org/exist/http/RESTServerParameter.java +++ b/exist-core/src/main/java/org/exist/http/RESTServerParameter.java @@ -368,18 +368,7 @@ enum RESTServerParameter { * * The value of the parameter should be either "yes" or "no". */ - Omit_Xml_Declaration, - - /** - * Can be used in the Query String of a GET request - * to indicate that the original persisted XML Declaration of an XML document should not - * be serialized if present. - * - * Contexts: GET - * - * The value of the parameter should be either "yes" or "no". - */ - Omit_Original_Xml_Declaration; + Omit_Xml_Declaration; /** * Get the parameter key that is diff --git a/exist-core/src/main/java/org/exist/storage/serializers/EXistOutputKeys.java b/exist-core/src/main/java/org/exist/storage/serializers/EXistOutputKeys.java index ca85a06f5fe..8ba955bb7b1 100644 --- a/exist-core/src/main/java/org/exist/storage/serializers/EXistOutputKeys.java +++ b/exist-core/src/main/java/org/exist/storage/serializers/EXistOutputKeys.java @@ -28,7 +28,6 @@ public class EXistOutputKeys { */ public static final String ITEM_SEPARATOR = "item-separator"; - public static final String OMIT_ORIGINAL_XML_DECLARATION = "omit-original-xml-declaration"; public static final String OUTPUT_DOCTYPE = "output-doctype"; diff --git a/exist-core/src/main/java/org/exist/storage/serializers/NativeSerializer.java b/exist-core/src/main/java/org/exist/storage/serializers/NativeSerializer.java index 59b0ec15dac..deaf7355477 100644 --- a/exist-core/src/main/java/org/exist/storage/serializers/NativeSerializer.java +++ b/exist-core/src/main/java/org/exist/storage/serializers/NativeSerializer.java @@ -44,6 +44,7 @@ import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import javax.xml.transform.OutputKeys; import java.io.IOException; import java.util.Iterator; import java.util.List; @@ -118,7 +119,7 @@ protected void serializeToReceiver(DocumentImpl doc, boolean generateDocEvent) t } if (doc.getXmlDeclaration() != null){ - if ("no".equals(getProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, "no"))) { + if ("no".equals(getProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"))) { final XMLDeclarationImpl xmlDecl = doc.getXmlDeclaration(); receiver.declaration(xmlDecl.getVersion(), xmlDecl.getEncoding(), xmlDecl.getStandalone()); } diff --git a/exist-core/src/main/java/org/exist/storage/serializers/Serializer.java b/exist-core/src/main/java/org/exist/storage/serializers/Serializer.java index e2f2166443b..ae3f4949fb4 100644 --- a/exist-core/src/main/java/org/exist/storage/serializers/Serializer.java +++ b/exist-core/src/main/java/org/exist/storage/serializers/Serializer.java @@ -109,8 +109,6 @@ public abstract class Serializer implements XMLReader { public static final String CONFIGURATION_ELEMENT_NAME = "serializer"; public static final String OMIT_XML_DECLARATION_ATTRIBUTE = "omit-xml-declaration"; public static final String PROPERTY_OMIT_XML_DECLARATION = "serialization.omit-xml-declaration"; - public static final String OMIT_ORIGINAL_XML_DECLARATION_ATTRIBUTE = "omit-original-xml-declaration"; - public static final String PROPERTY_OMIT_ORIGINAL_XML_DECLARATION = "serialization.omit-original-xml-declaration"; public static final String OUTPUT_DOCTYPE_ATTRIBUTE = "output-doctype"; public static final String PROPERTY_OUTPUT_DOCTYPE = "serialization.output-doctype"; public static final String ENABLE_XINCLUDE_ATTRIBUTE = "enable-xinclude"; @@ -209,9 +207,16 @@ public Serializer(final DBBroker broker, final Configuration config, final List< this.customMatchListeners = new CustomMatchListenerFactory(broker, config, chainOfReceivers); this.receiver = xinclude; - defaultOutputProperties.setProperty(EXistOutputKeys.PROCESS_XSL_PI, config.getProperty(PROPERTY_ENABLE_XSL, "no")); - @Nullable String option = null; + if ((option = (String) config.getProperty(PROPERTY_ENABLE_XSL)) != null) { + defaultOutputProperties.setProperty(EXistOutputKeys.PROCESS_XSL_PI, option); + } + + if ((option = (String) config.getProperty(PROPERTY_OMIT_XML_DECLARATION)) != null) { + defaultOutputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, option); + } else if ((option = (String) config.getProperty(OMIT_XML_DECLARATION_ATTRIBUTE)) != null) { + defaultOutputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, option); + } if ((option = (String) config.getProperty(PROPERTY_ENABLE_XINCLUDE)) != null) { defaultOutputProperties.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, option); diff --git a/exist-core/src/main/java/org/exist/util/Configuration.java b/exist-core/src/main/java/org/exist/util/Configuration.java index 81f776dbaf8..9fe57c6dc0d 100644 --- a/exist-core/src/main/java/org/exist/util/Configuration.java +++ b/exist-core/src/main/java/org/exist/util/Configuration.java @@ -172,7 +172,6 @@ import static org.exist.storage.serializers.Serializer.ENABLE_XINCLUDE_ATTRIBUTE; import static org.exist.storage.serializers.Serializer.ENABLE_XSL_ATTRIBUTE; import static org.exist.storage.serializers.Serializer.INDENT_ATTRIBUTE; -import static org.exist.storage.serializers.Serializer.OMIT_ORIGINAL_XML_DECLARATION_ATTRIBUTE; import static org.exist.storage.serializers.Serializer.OMIT_XML_DECLARATION_ATTRIBUTE; import static org.exist.storage.serializers.Serializer.OUTPUT_DOCTYPE_ATTRIBUTE; import static org.exist.storage.serializers.Serializer.PROPERTY_ADD_EXIST_ID; @@ -180,7 +179,6 @@ import static org.exist.storage.serializers.Serializer.PROPERTY_ENABLE_XINCLUDE; import static org.exist.storage.serializers.Serializer.PROPERTY_ENABLE_XSL; import static org.exist.storage.serializers.Serializer.PROPERTY_INDENT; -import static org.exist.storage.serializers.Serializer.PROPERTY_OMIT_ORIGINAL_XML_DECLARATION; import static org.exist.storage.serializers.Serializer.PROPERTY_OMIT_XML_DECLARATION; import static org.exist.storage.serializers.Serializer.PROPERTY_OUTPUT_DOCTYPE; import static org.exist.storage.serializers.Serializer.PROPERTY_TAG_MATCHING_ATTRIBUTES; @@ -757,7 +755,6 @@ private void configureHtmlToXmlParser(final Element parser) throws DatabaseConfi */ private void configureSerializer(final Element serializer) { configureProperty(serializer, OMIT_XML_DECLARATION_ATTRIBUTE, PROPERTY_OMIT_XML_DECLARATION); - configureProperty(serializer, OMIT_ORIGINAL_XML_DECLARATION_ATTRIBUTE, PROPERTY_OMIT_ORIGINAL_XML_DECLARATION); configureProperty(serializer, OUTPUT_DOCTYPE_ATTRIBUTE, PROPERTY_OUTPUT_DOCTYPE); configureProperty(serializer, ENABLE_XINCLUDE_ATTRIBUTE, PROPERTY_ENABLE_XINCLUDE); configureProperty(serializer, ENABLE_XSL_ATTRIBUTE, PROPERTY_ENABLE_XSL); diff --git a/exist-core/src/main/java/org/exist/util/serializer/AbstractSerializer.java b/exist-core/src/main/java/org/exist/util/serializer/AbstractSerializer.java index 758ccee130a..0d4dca75613 100644 --- a/exist-core/src/main/java/org/exist/util/serializer/AbstractSerializer.java +++ b/exist-core/src/main/java/org/exist/util/serializer/AbstractSerializer.java @@ -61,7 +61,6 @@ public abstract class AbstractSerializer { protected static final Properties defaultProperties = new Properties(); static { - defaultProperties.setProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, "no"); defaultProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); defaultProperties.setProperty(EXistOutputKeys.XDM_SERIALIZATION, "no"); } diff --git a/exist-core/src/main/java/org/exist/util/serializer/MicroXmlWriter.java b/exist-core/src/main/java/org/exist/util/serializer/MicroXmlWriter.java index 6fbfe1f1530..455ed32039c 100644 --- a/exist-core/src/main/java/org/exist/util/serializer/MicroXmlWriter.java +++ b/exist-core/src/main/java/org/exist/util/serializer/MicroXmlWriter.java @@ -169,7 +169,6 @@ public void characters(final char[] ch, final int start, final int len) throws T @Override public void setOutputProperties(final Properties properties) { - properties.setProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, "yes"); properties.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); super.setOutputProperties(properties); } diff --git a/exist-core/src/main/java/org/exist/util/serializer/XMLWriter.java b/exist-core/src/main/java/org/exist/util/serializer/XMLWriter.java index 763aaf52ef6..b4674dcf912 100644 --- a/exist-core/src/main/java/org/exist/util/serializer/XMLWriter.java +++ b/exist-core/src/main/java/org/exist/util/serializer/XMLWriter.java @@ -48,7 +48,6 @@ public class XMLWriter implements SerializerWriter { protected final static Properties defaultProperties = new Properties(); static { - defaultProperties.setProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, "no"); defaultProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); defaultProperties.setProperty(EXistOutputKeys.XDM_SERIALIZATION, "no"); } @@ -532,26 +531,18 @@ protected void writeDeclaration() throws TransformerException { } declarationWritten = true; - final String omitOriginalXmlDecl = outputProperties.getProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, "yes"); - if (originalXmlDecl != null && "no".equals(omitOriginalXmlDecl)) { + final String omitXmlDecl = outputProperties.getProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + if ("yes".equals(omitXmlDecl)) { + return; + } + + if (originalXmlDecl != null) { // get the fields of the persisted xml declaration, but overridden with any properties from the serialization properties final String version = outputProperties.getProperty(OutputKeys.VERSION, (originalXmlDecl.version != null ? originalXmlDecl.version : DEFAULT_XML_VERSION)); final String encoding = outputProperties.getProperty(OutputKeys.ENCODING, (originalXmlDecl.encoding != null ? originalXmlDecl.encoding : DEFAULT_XML_ENCODING)); @Nullable final String standalone = outputProperties.getProperty(OutputKeys.STANDALONE, originalXmlDecl.standalone); writeDeclaration(version, encoding, standalone); - - return; - } - - final String omitXmlDecl = outputProperties.getProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - if ("no".equals(omitXmlDecl)) { - // get the fields of the declaration from the serialization properties - final String version = outputProperties.getProperty(OutputKeys.VERSION, DEFAULT_XML_VERSION); - final String encoding = outputProperties.getProperty(OutputKeys.ENCODING, DEFAULT_XML_ENCODING); - @Nullable final String standalone = outputProperties.getProperty(OutputKeys.STANDALONE); - - writeDeclaration(version, encoding, standalone); } } diff --git a/exist-core/src/main/java/org/exist/xmldb/LocalCollection.java b/exist-core/src/main/java/org/exist/xmldb/LocalCollection.java index aedf3cf0b12..f0ae6ef82c8 100644 --- a/exist-core/src/main/java/org/exist/xmldb/LocalCollection.java +++ b/exist-core/src/main/java/org/exist/xmldb/LocalCollection.java @@ -94,7 +94,6 @@ public class LocalCollection extends AbstractLocal implements EXistCollection { defaultProperties.setProperty(EXistOutputKeys.PROCESS_XSL_PI, "no"); defaultProperties.setProperty(NORMALIZE_HTML, "no"); defaultProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - defaultProperties.setProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, "no"); defaultProperties.setProperty(EXistOutputKeys.OUTPUT_DOCTYPE, "yes"); } diff --git a/exist-core/src/main/java/org/exist/xmlrpc/RpcConnection.java b/exist-core/src/main/java/org/exist/xmlrpc/RpcConnection.java index 11512c9005f..6228b21a5d6 100644 --- a/exist-core/src/main/java/org/exist/xmlrpc/RpcConnection.java +++ b/exist-core/src/main/java/org/exist/xmlrpc/RpcConnection.java @@ -657,11 +657,6 @@ private void serialize(final DBBroker broker, final Properties properties, final properties.setProperty(OutputKeys.OMIT_XML_DECLARATION, omitXmlDeclaration); } - if (!properties.containsKey(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION)) { - final String omitOriginalXmlDeclaration = broker.getConfiguration().getProperty(Serializer.OMIT_ORIGINAL_XML_DECLARATION_ATTRIBUTE, "no"); - properties.setProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, omitOriginalXmlDeclaration); - } - if (!properties.containsKey(EXistOutputKeys.OUTPUT_DOCTYPE)) { final String outputDocType = broker.getConfiguration().getProperty(Serializer.PROPERTY_OUTPUT_DOCTYPE, "yes"); properties.setProperty(EXistOutputKeys.OUTPUT_DOCTYPE, outputDocType); diff --git a/exist-core/src/test/java/org/exist/backup/XMLDBBackupTest.java b/exist-core/src/test/java/org/exist/backup/XMLDBBackupTest.java index 037f6cde8b3..afae58f6f77 100644 --- a/exist-core/src/test/java/org/exist/backup/XMLDBBackupTest.java +++ b/exist-core/src/test/java/org/exist/backup/XMLDBBackupTest.java @@ -122,8 +122,8 @@ public void backupRestore() throws XMLDBException, SAXException, IOException, UR // NOTE(AR) that org.exist.backup.Backup calls defaultOutputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); // NOTE(AR) that org.exist.backup.SystemExport also calls defaultOutputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); - // TODO(AR) consider whether the backup/export should be injecting a XML Declaration that was not previously present, or should default to EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION - final Source expected = Input.fromString("\n" + doc1Content).build(); + // TODO(JL) export must output a stored (original) XML declaration + final Source expected = Input.fromString(doc1Content).build(); final Source actual = Input.fromString(doc1.getContent().toString()).build(); final Diff diff = DiffBuilder.compare(expected) @@ -139,6 +139,41 @@ public void backupRestore() throws XMLDBException, SAXException, IOException, UR assertEquals(binDoc2Content, new String((byte[])binDoc2.getContent(), UTF_8)); } + @Test + public void backupRestoreWithXmlDecl() throws XMLDBException, SAXException, IOException, URISyntaxException, ParserConfigurationException { + final XmldbURI collectionUri = XmldbURI.create(getBaseUri()).append("/db").append(COLLECTION_NAME); + final String docWithDeclName = "docWithDecl.xml"; + final String docWithDeclContent = "\n"; + + final Collection testCollectionInitial = DatabaseManager.getCollection(collectionUri.toString(), TestUtils.ADMIN_DB_USER, TestUtils.ADMIN_DB_PWD); + final Resource docWithDecl = testCollectionInitial.createResource(docWithDeclName, XMLResource.class); + docWithDecl.setContent(docWithDeclContent); + testCollectionInitial.storeResource(docWithDecl); + + final String backupFilename = "test-xmldb-backup-decl-" + System.currentTimeMillis() + ".zip"; + + // backup the collection + final Path backupFile = backup(backupFilename, collectionUri); + + // delete the collection + deleteCollection(collectionUri); + + // restore the collection + restore(backupFile, XmldbURI.create(getBaseUri()).append("/db")); + + // check restore has restored the collection + final Collection testCollection = DatabaseManager.getCollection(collectionUri.toString(), TestUtils.ADMIN_DB_USER, TestUtils.ADMIN_DB_PWD); + assertNotNull(testCollection); + + final Resource restoredDoc = testCollection.getResource(docWithDeclName); + assertNotNull(restoredDoc); + + // The backup/restore process should preserve the XML declaration because Backup sets OMIT_XML_DECLARATION=no + final String content = restoredDoc.getContent().toString(); + assertTrue("Content should contain XML declaration", content.startsWith("\r\n" + - "\r\n", response); + assertEquals("\r\n", response); } finally { connect.disconnect(); @@ -1434,8 +1433,8 @@ public void getXmlDeclDefault() throws IOException { } @Test - public void getXmlDeclNo() throws IOException { - final HttpURLConnection connect = getConnection(getResourceWithXmlDeclUri() + "?_omit-original-xml-declaration=no"); + public void omitXmlDeclarationNo() throws IOException { + final HttpURLConnection connect = getConnection(getResourceWithXmlDeclUri() + "?_omit-xml-declaration=no"); try { connect.setRequestMethod("GET"); connect.connect(); @@ -1460,8 +1459,8 @@ public void getXmlDeclNo() throws IOException { } @Test - public void getXmlDeclYes() throws IOException { - final HttpURLConnection connect = getConnection(getResourceWithXmlDeclUri() + "?_omit-original-xml-declaration=yes"); + public void omitXmlDeclarationYes() throws IOException { + final HttpURLConnection connect = getConnection(getResourceWithXmlDeclUri() + "?_omit-xml-declaration=yes"); try { connect.setRequestMethod("GET"); connect.connect(); diff --git a/exist-core/src/test/java/org/exist/xmldb/SerializationTest.java b/exist-core/src/test/java/org/exist/xmldb/SerializationTest.java index b4de05229db..901b9ba11e3 100644 --- a/exist-core/src/test/java/org/exist/xmldb/SerializationTest.java +++ b/exist-core/src/test/java/org/exist/xmldb/SerializationTest.java @@ -47,6 +47,7 @@ import java.util.Arrays; +import static javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -211,33 +212,21 @@ public void getDocTypeYes() throws XMLDBException { @Test public void getXmlDeclDefault() throws XMLDBException { final Resource res = testCollection.getResource(TEST_XML_DOC_WITH_XMLDECL_URI.lastSegmentString()); - assertEquals(XML_WITH_XMLDECL, res.getContent()); + assertEquals("", res.getContent()); } @Test - public void getXmlDeclNo() throws XMLDBException { - final String prevOmitOriginalXmlDecl = testCollection.getProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION); + public void getXmlDeclOmit() throws XMLDBException { + final String prevOmitXmlDecl = testCollection.getProperty(OMIT_XML_DECLARATION); try { final Resource res = testCollection.getResource(TEST_XML_DOC_WITH_XMLDECL_URI.lastSegmentString()); - testCollection.setProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, "no"); - assertEquals(XML_WITH_XMLDECL, res.getContent()); - } finally { - if (prevOmitOriginalXmlDecl != null) { - testCollection.setProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, prevOmitOriginalXmlDecl); - } - } - } - - @Test - public void getXmlDeclYes() throws XMLDBException { - final String prevOmitOriginalXmlDecl = testCollection.getProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION); - try { - final Resource res = testCollection.getResource(TEST_XML_DOC_WITH_XMLDECL_URI.lastSegmentString()); - testCollection.setProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, "yes"); + testCollection.setProperty(OMIT_XML_DECLARATION, "yes"); assertEquals("", res.getContent()); } finally { - if (prevOmitOriginalXmlDecl != null) { - testCollection.setProperty(EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION, prevOmitOriginalXmlDecl); + if (prevOmitXmlDecl != null) { + testCollection.setProperty(OMIT_XML_DECLARATION, prevOmitXmlDecl); + } else { + testCollection.setProperty(OMIT_XML_DECLARATION, "no"); } } }