26 #include <XMLWriter.h>
28 #include <D4BaseTypeFactory.h>
29 #include <InternalErr.h>
32 #include "DmrppCommon.h"
33 #include "DmrppTypeFactory.h"
39 DMRpp::DMRpp(DmrppTypeFactory *factory,
const std::string &name) : DMR(factory, name)
70 void DMRpp::print_dmrpp(XMLWriter &xml,
const string &href,
bool constrained,
bool print_chunks)
72 bool pc_initial_value = DmrppCommon::d_print_chunks;
73 DmrppCommon::d_print_chunks = print_chunks;
76 if (xmlTextWriterStartElement(xml.get_writer(), (
const xmlChar*)
"Dataset") < 0)
77 throw InternalErr(__FILE__, __LINE__,
"Could not write Dataset element");
79 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"xmlns",
80 (
const xmlChar*) get_namespace().c_str()) < 0)
81 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for xmlns");
84 if (DmrppCommon::d_print_chunks)
85 if (xmlTextWriterWriteAttribute(xml.get_writer(),
86 (
const xmlChar*)
string(
"xmlns:").append(DmrppCommon::d_ns_prefix).c_str(),
87 (
const xmlChar*)DmrppCommon::d_dmrpp_ns.c_str()) < 0)
88 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for xmlns:dmrpp");
90 if (!request_xml_base().empty()) {
91 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"xml:base",
92 (
const xmlChar*) request_xml_base().c_str()) < 0)
93 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for xml:base");
96 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"dapVersion",
97 (
const xmlChar*) dap_version().c_str()) < 0)
98 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for dapVersion");
100 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"dmrVersion",
101 (
const xmlChar*) dmr_version().c_str()) < 0)
102 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for dapVersion");
104 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"name", (
const xmlChar*) name().c_str()) < 0)
105 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
109 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
string(DmrppCommon::d_ns_prefix).append(
":href").c_str(),
110 (
const xmlChar*) href.c_str()) < 0)
111 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for href");
114 root()->print_dap4(xml, constrained);
116 if (xmlTextWriterEndElement(xml.get_writer()) < 0)
117 throw InternalErr(__FILE__, __LINE__,
"Could not end the top-level Group element");
120 DmrppCommon::d_print_chunks = pc_initial_value;
124 DmrppCommon::d_print_chunks = pc_initial_value;
134 DMRpp::print_dap4(XMLWriter &xml,
bool constrained )
136 print_dmrpp(xml, get_href(), constrained, get_print_chunks());