From bb0b8d16f79f16e14b0f50d7ac585dce10a18d2f Mon Sep 17 00:00:00 2001 From: ndp-opendap Date: Tue, 14 Apr 2026 04:28:31 -0700 Subject: [PATCH 1/6] Patching the dmrVersion business. --- D4ParserSax2.cc | 3 +++ DDS.cc | 6 +++++- DDS.h | 3 +++ DMR.cc | 7 ++++++- DMR.h | 20 ++++++++++++++++++-- 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/D4ParserSax2.cc b/D4ParserSax2.cc index c9b7647f3..9df34327b 100644 --- a/D4ParserSax2.cc +++ b/D4ParserSax2.cc @@ -651,6 +651,9 @@ void D4ParserSax2::dmr_start_element(void *p, const xmlChar *l, const xmlChar *p if (parser->check_attribute("dmrVersion")) parser->dmr()->set_dmr_version(parser->xml_attrs["dmrVersion"].value); + if (parser->check_attribute("dap:serialization")) + parser->dmr()->set_serialization(parser->xml_attrs["dap:serialization"].value); + if (parser->check_attribute("base")) parser->dmr()->set_request_xml_base(parser->xml_attrs["base"].value); diff --git a/DDS.cc b/DDS.cc index 03e58c37b..71426b969 100644 --- a/DDS.cc +++ b/DDS.cc @@ -1257,7 +1257,11 @@ void DDS::print_dmr(ostream &out, bool constrained) { if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"dmrVersion", (const xmlChar *)get_dmr_version().c_str()) < 0) - throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dapVersion"); + throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dmrVersion"); + + if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"dap:serialization", + (const xmlChar *)get_serialization().c_str()) < 0) + throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dap:serialization"); if (!get_request_xml_base().empty()) { if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"xml:base", diff --git a/DDS.h b/DDS.h index 35de784d2..6f7ad95f7 100644 --- a/DDS.h +++ b/DDS.h @@ -286,6 +286,9 @@ class DDS : public DapObj { /** @brief Returns the DAP4 DMR version corresponding to DDS exports. */ string get_dmr_version() const { return "1.0"; } + /** @brief Returns the DAP4 data serialization scheme. */ + string get_serialization() const { return "4.0"; } + /// @deprecated void set_dap_major(int p); /// @deprecated diff --git a/DMR.cc b/DMR.cc index 9337618ac..402b4512b 100644 --- a/DMR.cc +++ b/DMR.cc @@ -68,6 +68,7 @@ void DMR::m_duplicate(const DMR &dmr) { d_dap_version = dmr.d_dap_version; // String version of the protocol d_dmr_version = dmr.d_dmr_version; + d_serialization = dmr.d_serialization; d_request_xml_base = dmr.d_request_xml_base; @@ -332,7 +333,11 @@ void DMR::print_dap4(XMLWriter &xml, bool constrained) { if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"dmrVersion", (const xmlChar *)dmr_version().c_str()) < 0) - throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dapVersion"); + throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dmrVersion"); + + if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"dap:serialization", + (const xmlChar *)serialization().c_str()) < 0) + throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dap:serialization"); if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"name", (const xmlChar *)name().c_str()) < 0) throw InternalErr(__FILE__, __LINE__, "Could not write attribute for name"); diff --git a/DMR.h b/DMR.h index 6464b0daf..1889a0500 100644 --- a/DMR.h +++ b/DMR.h @@ -73,8 +73,15 @@ class DMR : public DapObj { /// The version of the DMR document /// Version 1.0 is the original serialization scheme - Groups were serialized first, /// then the top-level variables. - /// The 2.0 version indicates the DAP4 Serialization bug fix. - std::string d_dmr_version = "2.0"; + std::string d_dmr_version = "1.0"; + + /// The version of the DMR document + /// Version 1.0 is the original serialization scheme - Groups were serialized first, + /// then the top-level variables. + /// When we fixed the DAP4 Serialization bug we added this along + /// with a Dataset xml attribute dap:serialization to express this state. + /// the original patch changed the d_dmr_version to 2.0 - ndp 4/14/26 + std::string d_serialization = "4.0"; /// The URL for the request base std::string d_request_xml_base; @@ -179,6 +186,15 @@ class DMR : public DapObj { */ void set_dmr_version(const std::string &v) { d_dmr_version = v; } + /** @brief Returns the DAP4 serialization that the source service will deliver. */ + std::string serialization() const { return d_serialization; } + + /** + * @brief Sets the DMR document version string. + * @param v DMR version value. + */ + void set_serialization(const std::string &v) { d_serialization = v; } + /// Get the URL that will return this DMR std::string request_xml_base() const { return d_request_xml_base; } From 590fd418b8f5e43c2923e06c3e74521fabc64e75 Mon Sep 17 00:00:00 2001 From: ndp-opendap Date: Tue, 14 Apr 2026 05:15:19 -0700 Subject: [PATCH 2/6] comments --- DMR.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/DMR.h b/DMR.h index 1889a0500..863be0091 100644 --- a/DMR.h +++ b/DMR.h @@ -71,16 +71,15 @@ class DMR : public DapObj { std::string d_dap_version = "4.0"; /// The version of the DMR document - /// Version 1.0 is the original serialization scheme - Groups were serialized first, - /// then the top-level variables. std::string d_dmr_version = "1.0"; - /// The version of the DMR document - /// Version 1.0 is the original serialization scheme - Groups were serialized first, - /// then the top-level variables. - /// When we fixed the DAP4 Serialization bug we added this along - /// with a Dataset xml attribute dap:serialization to express this state. - /// the original patch changed the d_dmr_version to 2.0 - ndp 4/14/26 + /// The version of the DAP4 serialization used to encode the data response values. + /// Prior to adding this indicator variable and its expression in the DMR + /// a non-dap4 compliant serialization scheme, in which Groups were serialized first + /// and then the top-level variables was implemented. + /// We mended this problem with dap4 serialization add added this state + /// variable along with a Dataset xml attribute dap:serialization to express this state. + /// The original patch changed the d_dmr_version to 2.0 - ndp 4/14/26 std::string d_serialization = "4.0"; /// The URL for the request base From 112904d2777b7fb77a182db5d5694771d56819ca Mon Sep 17 00:00:00 2001 From: ndp-opendap Date: Wed, 15 Apr 2026 08:12:53 -0700 Subject: [PATCH 3/6] Checkpoint before separating concerns --- DDS.cc | 10 ++++++---- DDS.h | 2 +- DMR.cc | 12 ++++++++---- DMR.h | 3 ++- getdap4.cc | 2 +- tests/D4ResponseBuilder.cc | 2 +- tests/DMRTest.at | 2 +- unit-tests/DMRTest.cc | 11 ++++++++--- unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.dmr | 2 +- .../dmr-rt-testsuite/3B42.980909.5.HDF.full.dmr | 2 +- .../3B42.980909.5.hacked.2.HDF.attr.dmr | 2 +- unit-tests/dmr-rt-testsuite/S2000415.HDF.dmr | 2 +- unit-tests/dmr-rt-testsuite/S2000415.HDF.full.dmr | 2 +- unit-tests/dmr-rt-testsuite/attr_test_00.dmr | 2 +- unit-tests/dmr-rt-testsuite/attr_test_01.dmr | 2 +- unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr | 2 +- .../dmr-rt-testsuite/coads_climatology.nc.dmr.xml | 2 +- .../dmr-rt-testsuite/coads_climatology.nc.full.dmr | 2 +- unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr | 2 +- unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr.xml | 2 +- unit-tests/dmr-rt-testsuite/test.1.attr.dmr | 2 +- unit-tests/dmr-rt-testsuite/test.1.dmr | 2 +- unit-tests/dmr-rt-testsuite/test.1.full.dmr | 2 +- .../dmr-rt-testsuite/unused/coads_climatology.nc.dmr | 2 +- unit-tests/dmr-testsuite/3B42.980909.5.HDF.dmr | 2 +- unit-tests/dmr-testsuite/3B42.980909.5.HDF.full.dmr | 2 +- .../3B42.980909.5.hacked.2.HDF.attr.dmr | 2 +- unit-tests/dmr-testsuite/S2000415.HDF.dmr | 2 +- unit-tests/dmr-testsuite/S2000415.HDF.full.dmr | 2 +- unit-tests/dmr-testsuite/coads_climatology.nc.dmr | 2 +- .../dmr-testsuite/coads_climatology.nc.full.dmr | 2 +- unit-tests/dmr-testsuite/fnoc1.nc.dmr | 2 +- unit-tests/dmr-testsuite/fnoc1.nc.dmr.xml | 2 +- unit-tests/dmr-testsuite/structure_1.dds.dmr | 2 +- unit-tests/dmr-testsuite/test.1.attr.dmr | 2 +- unit-tests/dmr-testsuite/test.1.dmr | 2 +- unit-tests/dmr-testsuite/test.1.full.dmr | 2 +- 37 files changed, 57 insertions(+), 45 deletions(-) diff --git a/DDS.cc b/DDS.cc index 71426b969..8dbb06240 100644 --- a/DDS.cc +++ b/DDS.cc @@ -1225,7 +1225,7 @@ void DDS::print_xml_writer(ostream &out, bool constrained, const string &blob) { * @param out Write the XML to this stream * @param constrained Should the DMR be subject to a constraint? */ -void DDS::print_dmr(ostream &out, bool constrained) { +void DDS::print_dmr(ostream &out, bool constrained, bool add_serialization_attr) { if (get_dap_major() < 4) throw InternalErr(__FILE__, __LINE__, "Tried to print a DMR with DAP major version less than 4"); @@ -1259,9 +1259,11 @@ void DDS::print_dmr(ostream &out, bool constrained) { (const xmlChar *)get_dmr_version().c_str()) < 0) throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dmrVersion"); - if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"dap:serialization", - (const xmlChar *)get_serialization().c_str()) < 0) - throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dap:serialization"); + if (add_serialization_attr) { + if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"dap:serialization", + (const xmlChar *)get_serialization().c_str()) < 0) + throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dap:serialization"); + } if (!get_request_xml_base().empty()) { if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"xml:base", diff --git a/DDS.h b/DDS.h index 6f7ad95f7..288d2499a 100644 --- a/DDS.h +++ b/DDS.h @@ -418,7 +418,7 @@ class DDS : public DapObj { void print_xml_writer(ostream &out, bool constrained, const string &blob = ""); // Print the DAP4 DMR 'object' - void print_dmr(ostream &out, bool constrained); + void print_dmr(ostream &out, bool constrained, bool add_serialization_attr = false); void print_das(ostream &out); DAS *get_das(); diff --git a/DMR.cc b/DMR.cc index 402b4512b..b428914f4 100644 --- a/DMR.cc +++ b/DMR.cc @@ -312,8 +312,10 @@ uint64_t DMR::request_size_kb(bool constrained) { return d_root->request_size_kb * @param xml use this XMLWriter to build the XML. * @param constrained Should the DMR be subject to a constraint? Defaults to * False + * @param add_serialization_attr Add the servers serialization version + * attribute to the Dataset element */ -void DMR::print_dap4(XMLWriter &xml, bool constrained) { +void DMR::print_dap4(XMLWriter &xml, bool constrained, bool add_serialization_attr) { if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar *)"Dataset") < 0) throw InternalErr(__FILE__, __LINE__, "Could not write Dataset element"); @@ -335,9 +337,11 @@ void DMR::print_dap4(XMLWriter &xml, bool constrained) { (const xmlChar *)dmr_version().c_str()) < 0) throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dmrVersion"); - if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"dap:serialization", - (const xmlChar *)serialization().c_str()) < 0) - throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dap:serialization"); + if (add_serialization_attr) { + if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"dap:serialization", + (const xmlChar *)serialization().c_str()) < 0) + throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dap:serialization"); + } if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"name", (const xmlChar *)name().c_str()) < 0) throw InternalErr(__FILE__, __LINE__, "Could not write attribute for name"); diff --git a/DMR.h b/DMR.h index 863be0091..028e5153a 100644 --- a/DMR.h +++ b/DMR.h @@ -270,7 +270,8 @@ class DMR : public DapObj { virtual bool is_dap4_projected(std::vector &inventory); - void print_dap4(XMLWriter &xml, bool constrained = false); + // void print_dap4(XMLWriter &xml, bool constrained = false){print_dap4(xml,constrained,false);}; + void print_dap4(XMLWriter &xml, bool constrained = false, bool add_serialization_attr = false); void dump(std::ostream &strm) const override; diff --git a/getdap4.cc b/getdap4.cc index 2e9b9cfd6..dd35249b9 100644 --- a/getdap4.cc +++ b/getdap4.cc @@ -341,7 +341,7 @@ void read_local_dap4(D4Connect &url, const string &name, const bool get_dmr_flag // Always write the DMR XMLWriter xml; - dmr.print_dap4(xml); + dmr.print_dap4(xml, false, true); cout << xml.get_doc() << endl; if (get_data_flag) diff --git a/tests/D4ResponseBuilder.cc b/tests/D4ResponseBuilder.cc index ac4cae2bb..8113fab68 100644 --- a/tests/D4ResponseBuilder.cc +++ b/tests/D4ResponseBuilder.cc @@ -135,7 +135,7 @@ void D4ResponseBuilder::send_dap(ostream &out, DMR &dmr, bool with_mime_headers, // Write the DMR XMLWriter xml; - dmr.print_dap4(xml, constrained); + dmr.print_dap4(xml, constrained, true); // now make the chunked output stream; set the size to be at least chunk_size // but make sure that the whole of the xml plus the CRLF can fit in the first diff --git a/tests/DMRTest.at b/tests/DMRTest.at index b2cdcf166..85659e1f6 100644 --- a/tests/DMRTest.at +++ b/tests/DMRTest.at @@ -89,7 +89,7 @@ m4_define([DMR_TRANS], [ AT_CHECK([cat stdout stderr > $baseline.tmp]) ], [ - AT_CHECK([$abs_builddir/dmr-test -C -x -t $input || true], [], [stdout], [stderr]) + AT_CHECK([$abs_builddir/dmr-test -d -C -x -t $input || true], [], [stdout], [stderr]) AT_CHECK([diff -b -B $baseline stdout || diff -b -B $baseline stderr], [], [ignore],[],[]) AT_XFAIL_IF([test "$2" = "xfail"]) diff --git a/unit-tests/DMRTest.cc b/unit-tests/DMRTest.cc index 0312882d7..a48232590 100644 --- a/unit-tests/DMRTest.cc +++ b/unit-tests/DMRTest.cc @@ -131,10 +131,15 @@ class DMRTest : public TestFixture { dmr = build_dmr(dds_file, attr); XMLWriter xml; dmr->print_dap4(xml); - DBG(cerr << "DMR: " << endl << xml.get_doc() << endl); + string dmr_doc(xml.get_doc()); + DBG(cerr << "DMR: " << endl << dmr_doc << endl); - string prefix = string(TEST_SRC_DIR) + "/dmr-testsuite/"; - CPPUNIT_ASSERT(string(xml.get_doc()) == read_test_baseline(prefix + dmr_baseline)); + string baseline_file = string(TEST_SRC_DIR) + "/dmr-testsuite/" + dmr_baseline; + DBG(cerr << "baseline_file: " << baseline_file << endl); + string baseline = read_test_baseline(baseline_file); + DBG(cerr << "BASELINE: " << endl << baseline << endl); + + CPPUNIT_ASSERT(dmr_doc == baseline); delete dmr; } catch (Error &e) { delete dmr; diff --git a/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.dmr b/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.dmr index fc950b615..33074a2aa 100644 --- a/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.dmr +++ b/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.full.dmr b/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.full.dmr index 4abf38568..3a56955ec 100644 --- a/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.full.dmr +++ b/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.full.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr b/unit-tests/dmr-rt-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr index 8eb79b46f..405355d37 100644 --- a/unit-tests/dmr-rt-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr +++ b/unit-tests/dmr-rt-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/S2000415.HDF.dmr b/unit-tests/dmr-rt-testsuite/S2000415.HDF.dmr index 002f060e9..5a76c4b8d 100644 --- a/unit-tests/dmr-rt-testsuite/S2000415.HDF.dmr +++ b/unit-tests/dmr-rt-testsuite/S2000415.HDF.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/S2000415.HDF.full.dmr b/unit-tests/dmr-rt-testsuite/S2000415.HDF.full.dmr index 5476effcb..f92ac0198 100644 --- a/unit-tests/dmr-rt-testsuite/S2000415.HDF.full.dmr +++ b/unit-tests/dmr-rt-testsuite/S2000415.HDF.full.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/attr_test_00.dmr b/unit-tests/dmr-rt-testsuite/attr_test_00.dmr index 475c947d7..151ee63e9 100644 --- a/unit-tests/dmr-rt-testsuite/attr_test_00.dmr +++ b/unit-tests/dmr-rt-testsuite/attr_test_00.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/attr_test_01.dmr b/unit-tests/dmr-rt-testsuite/attr_test_01.dmr index ef8bde66f..0b87e667e 100644 --- a/unit-tests/dmr-rt-testsuite/attr_test_01.dmr +++ b/unit-tests/dmr-rt-testsuite/attr_test_01.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr b/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr index c97be5a6f..dd618e673 100644 --- a/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr +++ b/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr.xml b/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr.xml index c879fe46c..f361e7972 100644 --- a/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr.xml +++ b/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr.xml @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/coads_climatology.nc.full.dmr b/unit-tests/dmr-rt-testsuite/coads_climatology.nc.full.dmr index b56a244c0..afebdd075 100644 --- a/unit-tests/dmr-rt-testsuite/coads_climatology.nc.full.dmr +++ b/unit-tests/dmr-rt-testsuite/coads_climatology.nc.full.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr b/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr index b420a17ba..ba7a9b585 100644 --- a/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr +++ b/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr.xml b/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr.xml index b2d009da3..89a4a80ff 100644 --- a/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr.xml +++ b/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr.xml @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/test.1.attr.dmr b/unit-tests/dmr-rt-testsuite/test.1.attr.dmr index 5f929add5..770502cb1 100644 --- a/unit-tests/dmr-rt-testsuite/test.1.attr.dmr +++ b/unit-tests/dmr-rt-testsuite/test.1.attr.dmr @@ -1,5 +1,5 @@ - + byte_b diff --git a/unit-tests/dmr-rt-testsuite/test.1.dmr b/unit-tests/dmr-rt-testsuite/test.1.dmr index 174f44b65..dab4ae214 100644 --- a/unit-tests/dmr-rt-testsuite/test.1.dmr +++ b/unit-tests/dmr-rt-testsuite/test.1.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/test.1.full.dmr b/unit-tests/dmr-rt-testsuite/test.1.full.dmr index 5f929add5..770502cb1 100644 --- a/unit-tests/dmr-rt-testsuite/test.1.full.dmr +++ b/unit-tests/dmr-rt-testsuite/test.1.full.dmr @@ -1,5 +1,5 @@ - + byte_b diff --git a/unit-tests/dmr-rt-testsuite/unused/coads_climatology.nc.dmr b/unit-tests/dmr-rt-testsuite/unused/coads_climatology.nc.dmr index 1f69a8b4f..6a9ba3bd2 100644 --- a/unit-tests/dmr-rt-testsuite/unused/coads_climatology.nc.dmr +++ b/unit-tests/dmr-rt-testsuite/unused/coads_climatology.nc.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/3B42.980909.5.HDF.dmr b/unit-tests/dmr-testsuite/3B42.980909.5.HDF.dmr index fc950b615..33074a2aa 100644 --- a/unit-tests/dmr-testsuite/3B42.980909.5.HDF.dmr +++ b/unit-tests/dmr-testsuite/3B42.980909.5.HDF.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/3B42.980909.5.HDF.full.dmr b/unit-tests/dmr-testsuite/3B42.980909.5.HDF.full.dmr index a7c261be7..4ef245a8f 100644 --- a/unit-tests/dmr-testsuite/3B42.980909.5.HDF.full.dmr +++ b/unit-tests/dmr-testsuite/3B42.980909.5.HDF.full.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr b/unit-tests/dmr-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr index 8eb79b46f..405355d37 100644 --- a/unit-tests/dmr-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr +++ b/unit-tests/dmr-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/S2000415.HDF.dmr b/unit-tests/dmr-testsuite/S2000415.HDF.dmr index 002f060e9..5a76c4b8d 100644 --- a/unit-tests/dmr-testsuite/S2000415.HDF.dmr +++ b/unit-tests/dmr-testsuite/S2000415.HDF.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/S2000415.HDF.full.dmr b/unit-tests/dmr-testsuite/S2000415.HDF.full.dmr index 92be7c5f8..9efa2bf41 100644 --- a/unit-tests/dmr-testsuite/S2000415.HDF.full.dmr +++ b/unit-tests/dmr-testsuite/S2000415.HDF.full.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/coads_climatology.nc.dmr b/unit-tests/dmr-testsuite/coads_climatology.nc.dmr index 5d9626ea4..b2795533c 100644 --- a/unit-tests/dmr-testsuite/coads_climatology.nc.dmr +++ b/unit-tests/dmr-testsuite/coads_climatology.nc.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/coads_climatology.nc.full.dmr b/unit-tests/dmr-testsuite/coads_climatology.nc.full.dmr index 2881fd5ae..4c7871f5e 100644 --- a/unit-tests/dmr-testsuite/coads_climatology.nc.full.dmr +++ b/unit-tests/dmr-testsuite/coads_climatology.nc.full.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/fnoc1.nc.dmr b/unit-tests/dmr-testsuite/fnoc1.nc.dmr index b420a17ba..ba7a9b585 100644 --- a/unit-tests/dmr-testsuite/fnoc1.nc.dmr +++ b/unit-tests/dmr-testsuite/fnoc1.nc.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/fnoc1.nc.dmr.xml b/unit-tests/dmr-testsuite/fnoc1.nc.dmr.xml index b2d009da3..89a4a80ff 100644 --- a/unit-tests/dmr-testsuite/fnoc1.nc.dmr.xml +++ b/unit-tests/dmr-testsuite/fnoc1.nc.dmr.xml @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/structure_1.dds.dmr b/unit-tests/dmr-testsuite/structure_1.dds.dmr index be219017f..db977bdd5 100644 --- a/unit-tests/dmr-testsuite/structure_1.dds.dmr +++ b/unit-tests/dmr-testsuite/structure_1.dds.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/test.1.attr.dmr b/unit-tests/dmr-testsuite/test.1.attr.dmr index 5f929add5..770502cb1 100644 --- a/unit-tests/dmr-testsuite/test.1.attr.dmr +++ b/unit-tests/dmr-testsuite/test.1.attr.dmr @@ -1,5 +1,5 @@ - + byte_b diff --git a/unit-tests/dmr-testsuite/test.1.dmr b/unit-tests/dmr-testsuite/test.1.dmr index 174f44b65..dab4ae214 100644 --- a/unit-tests/dmr-testsuite/test.1.dmr +++ b/unit-tests/dmr-testsuite/test.1.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/test.1.full.dmr b/unit-tests/dmr-testsuite/test.1.full.dmr index 5f929add5..770502cb1 100644 --- a/unit-tests/dmr-testsuite/test.1.full.dmr +++ b/unit-tests/dmr-testsuite/test.1.full.dmr @@ -1,5 +1,5 @@ - + byte_b From 73e6c185061bdb00a542e6051208590a5ab57f94 Mon Sep 17 00:00:00 2001 From: ndp-opendap Date: Wed, 15 Apr 2026 08:31:56 -0700 Subject: [PATCH 4/6] dmrVersion rollback step one - disentangle from dmrVersion rollback work. --- DMR.h | 5 ++++- tests/DMRTest.at | 2 +- unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.dmr | 2 +- unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.full.dmr | 2 +- .../dmr-rt-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr | 2 +- unit-tests/dmr-rt-testsuite/S2000415.HDF.dmr | 2 +- unit-tests/dmr-rt-testsuite/S2000415.HDF.full.dmr | 2 +- unit-tests/dmr-rt-testsuite/attr_test_00.dmr | 2 +- unit-tests/dmr-rt-testsuite/attr_test_01.dmr | 2 +- unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr | 2 +- unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr.xml | 2 +- unit-tests/dmr-rt-testsuite/coads_climatology.nc.full.dmr | 2 +- unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr | 2 +- unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr.xml | 2 +- unit-tests/dmr-rt-testsuite/test.1.attr.dmr | 2 +- unit-tests/dmr-rt-testsuite/test.1.dmr | 2 +- unit-tests/dmr-rt-testsuite/test.1.full.dmr | 2 +- unit-tests/dmr-rt-testsuite/unused/coads_climatology.nc.dmr | 2 +- unit-tests/dmr-testsuite/3B42.980909.5.HDF.dmr | 2 +- unit-tests/dmr-testsuite/3B42.980909.5.HDF.full.dmr | 2 +- unit-tests/dmr-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr | 2 +- unit-tests/dmr-testsuite/S2000415.HDF.dmr | 2 +- unit-tests/dmr-testsuite/S2000415.HDF.full.dmr | 2 +- unit-tests/dmr-testsuite/coads_climatology.nc.dmr | 2 +- unit-tests/dmr-testsuite/coads_climatology.nc.full.dmr | 2 +- unit-tests/dmr-testsuite/fnoc1.nc.dmr | 2 +- unit-tests/dmr-testsuite/fnoc1.nc.dmr.xml | 2 +- unit-tests/dmr-testsuite/structure_1.dds.dmr | 2 +- unit-tests/dmr-testsuite/test.1.attr.dmr | 2 +- unit-tests/dmr-testsuite/test.1.dmr | 2 +- unit-tests/dmr-testsuite/test.1.full.dmr | 2 +- 31 files changed, 34 insertions(+), 31 deletions(-) diff --git a/DMR.h b/DMR.h index 028e5153a..6af1d7c88 100644 --- a/DMR.h +++ b/DMR.h @@ -71,7 +71,10 @@ class DMR : public DapObj { std::string d_dap_version = "4.0"; /// The version of the DMR document - std::string d_dmr_version = "1.0"; + /// Version 1.0 is the original serialization scheme - Groups were serialized first, + /// then the top-level variables. + /// The 2.0 version indicates the DAP4 Serialization bug fix. + std::string d_dmr_version = "2.0"; /// The version of the DAP4 serialization used to encode the data response values. /// Prior to adding this indicator variable and its expression in the DMR diff --git a/tests/DMRTest.at b/tests/DMRTest.at index 85659e1f6..b2cdcf166 100644 --- a/tests/DMRTest.at +++ b/tests/DMRTest.at @@ -89,7 +89,7 @@ m4_define([DMR_TRANS], [ AT_CHECK([cat stdout stderr > $baseline.tmp]) ], [ - AT_CHECK([$abs_builddir/dmr-test -d -C -x -t $input || true], [], [stdout], [stderr]) + AT_CHECK([$abs_builddir/dmr-test -C -x -t $input || true], [], [stdout], [stderr]) AT_CHECK([diff -b -B $baseline stdout || diff -b -B $baseline stderr], [], [ignore],[],[]) AT_XFAIL_IF([test "$2" = "xfail"]) diff --git a/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.dmr b/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.dmr index 33074a2aa..fc950b615 100644 --- a/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.dmr +++ b/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.full.dmr b/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.full.dmr index 3a56955ec..4abf38568 100644 --- a/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.full.dmr +++ b/unit-tests/dmr-rt-testsuite/3B42.980909.5.HDF.full.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr b/unit-tests/dmr-rt-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr index 405355d37..8eb79b46f 100644 --- a/unit-tests/dmr-rt-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr +++ b/unit-tests/dmr-rt-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/S2000415.HDF.dmr b/unit-tests/dmr-rt-testsuite/S2000415.HDF.dmr index 5a76c4b8d..002f060e9 100644 --- a/unit-tests/dmr-rt-testsuite/S2000415.HDF.dmr +++ b/unit-tests/dmr-rt-testsuite/S2000415.HDF.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/S2000415.HDF.full.dmr b/unit-tests/dmr-rt-testsuite/S2000415.HDF.full.dmr index f92ac0198..5476effcb 100644 --- a/unit-tests/dmr-rt-testsuite/S2000415.HDF.full.dmr +++ b/unit-tests/dmr-rt-testsuite/S2000415.HDF.full.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/attr_test_00.dmr b/unit-tests/dmr-rt-testsuite/attr_test_00.dmr index 151ee63e9..475c947d7 100644 --- a/unit-tests/dmr-rt-testsuite/attr_test_00.dmr +++ b/unit-tests/dmr-rt-testsuite/attr_test_00.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/attr_test_01.dmr b/unit-tests/dmr-rt-testsuite/attr_test_01.dmr index 0b87e667e..ef8bde66f 100644 --- a/unit-tests/dmr-rt-testsuite/attr_test_01.dmr +++ b/unit-tests/dmr-rt-testsuite/attr_test_01.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr b/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr index dd618e673..c97be5a6f 100644 --- a/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr +++ b/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr.xml b/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr.xml index f361e7972..c879fe46c 100644 --- a/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr.xml +++ b/unit-tests/dmr-rt-testsuite/coads_climatology.nc.dmr.xml @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/coads_climatology.nc.full.dmr b/unit-tests/dmr-rt-testsuite/coads_climatology.nc.full.dmr index afebdd075..b56a244c0 100644 --- a/unit-tests/dmr-rt-testsuite/coads_climatology.nc.full.dmr +++ b/unit-tests/dmr-rt-testsuite/coads_climatology.nc.full.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr b/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr index ba7a9b585..b420a17ba 100644 --- a/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr +++ b/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr.xml b/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr.xml index 89a4a80ff..b2d009da3 100644 --- a/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr.xml +++ b/unit-tests/dmr-rt-testsuite/fnoc1.nc.dmr.xml @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/test.1.attr.dmr b/unit-tests/dmr-rt-testsuite/test.1.attr.dmr index 770502cb1..5f929add5 100644 --- a/unit-tests/dmr-rt-testsuite/test.1.attr.dmr +++ b/unit-tests/dmr-rt-testsuite/test.1.attr.dmr @@ -1,5 +1,5 @@ - + byte_b diff --git a/unit-tests/dmr-rt-testsuite/test.1.dmr b/unit-tests/dmr-rt-testsuite/test.1.dmr index dab4ae214..174f44b65 100644 --- a/unit-tests/dmr-rt-testsuite/test.1.dmr +++ b/unit-tests/dmr-rt-testsuite/test.1.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-rt-testsuite/test.1.full.dmr b/unit-tests/dmr-rt-testsuite/test.1.full.dmr index 770502cb1..5f929add5 100644 --- a/unit-tests/dmr-rt-testsuite/test.1.full.dmr +++ b/unit-tests/dmr-rt-testsuite/test.1.full.dmr @@ -1,5 +1,5 @@ - + byte_b diff --git a/unit-tests/dmr-rt-testsuite/unused/coads_climatology.nc.dmr b/unit-tests/dmr-rt-testsuite/unused/coads_climatology.nc.dmr index 6a9ba3bd2..1f69a8b4f 100644 --- a/unit-tests/dmr-rt-testsuite/unused/coads_climatology.nc.dmr +++ b/unit-tests/dmr-rt-testsuite/unused/coads_climatology.nc.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/3B42.980909.5.HDF.dmr b/unit-tests/dmr-testsuite/3B42.980909.5.HDF.dmr index 33074a2aa..fc950b615 100644 --- a/unit-tests/dmr-testsuite/3B42.980909.5.HDF.dmr +++ b/unit-tests/dmr-testsuite/3B42.980909.5.HDF.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/3B42.980909.5.HDF.full.dmr b/unit-tests/dmr-testsuite/3B42.980909.5.HDF.full.dmr index 4ef245a8f..a7c261be7 100644 --- a/unit-tests/dmr-testsuite/3B42.980909.5.HDF.full.dmr +++ b/unit-tests/dmr-testsuite/3B42.980909.5.HDF.full.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr b/unit-tests/dmr-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr index 405355d37..8eb79b46f 100644 --- a/unit-tests/dmr-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr +++ b/unit-tests/dmr-testsuite/3B42.980909.5.hacked.2.HDF.attr.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/S2000415.HDF.dmr b/unit-tests/dmr-testsuite/S2000415.HDF.dmr index 5a76c4b8d..002f060e9 100644 --- a/unit-tests/dmr-testsuite/S2000415.HDF.dmr +++ b/unit-tests/dmr-testsuite/S2000415.HDF.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/S2000415.HDF.full.dmr b/unit-tests/dmr-testsuite/S2000415.HDF.full.dmr index 9efa2bf41..92be7c5f8 100644 --- a/unit-tests/dmr-testsuite/S2000415.HDF.full.dmr +++ b/unit-tests/dmr-testsuite/S2000415.HDF.full.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/coads_climatology.nc.dmr b/unit-tests/dmr-testsuite/coads_climatology.nc.dmr index b2795533c..5d9626ea4 100644 --- a/unit-tests/dmr-testsuite/coads_climatology.nc.dmr +++ b/unit-tests/dmr-testsuite/coads_climatology.nc.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/coads_climatology.nc.full.dmr b/unit-tests/dmr-testsuite/coads_climatology.nc.full.dmr index 4c7871f5e..2881fd5ae 100644 --- a/unit-tests/dmr-testsuite/coads_climatology.nc.full.dmr +++ b/unit-tests/dmr-testsuite/coads_climatology.nc.full.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/fnoc1.nc.dmr b/unit-tests/dmr-testsuite/fnoc1.nc.dmr index ba7a9b585..b420a17ba 100644 --- a/unit-tests/dmr-testsuite/fnoc1.nc.dmr +++ b/unit-tests/dmr-testsuite/fnoc1.nc.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/fnoc1.nc.dmr.xml b/unit-tests/dmr-testsuite/fnoc1.nc.dmr.xml index 89a4a80ff..b2d009da3 100644 --- a/unit-tests/dmr-testsuite/fnoc1.nc.dmr.xml +++ b/unit-tests/dmr-testsuite/fnoc1.nc.dmr.xml @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/structure_1.dds.dmr b/unit-tests/dmr-testsuite/structure_1.dds.dmr index db977bdd5..be219017f 100644 --- a/unit-tests/dmr-testsuite/structure_1.dds.dmr +++ b/unit-tests/dmr-testsuite/structure_1.dds.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/test.1.attr.dmr b/unit-tests/dmr-testsuite/test.1.attr.dmr index 770502cb1..5f929add5 100644 --- a/unit-tests/dmr-testsuite/test.1.attr.dmr +++ b/unit-tests/dmr-testsuite/test.1.attr.dmr @@ -1,5 +1,5 @@ - + byte_b diff --git a/unit-tests/dmr-testsuite/test.1.dmr b/unit-tests/dmr-testsuite/test.1.dmr index dab4ae214..174f44b65 100644 --- a/unit-tests/dmr-testsuite/test.1.dmr +++ b/unit-tests/dmr-testsuite/test.1.dmr @@ -1,5 +1,5 @@ - + diff --git a/unit-tests/dmr-testsuite/test.1.full.dmr b/unit-tests/dmr-testsuite/test.1.full.dmr index 770502cb1..5f929add5 100644 --- a/unit-tests/dmr-testsuite/test.1.full.dmr +++ b/unit-tests/dmr-testsuite/test.1.full.dmr @@ -1,5 +1,5 @@ - + byte_b From f1ff2fe60b435cf9927b3db72fb657ebdbdf186d Mon Sep 17 00:00:00 2001 From: ndp-opendap Date: Thu, 16 Apr 2026 05:22:52 -0700 Subject: [PATCH 5/6] This version works to inject the attribute into the DAP4 Data response DMR. I have elided any state regarding in the DMR, DDS, and D4ParserSax2 because there is no point ti holding the state. The code always performs the DAP4 seialization the correct way, and never the old way. The flag is only for consuming clients. --- D4ParserSax2.cc | 6 +++-- DDS.cc | 5 ++-- DDS.h | 3 ++- DMR.cc | 9 ++++--- DMR.h | 17 +++++++----- Makefile.am | 2 +- cerealization_patch.h | 62 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 87 insertions(+), 17 deletions(-) create mode 100644 cerealization_patch.h diff --git a/D4ParserSax2.cc b/D4ParserSax2.cc index 9df34327b..2951e1ad6 100644 --- a/D4ParserSax2.cc +++ b/D4ParserSax2.cc @@ -43,6 +43,7 @@ #include "D4ParserSax2.h" #include "DapXmlNamespaces.h" +#include "cerealization_patch.h" #include "debug.h" #include "util.h" @@ -651,8 +652,9 @@ void D4ParserSax2::dmr_start_element(void *p, const xmlChar *l, const xmlChar *p if (parser->check_attribute("dmrVersion")) parser->dmr()->set_dmr_version(parser->xml_attrs["dmrVersion"].value); - if (parser->check_attribute("dap:serialization")) - parser->dmr()->set_serialization(parser->xml_attrs["dap:serialization"].value); + // TODO - Do we ever need/want to read serialization flag into a DMR state variable? (I don't think so...) + // if (parser->check_attribute(CEREALIZATION_PATCH_ATTR_NAME)) + // parser->dmr()->set_serialization(parser->xml_attrs[CEREALIZATION_PATCH_ATTR_NAME].value); if (parser->check_attribute("base")) parser->dmr()->set_request_xml_base(parser->xml_attrs["base"].value); diff --git a/DDS.cc b/DDS.cc index 8dbb06240..7beb1c4ee 100644 --- a/DDS.cc +++ b/DDS.cc @@ -71,6 +71,7 @@ #include "DapIndent.h" #include "Error.h" #include "InternalErr.h" +#include "cerealization_patch.h" #include "debug.h" #include "escaping.h" #include "parser.h" @@ -1260,9 +1261,7 @@ void DDS::print_dmr(ostream &out, bool constrained, bool add_serialization_attr) throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dmrVersion"); if (add_serialization_attr) { - if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"dap:serialization", - (const xmlChar *)get_serialization().c_str()) < 0) - throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dap:serialization"); + add_serialization_patch_attribute(xml, get_namespace()); } if (!get_request_xml_base().empty()) { diff --git a/DDS.h b/DDS.h index 288d2499a..feed168ba 100644 --- a/DDS.h +++ b/DDS.h @@ -286,8 +286,9 @@ class DDS : public DapObj { /** @brief Returns the DAP4 DMR version corresponding to DDS exports. */ string get_dmr_version() const { return "1.0"; } + // TODO - Do we need a state variable for the serialization flag? (I don't think so...) /** @brief Returns the DAP4 data serialization scheme. */ - string get_serialization() const { return "4.0"; } + // string get_serialization() const { return "4.0"; } /// @deprecated void set_dap_major(int p); diff --git a/DMR.cc b/DMR.cc index b428914f4..2b7309a8d 100644 --- a/DMR.cc +++ b/DMR.cc @@ -46,6 +46,7 @@ #include "DDS.h" // Included so DMRs can be built using a DDS for 'legacy' handlers #include "DapIndent.h" +#include "cerealization_patch.h" #include "debug.h" using namespace std; @@ -68,7 +69,9 @@ void DMR::m_duplicate(const DMR &dmr) { d_dap_version = dmr.d_dap_version; // String version of the protocol d_dmr_version = dmr.d_dmr_version; - d_serialization = dmr.d_serialization; + + // TODO - Do we need a state variable for the serialization flag? (I don't think so...) + // d_serialization = dmr.d_serialization; d_request_xml_base = dmr.d_request_xml_base; @@ -338,9 +341,7 @@ void DMR::print_dap4(XMLWriter &xml, bool constrained, bool add_serialization_at throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dmrVersion"); if (add_serialization_attr) { - if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"dap:serialization", - (const xmlChar *)serialization().c_str()) < 0) - throw InternalErr(__FILE__, __LINE__, "Could not write attribute for dap:serialization"); + add_serialization_patch_attribute(xml, get_namespace()); } if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"name", (const xmlChar *)name().c_str()) < 0) diff --git a/DMR.h b/DMR.h index 6af1d7c88..cf9edf6c6 100644 --- a/DMR.h +++ b/DMR.h @@ -83,7 +83,8 @@ class DMR : public DapObj { /// We mended this problem with dap4 serialization add added this state /// variable along with a Dataset xml attribute dap:serialization to express this state. /// The original patch changed the d_dmr_version to 2.0 - ndp 4/14/26 - std::string d_serialization = "4.0"; + // TODO - Do we need a DMR state variable for the serialization flag? (I don't think so...) + // std::string d_serialization = "4.0"; /// The URL for the request base std::string d_request_xml_base; @@ -188,14 +189,18 @@ class DMR : public DapObj { */ void set_dmr_version(const std::string &v) { d_dmr_version = v; } - /** @brief Returns the DAP4 serialization that the source service will deliver. */ - std::string serialization() const { return d_serialization; } + /** + * @brief Returns the DAP4 serialization that the source service will deliver. + * TODO - Do we need a DMR state variable for the serialization flag? (I don't think so...) + */ + // std::string serialization() const { return d_serialization; } /** - * @brief Sets the DMR document version string. - * @param v DMR version value. + * @brief Sets the DAP4 serialization string. + * TODO - Do we need a DMR state variable for the serialization flag? (I don't think so...) + * @param v DAP4 serialization value. */ - void set_serialization(const std::string &v) { d_serialization = v; } + // void set_serialization(const std::string &v) { d_serialization = v; } /// Get the URL that will return this DMR std::string request_xml_base() const { return d_request_xml_base; } diff --git a/Makefile.am b/Makefile.am index 4bbc903ce..cecfd1245 100644 --- a/Makefile.am +++ b/Makefile.am @@ -218,7 +218,7 @@ DAP4_ONLY_HDR = D4StreamMarshaller.h D4StreamUnMarshaller.h Int64.h \ D4Maps.h D4Dimensions.h D4EnumDefs.h D4Group.h DMR.h D4Attributes.h \ D4AttributeType.h D4Enum.h chunked_stream.h chunked_ostream.h \ chunked_istream.h D4Sequence.h crc.h D4Opaque.h D4AsyncUtil.h \ - D4Function.h D4RValue.h D4FilterClause.h + D4Function.h D4RValue.h D4FilterClause.h cerealization_patch.h if USE_C99_TYPES dods-datatypes.h: dods-datatypes-static.h diff --git a/cerealization_patch.h b/cerealization_patch.h new file mode 100644 index 000000000..1b0eb79c8 --- /dev/null +++ b/cerealization_patch.h @@ -0,0 +1,62 @@ +// -*- mode: c++; c-basic-offset:4 -*- + +// This file is part of libdap, A C++ implementation of the OPeNDAP Data +// Access Protocol. + +// Copyright (c) 2026 OPeNDAP, Inc. +// Author: NAthan Potter +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// +// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112. +// +// cerealization_patch.h +// + +#ifndef CEREALIZATION_PATCH_H +#define CEREALIZATION_PATCH_H + +#define CEREALIZATION_PATCH_ATTR_NAME "hyrax_dap" +#define CEREALIZATION_PATCH_ATTR_VALUE "4.0" + +#include "InternalErr.h" +#include "XMLWriter.h" +namespace libdap { + +/** + * + * Adds the serialization patch attribute to the current element. + * @param xml + * @param dap4_namespace_name + */ +static void add_serialization_patch_attribute(libdap::XMLWriter &xml, const string &dap4_namespace_name) { + + if (!dap4_namespace_name.empty()) { + // Oddly, the dap namespace prefix is not defined by default. We have to add it to + // namespace prefix our special attribute. + if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"xmlns:dap", + (const xmlChar *)dap4_namespace_name.c_str()) < 0) + throw libdap::InternalErr(__FILE__, __LINE__, "Could not write attribute for xmlns:dap"); + } + + // TODO - Is this really just a hyrax thing? Rethink this attribute name! + if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)CEREALIZATION_PATCH_ATTR_NAME, + (const xmlChar *)CEREALIZATION_PATCH_ATTR_VALUE) < 0) + throw libdap::InternalErr(__FILE__, __LINE__, "Could not write attribute for " CEREALIZATION_PATCH_ATTR_NAME); +} + +} // namespace libdap + +#endif // CEREALIZATION_PATCH_H From 5b8f87c57e5705d083ad12527447335b459dbad0 Mon Sep 17 00:00:00 2001 From: ndp-opendap Date: Thu, 16 Apr 2026 05:25:08 -0700 Subject: [PATCH 6/6] no namespace for now --- cerealization_patch.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cerealization_patch.h b/cerealization_patch.h index 1b0eb79c8..777a30fce 100644 --- a/cerealization_patch.h +++ b/cerealization_patch.h @@ -41,8 +41,10 @@ namespace libdap { * @param xml * @param dap4_namespace_name */ -static void add_serialization_patch_attribute(libdap::XMLWriter &xml, const string &dap4_namespace_name) { +static void add_serialization_patch_attribute(libdap::XMLWriter &xml, const string &) { + /* + TODO - If we don't need a namespace prefix we can drop this bit. if (!dap4_namespace_name.empty()) { // Oddly, the dap namespace prefix is not defined by default. We have to add it to // namespace prefix our special attribute. @@ -50,6 +52,7 @@ static void add_serialization_patch_attribute(libdap::XMLWriter &xml, const stri (const xmlChar *)dap4_namespace_name.c_str()) < 0) throw libdap::InternalErr(__FILE__, __LINE__, "Could not write attribute for xmlns:dap"); } + */ // TODO - Is this really just a hyrax thing? Rethink this attribute name! if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)CEREALIZATION_PATCH_ATTR_NAME,