Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #3428 - correct wfs namespaces in GetCapabilities #4344

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion mapwfs.c
Expand Up @@ -1899,7 +1899,7 @@ int msWFSGetFeature(mapObj *map, wfsParamsObj *paramsObj, cgiRequestObj *req, ow
}
if (psFormat == NULL) {
msSetError(MS_WFSERR,
"'%s' is not a permitted output format for layer '%s', review wfs_formats setting.",
"'%s' is not a permitted output format for layer '%s', review wfs_getfeature_formatlist setting.",
"msWFSGetFeature()",
paramsObj->pszOutputFormat,
lp->name );
Expand Down
30 changes: 29 additions & 1 deletion mapwfs11.c
Expand Up @@ -120,9 +120,16 @@ static xmlNodePtr msWFSDumpLayer11(mapObj *map, layerObj *lp, xmlNsPtr psNsOws)

psRootNode = xmlNewNode(NULL, BAD_CAST "FeatureType");

/* add namespace to layer name */
value = msOWSLookupMetadata(&(map->web.metadata), "FO", "namespace_prefix");
n = strlen(value)+strlen(lp->name)+1+1;
valueToFree = (char *) msSmallMalloc(sizeof(char*)*n);
snprintf(valueToFree, n, "%s%s%s", (value ? value : ""), (value ? ":" : ""), lp->name);

/*if there is an encoding using it on some of the items*/
psNode = msOWSCommonxmlNewChildEncoded(psRootNode, NULL, "Name", lp->name, encoding);
psNode = msOWSCommonxmlNewChildEncoded(psRootNode, NULL, "Name", valueToFree, encoding);

msFree(valueToFree);

if (lp->name && strlen(lp->name) > 0 &&
(msIsXMLTagValid(lp->name) == MS_FALSE || isdigit(lp->name[0])))
Expand Down Expand Up @@ -253,6 +260,9 @@ int msWFSGetCapabilities11(mapObj *map, wfsParamsObj *params,
xmlNsPtr psNsOws, psNsXLink, psNsOgc;
char *schemalocation = NULL;
char *xsi_schemaLocation = NULL;
const char *user_namespace_prefix = NULL;
const char *user_namespace_uri = NULL;
gmlNamespaceListObj *namespaceList=NULL; /* for external application schema support */

char *script_url=NULL, *script_url_encoded=NULL, *formats_list;
const char *value = NULL;
Expand Down Expand Up @@ -307,6 +317,24 @@ int msWFSGetCapabilities11(mapObj *map, wfsParamsObj *params,
xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_W3C_XSI_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_W3C_XSI_NAMESPACE_PREFIX);
xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_OGC_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_OGC_NAMESPACE_PREFIX );

value = msOWSLookupMetadata(&(map->web.metadata), "FO", "namespace_uri");
if(value) user_namespace_uri = value;

value = msOWSLookupMetadata(&(map->web.metadata), "FO", "namespace_prefix");
if(value) user_namespace_prefix = value;
if(user_namespace_prefix != NULL && msIsXMLTagValid(user_namespace_prefix) == MS_FALSE)
msIO_printf("<!-- WARNING: The value '%s' is not valid XML namespace. -->\n", user_namespace_prefix);
else
xmlNewNs(psRootNode, BAD_CAST user_namespace_uri, BAD_CAST user_namespace_prefix);

/* any additional namespaces */
namespaceList = msGMLGetNamespaces(&(map->web), "G");
for(i=0; i<namespaceList->numnamespaces; i++) {
if(namespaceList->namespaces[i].uri) {
xmlNewNs(psRootNode, BAD_CAST namespaceList->namespaces[i].uri, BAD_CAST namespaceList->namespaces[i].prefix);
}
}

xmlNewProp(psRootNode, BAD_CAST "version", BAD_CAST params->pszVersion );

updatesequence = msOWSLookupMetadata(&(map->web.metadata), "FO", "updatesequence");
Expand Down