| 793 | } |
| 794 | |
| 795 | static void msGMLWriteItem(FILE *stream, gmlItemObj *item, char *value, const char *namespace, const char *tab) |
| 796 | { |
| 797 | char *encoded_value, *tag_name; |
| 798 | int add_namespace = MS_TRUE; |
| 799 | |
| 800 | if(!stream || !item) return; |
| 801 | if(!item->visible) return; |
| 802 | |
| 803 | if(!namespace) add_namespace = MS_FALSE; |
| 804 | |
| 805 | if(item->encode == MS_TRUE) |
| 806 | encoded_value = msEncodeHTMLEntities(value); |
| 807 | else |
| 808 | encoded_value = msStrdup(value); |
| 809 | |
| 810 | if(!item->template) { /* build the tag from pieces */ |
| 811 | if(item->alias) { |
| 812 | tag_name = item->alias; |
| 813 | if(strchr(item->alias, ':') != NULL) add_namespace = MS_FALSE; |
| 814 | } else { |
| 815 | tag_name = item->name; |
| 816 | if(strchr(item->name, ':') != NULL) add_namespace = MS_FALSE; |
| 817 | } |
| 818 | |
| 819 | if(add_namespace == MS_TRUE && msIsXMLTagValid(tag_name) == MS_FALSE) |
| 820 | msIO_fprintf(stream, "<!-- WARNING: The value '%s' is not valid in a XML tag context. -->\n", tag_name); |
| 821 | |
| 822 | if(add_namespace == MS_TRUE) |
| 823 | msIO_fprintf(stream, "%s<%s:%s>%s</%s:%s>\n", tab, namespace, tag_name, encoded_value, namespace, tag_name); |
| 824 | else |
| 825 | msIO_fprintf(stream, "%s<%s>%s</%s>\n", tab, tag_name, encoded_value, tag_name); |
| 826 | } else { |
| 827 | char *tag = NULL; |
| 828 | |
| 829 | tag = msStrdup(item->template); |
| 830 | tag = msReplaceSubstring(tag, "$value", encoded_value); |
| 831 | if(namespace) tag = msReplaceSubstring(tag, "$namespace", namespace); |
| 832 | msIO_fprintf(stream, "%s%s\n", tab, tag); |
| 833 | free(tag); |
| 834 | } |
| 835 | |
| 836 | free( encoded_value ); |
| 837 | |
| 838 | return; |
| 839 | } |
| 840 | |
| 841 | gmlNamespaceListObj *msGMLGetNamespaces(webObj *web, const char *metadata_namespaces) |
| 842 | { |
no test coverage detected