Changeset 79
- Timestamp:
- Jan 16, 2011, 3:37:26 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/service_internal.c
r76 r79 749 749 nc3 = xmlNewNode(NULL, BAD_CAST e->format); 750 750 }else{ 751 if(strncasecmp(e->format,"LITERALDATA",strlen(e->format))==0) 751 if(strncasecmp(e->format,"LITERALDATA",strlen(e->format))==0){ 752 752 nc3 = xmlNewNode(NULL, BAD_CAST "LiteralData"); 753 } 753 754 else if(strncasecmp(e->format,"COMPLEXDATA",strlen(e->format))==0) 754 755 nc3 = xmlNewNode(NULL, BAD_CAST "ComplexData"); … … 760 761 iotype* _tmp=e->defaults; 761 762 int datatype=0; 763 bool hasDefault=false; 764 bool hasUOM=false; 762 765 if(_tmp!=NULL){ 763 if(strcmp(e->format,"LiteralOutput")==0 ||764 strcmp(e->format,"LiteralData")==0){766 if(strcmp(e->format,"LiteralOutput")==0 || 767 strcmp(e->format,"LiteralData")==0){ 765 768 datatype=1; 766 769 nc4 = xmlNewNode(NULL, BAD_CAST "UOMs"); 767 770 nc5 = xmlNewNode(NULL, BAD_CAST "Default"); 768 } 769 else if(strcmp(e->format,"BoundingBoxOutput")==0 || 770 strcmp(e->format,"BoundingBoxData")==0){ 771 datatype=2; 772 //nc4 = xmlNewNode(NULL, BAD_CAST "BoundingBoxOutput"); 773 nc5 = xmlNewNode(NULL, BAD_CAST "Default"); 774 } 775 else{ 776 nc4 = xmlNewNode(NULL, BAD_CAST "Default"); 777 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 778 } 779 780 tmp1=_tmp->content; 781 int avcnt=0; 782 int dcnt=0; 783 int oI=0; 784 for(oI=0;oI<7;oI++) 785 if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){ 786 //while(tmp1!=NULL){ 787 #ifdef DEBUG 788 printf("DATATYPE DEFAULT ? %s\n",tmp1->name); 789 #endif 790 if(strncasecmp(tmp1->name,"DataType",8)==0){ 791 nc6 = xmlNewNode(ns_ows, BAD_CAST "DataType"); 792 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 793 char tmp[1024]; 794 sprintf(tmp,"http://www.w3.org/TR/xmlschema-2/#%s",tmp1->value); 795 xmlNewNsProp(nc6,ns_ows,BAD_CAST "reference",BAD_CAST tmp); 796 xmlAddChild(nc3,nc6); 797 tmp1=tmp1->next; 798 datatype=1; 799 continue; 800 } 801 if(strcmp(tmp1->name,"asReference")!=0 && 802 strncasecmp(tmp1->name,"DataType",8)!=0 && 803 strcasecmp(tmp1->name,"extension")!=0 && 804 strcasecmp(tmp1->name,"value")!=0 && 805 strncasecmp(tmp1->name,"AllowedValues",13)!=0){ 806 if(datatype!=1){ 807 char *tmp2=zCapitalize1(tmp1->name); 808 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 809 free(tmp2); 810 } 811 else{ 812 char *tmp2=zCapitalize(tmp1->name); 813 nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2); 814 free(tmp2); 815 } 816 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 817 xmlAddChild(nc5,nc6); 818 }else 819 if(strncmp(type,"Input",5)==0){ 820 if(strcmp(tmp1->name,"value")==0){ 821 nc7 = xmlNewNode(NULL, BAD_CAST "DefaultValue"); 822 xmlAddChild(nc7,xmlNewText(BAD_CAST tmp1->value)); 823 default1=1; 824 } 825 if(strncasecmp(tmp1->name,"AllowedValues",13)==0){ 826 nc6 = xmlNewNode(ns_ows, BAD_CAST "AllowedValues"); 827 char *token,*saveptr1; 828 token=strtok_r(tmp1->value,",",&saveptr1); 829 while(token!=NULL){ 830 nc7 = xmlNewNode(ns_ows, BAD_CAST "Value"); 831 char *tmps=strdup(token); 832 tmps[strlen(tmps)]=0; 833 xmlAddChild(nc7,xmlNewText(BAD_CAST tmps)); 834 fprintf(stderr,"strgin : %s\n",tmps); 835 xmlAddChild(nc6,nc7); 836 token=strtok_r(NULL,",",&saveptr1); 837 } 838 xmlAddChild(nc3,nc6); 839 isAnyValue=-1; 840 } 841 } 842 tmp1=tmp1->next; 843 if(datatype!=2){ 844 xmlAddChild(nc4,nc5); 845 xmlAddChild(nc3,nc4); 846 }else{ 847 fprintf(stderr,"OK \n"); 848 xmlAddChild(nc3,nc5); 849 fprintf(stderr,"OK \n"); 850 } 771 } 772 else if(strcmp(e->format,"BoundingBoxOutput")==0 || 773 strcmp(e->format,"BoundingBoxData")==0){ 774 datatype=2; 775 //nc4 = xmlNewNode(NULL, BAD_CAST "BoundingBoxOutput"); 776 nc5 = xmlNewNode(NULL, BAD_CAST "Default"); 777 } 778 else{ 779 nc4 = xmlNewNode(NULL, BAD_CAST "Default"); 780 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 781 } 782 783 tmp1=_tmp->content; 784 int avcnt=0; 785 int dcnt=0; 786 int oI=0; 787 for(oI=0;oI<7;oI++) 788 if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){ 789 //while(tmp1!=NULL){ 790 #ifdef DEBUG 791 printf("DATATYPE DEFAULT ? %s\n",tmp1->name); 792 #endif 793 if(strncasecmp(tmp1->name,"DataType",8)==0){ 794 nc6 = xmlNewNode(ns_ows, BAD_CAST "DataType"); 795 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 796 char tmp[1024]; 797 sprintf(tmp,"http://www.w3.org/TR/xmlschema-2/#%s",tmp1->value); 798 xmlNewNsProp(nc6,ns_ows,BAD_CAST "reference",BAD_CAST tmp); 799 xmlAddChild(nc3,nc6); 800 tmp1=tmp1->next; 801 datatype=1; 802 continue; 803 } 804 if(strcmp(tmp1->name,"asReference")!=0 && 805 strncasecmp(tmp1->name,"DataType",8)!=0 && 806 strcasecmp(tmp1->name,"extension")!=0 && 807 strcasecmp(tmp1->name,"value")!=0 && 808 strncasecmp(tmp1->name,"AllowedValues",13)!=0){ 809 if(datatype!=1){ 810 char *tmp2=zCapitalize1(tmp1->name); 811 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 812 free(tmp2); 813 } 814 else{ 815 char *tmp2=zCapitalize(tmp1->name); 816 nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2); 817 free(tmp2); 818 } 819 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 820 xmlAddChild(nc5,nc6); 821 hasUOM=true; 822 }else 823 if(strncmp(type,"Input",5)==0){ 824 if(strcmp(tmp1->name,"value")==0){ 825 nc7 = xmlNewNode(NULL, BAD_CAST "DefaultValue"); 826 xmlAddChild(nc7,xmlNewText(BAD_CAST tmp1->value)); 827 default1=1; 828 } 829 if(strncasecmp(tmp1->name,"AllowedValues",13)==0){ 830 nc6 = xmlNewNode(ns_ows, BAD_CAST "AllowedValues"); 831 fprintf(stderr,"ALLOWED VALUE %s\n",tmp1->value); 832 char *token,*saveptr1; 833 token=strtok_r(tmp1->value,",",&saveptr1); 834 while(token!=NULL){ 835 nc7 = xmlNewNode(ns_ows, BAD_CAST "Value"); 836 char *tmps=strdup(token); 837 tmps[strlen(tmps)]=0; 838 xmlAddChild(nc7,xmlNewText(BAD_CAST tmps)); 839 fprintf(stderr,"strgin : %s\n",tmps); 840 xmlAddChild(nc6,nc7); 841 token=strtok_r(NULL,",",&saveptr1); 842 } 843 xmlAddChild(nc3,nc6); 844 isAnyValue=-1; 845 } 846 hasDefault=true; 847 } 848 tmp1=tmp1->next; 849 if(datatype!=2){ 850 if(hasUOM==true){ 851 xmlAddChild(nc4,nc5); 852 xmlAddChild(nc3,nc4); 853 } 854 }else{ 855 xmlAddChild(nc3,nc5); 856 } 851 857 852 if(strncmp(type,"Input",5)==0){ 853 if(datatype==1 && isAnyValue==1 && avcnt==0){ 854 xmlAddChild(nc3,xmlNewNode(ns_ows, BAD_CAST "AnyValue")); 855 avcnt++; 856 } 857 if(datatype==1 && default1>0){ 858 xmlAddChild(nc3,nc7); 859 } 860 } 861 } 858 if(strncmp(type,"Input",5)==0){ 859 if(datatype==1 && isAnyValue==1 && avcnt==0){ 860 xmlAddChild(nc3,xmlNewNode(ns_ows, BAD_CAST "AnyValue")); 861 hasDefault=true; 862 avcnt++; 863 } 864 if(datatype==1 && default1>0){ 865 xmlAddChild(nc3,nc7); 866 } 867 } 868 } 862 869 } 863 870 _tmp=e->supported; … … 899 906 tmps=strtok_r(tmp1->value,",",&tmpv); 900 907 while(tmps){ 901 fprintf(stderr,"Element %s\n",tmps);902 908 xmlAddChild(nc6,xmlNewText(BAD_CAST tmps)); 903 909 xmlAddChild(nc5,nc6); … … 909 915 } 910 916 } 911 //free(tmpv);912 917 } 913 918 else{ … … 924 929 }else 925 930 xmlAddChild(nc3,nc5); 926 fprintf(stderr,"OK \n");927 931 hasSupported=1; 928 932 } … … 937 941 xmlAddChild(nc2,nc3); 938 942 939 if(datatype!=2 ){943 if(datatype!=2 && hasUOM==true){ 940 944 xmlAddChild(nc3,nc4); 941 945 xmlAddChild(nc2,nc3); 946 }else if(datatype!=2){ 947 if(hasDefault!=true) 948 xmlAddChild(nc3,xmlNewNode(ns_ows, BAD_CAST "AnyValue")); 949 xmlFreeNodeList(nc5); 950 xmlFreeNodeList(nc4); 942 951 } 943 952
Note: See TracChangeset
for help on using the changeset viewer.