71void DMRpp::print_dmrpp(XMLWriter &xml,
const string &href,
bool constrained,
bool print_chunks)
73 bool pc_initial_value = DmrppCommon::d_print_chunks;
74 DmrppCommon::d_print_chunks = print_chunks;
77 if (xmlTextWriterStartElement(xml.get_writer(), (
const xmlChar*)
"Dataset") < 0)
78 throw InternalErr(__FILE__, __LINE__,
"Could not write Dataset element");
80 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"xmlns",
81 (
const xmlChar*) get_namespace().c_str()) < 0)
82 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for xmlns");
85 if (DmrppCommon::d_print_chunks)
86 if (xmlTextWriterWriteAttribute(xml.get_writer(),
87 (
const xmlChar*)
string(
"xmlns:").append(DmrppCommon::d_ns_prefix).c_str(),
88 (
const xmlChar*)DmrppCommon::d_dmrpp_ns.c_str()) < 0)
89 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for xmlns:dmrpp");
91 if (!request_xml_base().empty()) {
92 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"xml:base",
93 (
const xmlChar*) request_xml_base().c_str()) < 0)
94 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for xml:base");
97 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"dapVersion",
98 (
const xmlChar*) dap_version().c_str()) < 0)
99 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for dapVersion");
101 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"dmrVersion",
102 (
const xmlChar*) dmr_version().c_str()) < 0)
103 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for dapVersion");
105 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"name", (
const xmlChar*) name().c_str()) < 0)
106 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
110 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
string(DmrppCommon::d_ns_prefix).append(
":href").c_str(),
111 (
const xmlChar*) href.c_str()) < 0)
112 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for href");
114 if (!get_version().empty())
115 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
string(DmrppCommon::d_ns_prefix).append(
":version").c_str(),
116 (
const xmlChar*) get_version().c_str()) < 0)
117 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for version");
120 root()->print_dap4(xml, constrained);
122 if (xmlTextWriterEndElement(xml.get_writer()) < 0)
123 throw InternalErr(__FILE__, __LINE__,
"Could not end the top-level Group element");
126 DmrppCommon::d_print_chunks = pc_initial_value;
130 DmrppCommon::d_print_chunks = pc_initial_value;