Changes between Initial Version and Version 1 of UsingMapOWSCommon


Ignore:
Timestamp:
Jun 19, 2007, 8:22:16 AM (17 years ago)
Author:
tomkralidis
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UsingMapOWSCommon

    v1 v1  
     1
     2Using mapowscommon.c
     3
     4mapowscommon implements the OGC OWS Common Specification
     5
     6- version 1.0.0
     7- OGC document: OGC 05-008
     8
     9The library uses libxml2 (http://www.xmlsoft.org/) to create
     10XML objects.
     11
     12The library uses the tree and parser modules of libxml2.
     13
     14The library returns xmlNodePtr objects to the calling code.
     15
     16To implement, the calling code must instantiate an xmlNewDoc
     17object:
     18
     19{{{
     20/* use libxml2: */
     21
     22#include "libxml/parser.h"
     23#include "libxml/tree.h"
     24
     25#include "mapowscommon.h"
     26
     27static int msSOSException(mapObj *map, char *locator, char *exceptionCode)
     28  xmlDocPtr  psDoc      = NULL;
     29  xmlNodePtr psRootNode = NULL;
     30  xmlChar    *buffer    = NULL;
     31  int size = 0;
     32
     33  /* create XML document object */
     34  psDoc = xmlNewDoc(BAD_CAST "1.0");
     35
     36  /* generate a service exception object */
     37  psRootNode = msOWSCommonExceptionReport(msEncodeHTMLEntities(msOWSGetSchemasLocation(map)), pszSOSVersion, msOWSGetLanguage(map, "exception"), exceptionCode, locator, msEncodeHTMLEntities(msGetErrorString("\n")));
     38
     39  /* set the root element of the document */
     40  xmlDocSetRootElement(psDoc, psRootNode);
     41
     42  /* set the namespace of the document */
     43  xmlSetNs(psRootNode,  xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_PREFIX));
     44  msIO_printf("Content-type: text/xml%c%c",10,10);
     45
     46  /* dump the libxml2 object to a string for output */
     47  xmlDocDumpFormatMemoryEnc(psDoc, &buffer, &size, "ISO-8859-1", 1);
     48
     49  msIO_printf("%s", buffer);
     50
     51  /*free buffer and the document */
     52  xmlFree(buffer);
     53  xmlFreeDoc(psDoc);
     54
     55  /* clear error since we have already reported it */
     56  msResetErrorList();
     57
     58  return MS_FAILURE;
     59}
     60
     61
     62}}}
     63
     64NOTES:
     65
     66- with the exception of msOWSCommonExceptionReport, ALL functions return
     67an XML chunk.  It is the responsibility of the calling code to setup the
     68root element with correct namespace decls and schema pointers
     69
     70- msOWSCommonExceptionReport returns an entire, complete and valid XML
     71document, as it is the only XML in OWS Common which is designed to be
     72implemented standalone