35 using std::ostringstream ;
41 #define MY_ENCODING "ISO-8859-1"
42 #define BES_SCHEMA "http://xml.opendap.org/ns/bes/1.0#"
69 xmlFreeTextWriter( _writer ) ;
75 xmlBufferFree( _doc_buf ) ;
86 ((ostringstream *)
_strm)->str(
"" ) ;
112 _doc_buf = xmlBufferCreate() ;
113 if( _doc_buf == NULL )
116 string err = (string)
"Error creating the xml buffer for response "
123 _writer = xmlNewTextWriterMemory( _doc_buf, 0 ) ;
124 if( _writer == NULL )
127 string err = (string)
"Error creating the xml writer for response "
132 rc = xmlTextWriterSetIndent( _writer, 4 ) ;
136 string err = (string)
"Error starting indentation for response document "
141 rc = xmlTextWriterSetIndentString( _writer, BAD_CAST
" " ) ;
145 string err = (string)
"Error setting indentation for response document "
155 rc = xmlTextWriterStartDocument( _writer, NULL,
MY_ENCODING, NULL ) ;
159 string err = (string)
"Error starting xml response document for "
166 rc = xmlTextWriterStartElementNS( _writer, NULL,
172 string err = (string)
"Error starting the response element for response "
181 rc = xmlTextWriterWriteAttribute( _writer, BAD_CAST
REQUEST_ID,
182 BAD_CAST reqid.c_str() ) ;
186 string err = (string)
"Error adding attribute " + REQUEST_ID
193 rc = xmlTextWriterStartElement( _writer, BAD_CAST
_response_name.c_str() ) ;
197 string err = (string)
"Error creating root element for response "
218 rc = xmlTextWriterEndElement( _writer ) ;
222 string err = (string)
"Error ending response element for response "
228 rc = xmlTextWriterEndElement( _writer ) ;
232 string err = (string)
"Error ending specific response element "
237 rc = xmlTextWriterEndDocument( _writer ) ;
241 string err = (string)
"Error ending the response document for response "
247 xmlFreeTextWriter( _writer ) ;
251 if( !_doc_buf->content )
254 string err = (string)
"Error retrieving response document as string "
260 _doc = (
char *)_doc_buf->content ;
276 const string &tag_data,
277 map<string,string> *attrs )
280 int rc = xmlTextWriterStartElement( _writer, BAD_CAST tag_name.c_str() ) ;
284 string err = (string)
"Error starting element " + tag_name
291 map<string,string>::const_iterator i = attrs->begin() ;
292 map<string,string>::const_iterator e = attrs->end() ;
295 string name = (*i).first ;
296 string val = (*i).second ;
300 rc = xmlTextWriterWriteAttribute( _writer, BAD_CAST name.c_str(),
301 BAD_CAST val.c_str() ) ;
305 string err = (string)
"Error adding attribute " + name
313 if( !tag_data.empty() )
315 rc = xmlTextWriterWriteString( _writer, BAD_CAST tag_data.c_str() ) ;
319 string err = (string)
"Error writing the value for element "
326 rc = xmlTextWriterEndElement( _writer ) ;
330 string err = (string)
"Error ending element " + tag_name
343 map<string,string> *attrs )
359 map<string,string> *attrs )
365 if( ns.empty() && uri.empty() )
367 rc = xmlTextWriterStartElement( _writer, BAD_CAST tag_name.c_str());
371 string err = (string)
"Error starting element " + tag_name
378 const char *cns = NULL ;
379 if( !ns.empty() ) cns = ns.c_str() ;
380 rc = xmlTextWriterStartElementNS( _writer,
382 BAD_CAST tag_name.c_str(),
383 BAD_CAST uri.c_str() ) ;
387 string err = (string)
"Error starting element " + tag_name
395 map<string,string>::const_iterator i = attrs->begin() ;
396 map<string,string>::const_iterator e = attrs->end() ;
399 string name = (*i).first ;
400 string val = (*i).second ;
403 rc = xmlTextWriterWriteAttribute( _writer, BAD_CAST name.c_str(),
404 BAD_CAST val.c_str() ) ;
408 string err = (string)
"Error adding attribute " + name
429 string s = ((ostringstream *)
_strm)->str() ;
433 rc = xmlTextWriterWriteString( _writer, BAD_CAST s.c_str() ) ;
437 string err = (string)
"Error writing the value for element "
442 ((ostringstream *)
_strm)->str(
"" ) ;
446 rc = xmlTextWriterEndElement( _writer ) ;
450 string err = (string)
"Error ending element " + tag_name
464 for(
unsigned long i = 0; i < num_spaces; i++ )
479 for(
unsigned long i = 0; i < num_breaks; i++ )
505 begin_tag(
"html",
"",
"http://www.w3.org/1999/xhtml" ) ;
507 string newkey = key +
".HTML" ;
525 if( _started && !_ended )
540 if( _started && !_ended )
558 << (
void *)
this <<
")" << endl ;
virtual void end_response()
virtual void end_response()
end the response
exception thrown if inernal error encountered
virtual void add_data_from_file(const string &key, const string &name)
add data from a file to the informational object.
virtual void add_data_from_file(const string &key, const string &name)
add data from a file to the informational object
virtual void end_tag(const string &tag_name)
end a tagged part of the informational response
virtual void dump(ostream &strm) const
Displays debug information about this object.
virtual void print(ostream &strm)
print the information from this informational object to the specified stream
virtual void begin_response(const string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
BESXMLInfo()
constructs an informational response object as an xml document
informational response object
virtual void add_space(unsigned long num_spaces)
add a space to the informational response
virtual void begin_tag(const string &tag_name, map< string, string > *attrs=0)
static ostream & LMarg(ostream &strm)
virtual void add_break(unsigned long num_breaks)
add a line break to the information
virtual void begin_tag(const string &tag_name, const string &ns, const string &uri, map< string, string > *attrs=0)
begin a tagged part of the information, information to follow
static BESInfo * BuildXMLInfo(const string &info_type)
virtual void send_text(BESInfo &info, BESDataHandlerInterface &dhi)=0
Structure storing information used by the BES to handle the request.
map< string, string > data
the map of string data that will be required for the current request.
virtual void add_tag(const string &tag_name, const string &tag_data, map< string, string > *attrs=0)
add tagged information to the inforamtional response
virtual void begin_response(const string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
virtual void add_data(const string &s)
add data to this informational object.
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)
transmit the text information as text
virtual void dump(ostream &strm) const
dumps information about this object
virtual void add_data(const string &s)
add data to this informational object.
virtual void end_tag(const string &tag_name)