1 /******************************************************************************
2  * $Id$
3  *
4  * Project:  MapServer
5  * Purpose:  OGC OWS Common Implementation include file
6  * Author:   Tom Kralidis (tomkralidis@gmail.com)
7  *
8  ******************************************************************************
9  * Copyright (c) 2006, Tom Kralidis
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included in
19  * all copies of this Software or works derived from this Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  ****************************************************************************/
29 
30 #ifndef MAPOWSCOMMON_H
31 #define MAPOWSCOMMON_H
32 
33 #ifdef USE_LIBXML2
34 
35 #include<libxml/parser.h>
36 #include<libxml/tree.h>
37 
38 #endif
39 
40 /* W3C namespaces */
41 
42 #define MS_OWSCOMMON_W3C_XLINK_NAMESPACE_URI      "http://www.w3.org/1999/xlink"
43 #define MS_OWSCOMMON_W3C_XLINK_NAMESPACE_PREFIX   "xlink"
44 
45 #define MS_OWSCOMMON_W3C_XSI_NAMESPACE_URI        "http://www.w3.org/2001/XMLSchema-instance"
46 #define MS_OWSCOMMON_W3C_XSI_NAMESPACE_PREFIX     "xsi"
47 
48 #define MS_OWSCOMMON_W3C_XS_NAMESPACE_URI         "http://www.w3.org/2001/XMLSchema"
49 #define MS_OWSCOMMON_W3C_XS_NAMESPACE_PREFIX      "xs"
50 
51 /* OGC namespaces */
52 
53 #define MS_OWSCOMMON_OGC_NAMESPACE_URI      "http://www.opengis.net/ogc"
54 #define MS_OWSCOMMON_OGC_NAMESPACE_PREFIX   "ogc"
55 
56 #define MS_OWSCOMMON_OWS_NAMESPACE_URI      "http://www.opengis.net/ows"
57 #define MS_OWSCOMMON_OWS_NAMESPACE_PREFIX   "ows"
58 
59 #define MS_OWSCOMMON_OWS_110_NAMESPACE_URI      "http://www.opengis.net/ows/1.1"
60 
61 #define MS_OWSCOMMON_OWS_20_NAMESPACE_URI   "http://www.opengis.net/ows/2.0"
62 #define MS_OWSCOMMON_OWS_20_SCHEMAS_LOCATION    "/ows/2.0/owsAll.xsd"
63 
64 /* OGC URNs */
65 
66 #define MS_OWSCOMMON_URN_OGC_CRS_4326 "urn:opengis:def:crs:OGC:2:84"
67 
68 /* default OGC Schemas Location */
69 
70 #define MS_OWSCOMMON_SCHEMAS_LOCATION "http://schemas.opengis.net"
71 
72 /* OGC codespace */
73 
74 #define MS_OWSCOMMON_OGC_CODESPACE "OGC"
75 
76 /* WCS namespaces */
77 
78 #define MS_OWSCOMMON_WCS_20_NAMESPACE_URI   "http://www.opengis.net/wcs/2.0"
79 #define MS_OWSCOMMON_WCS_20_SCHEMAS_LOCATION    "/wcs/2.0/wcsAll.xsd"
80 #define MS_OWSCOMMON_WCS_NAMESPACE_PREFIX   "wcs"
81 
82 /* GML namespaces */
83 
84 #define MS_OWSCOMMON_GML_NAMESPACE_URI      "http://www.opengis.net/gml"
85 #define MS_OWSCOMMON_GML_NAMESPACE_PREFIX   "gml"
86 
87 #define MS_OWSCOMMON_GML_32_NAMESPACE_URI   "http://www.opengis.net/gml/3.2"
88 
89 #define MS_OWSCOMMON_GML_212_SCHEMA_LOCATION       "/gml/2.1.2/feature.xsd"
90 #define MS_OWSCOMMON_GML_311_SCHEMA_LOCATION       "/gml/3.1.1/base/gml.xsd"
91 #define MS_OWSCOMMON_GML_321_SCHEMA_LOCATION       "/gml/3.2.1/gml.xsd"
92 
93 /* WFS namespaces */
94 
95 #define MS_OWSCOMMON_WFS_NAMESPACE_PREFIX          "wfs"
96 #define MS_OWSCOMMON_WFS_NAMESPACE_URI             "http://www.opengis.net/wfs"
97 #define MS_OWSCOMMON_WFS_20_NAMESPACE_URI          "http://www.opengis.net/wfs/2.0"
98 
99 #define MS_OWSCOMMON_WFS_10_SCHEMA_LOCATION        "/wfs/1.0.0/WFS-basic.xsd"
100 #define MS_OWSCOMMON_WFS_11_SCHEMA_LOCATION        "/wfs/1.1.0/wfs.xsd"
101 #define MS_OWSCOMMON_WFS_20_SCHEMA_LOCATION        "/wfs/2.0/wfs.xsd"
102 
103 /* FES namespaces */
104 
105 #define MS_OWSCOMMON_FES_20_NAMESPACE_PREFIX       "fes"
106 #define MS_OWSCOMMON_FES_20_NAMESPACE_URI          "http://www.opengis.net/fes/2.0"
107 
108 #define MS_OWSCOMMON_FES_20_SCHEMA_LOCATION        "/filter/2.0/filterAll.xsd"
109 
110 /* GMLCov namespaces */
111 
112 #define MS_OWSCOMMON_GMLCOV_10_NAMESPACE_URI    "http://www.opengis.net/gmlcov/1.0"
113 #define MS_OWSCOMMON_GMLCOV_NAMESPACE_PREFIX    "gmlcov"
114 
115 /* SWE namespaces */
116 #define MS_OWSCOMMON_SWE_20_NAMESPACE_URI   "http://www.opengis.net/swe/2.0"
117 #define MS_OWSCOMMON_SWE_NAMESPACE_PREFIX   "swe"
118 
119 /* Inspire namespaces */
120 
121 #define MS_INSPIRE_COMMON_NAMESPACE_URI     "http://inspire.ec.europa.eu/schemas/common/1.0"
122 #define MS_INSPIRE_COMMON_NAMESPACE_PREFIX  "inspire_common"
123 #define MS_INSPIRE_COMMON_SCHEMA_LOCATION   "/common/1.0/common.xsd"
124 
125 #define MS_INSPIRE_VS_NAMESPACE_URI         "http://inspire.ec.europa.eu/schemas/inspire_vs/1.0"
126 #define MS_INSPIRE_VS_NAMESPACE_PREFIX      "inspire_vs"
127 #define MS_INSPIRE_VS_SCHEMA_LOCATION       "/inspire_vs/1.0/inspire_vs.xsd"
128 
129 #define MS_INSPIRE_DLS_NAMESPACE_URI        "http://inspire.ec.europa.eu/schemas/inspire_dls/1.0"
130 #define MS_INSPIRE_DLS_NAMESPACE_PREFIX     "inspire_dls"
131 #define MS_INSPIRE_DLS_SCHEMA_LOCATION      "/inspire_dls/1.0/inspire_dls.xsd"
132 
133 
134 /* MapServer namespaces */
135 #define MS_DEFAULT_NAMESPACE_PREFIX         "ms"
136 #define MS_DEFAULT_NAMESPACE_URI            "http://mapserver.gis.umn.edu/mapserver"
137 
138 
139 /* OWS errors */
140 
141 /* OWS 1.1.0 Table 25 */
142 #define MS_OWS_ERROR_OPERATION_NOT_SUPPORTED    "OperationNotSupported"
143 #define MS_OWS_ERROR_MISSING_PARAMETER_VALUE    "MissingParameterValue"
144 #define MS_OWS_ERROR_INVALID_PARAMETER_VALUE    "InvalidParameterValue"
145 #define MS_OWS_ERROR_VERSION_NEGOTIATION_FAILED "VersionNegotiationFailed"
146 #define MS_OWS_ERROR_INVALID_UPDATE_SEQUENCE    "InvalidUpdateSequence"
147 #define MS_OWS_ERROR_OPTION_NOT_SUPPORTED       "OptionNotSupported"
148 #define MS_OWS_ERROR_NO_APPLICABLE_CODE         "NoApplicableCode"
149 
150 #define MS_WFS_ERROR_OPERATION_PROCESSING_FAILED "OperationProcessingFailed"
151 
152 #ifdef USE_LIBXML2
153 
154 /* function prototypes */
155 
156 
157 xmlNodePtr msOWSCommonServiceIdentification(xmlNsPtr psNsOws, mapObj *map,
158                                             const char *servicetype,
159                                             const char *version,
160                                             const char *namespaces,
161                                             const char *validated_language);
162 
163 xmlNodePtr msOWSCommonServiceProvider(xmlNsPtr psNsOws,
164                                       xmlNsPtr psXLinkNs,
165                                       mapObj *map,
166                                       const char *namespaces,
167                                       const char *validated_language);
168 
169 xmlNodePtr msOWSCommonOperationsMetadata(xmlNsPtr psNsOws);
170 
171 #define OWS_METHOD_GET     1
172 #define OWS_METHOD_POST    2
173 #define OWS_METHOD_GETPOST 3
174 
175 xmlNodePtr msOWSCommonOperationsMetadataOperation(xmlNsPtr psNsOws, xmlNsPtr psXLinkNs, char *name, int method, char *url);
176 
177 xmlNodePtr msOWSCommonOperationsMetadataDomainType(int version, xmlNsPtr psNsOws, char *elname, char *name, char *values);
178 
179 xmlNodePtr msOWSCommonExceptionReport(xmlNsPtr psNsOws, int ows_version, const char *schemas_location, const char *version, const char *language, const char *exceptionCode, const char *locator, const char *ExceptionText);
180 
181 xmlNodePtr msOWSCommonBoundingBox(xmlNsPtr psNsOws, const char *crs, int dimensions, double minx, double miny, double maxx, double maxy);
182 
183 xmlNodePtr msOWSCommonWGS84BoundingBox(xmlNsPtr psNsOws, int dimensions, double minx, double miny, double maxx, double maxy);
184 
185 int _validateNamespace(xmlNsPtr psNsOws);
186 
187 int msOWSSchemaValidation(const char* xml_schema, const char* xml);
188 
189 #endif /* defined(USE_LIBXML2) */
190 
191 int msOWSCommonNegotiateVersion(int requested_version, const int supported_versions[], int num_supported_versions);
192 
193 #endif /* MAPOWSCOMMON_H */
194