Changeset 71
- Timestamp:
- Jan 13, 2011, 2:47:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/service_internal.c
r70 r71 308 308 if(tmp4!=NULL){ 309 309 map* tmp2=tmp4->content; 310 while(tmp2!=NULL){ 311 if(strcasecmp(tmp2->name,"abstract")==0 || 312 strcasecmp(tmp2->name,"title")==0 || 313 strcasecmp(tmp2->name,"accessConstraints")==0 || 314 strcasecmp(tmp2->name,"fess")==0){ 315 tmp2->name[0]=toupper(tmp2->name[0]); 316 nc1 = xmlNewNode(ns_ows, BAD_CAST tmp2->name); 317 xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value)); 318 xmlAddChild(nc,nc1); 319 } 320 else 321 if(strcmp(tmp2->name,"keywords")==0){ 322 nc1 = xmlNewNode(ns_ows, BAD_CAST "Keywords"); 323 char *toto=tmp2->value; 324 char buff[256]; 325 int i=0; 326 int j=0; 327 while(toto[i]){ 328 if(toto[i]!=',' && toto[i]!=0){ 329 buff[j]=toto[i]; 330 buff[j+1]=0; 331 j++; 310 char *orderedFields[5]; 311 orderedFields[0]="Title"; 312 orderedFields[1]="Abstract"; 313 orderedFields[2]="Keywords"; 314 orderedFields[3]="Fees"; 315 orderedFields[4]="AccessConstraints"; 316 int oI=0; 317 for(oI=0;oI<5;oI++) 318 if((tmp2=getMap(tmp4->content,orderedFields[oI]))!=NULL){ 319 if(strcasecmp(tmp2->name,"abstract")==0 || 320 strcasecmp(tmp2->name,"title")==0 || 321 strcasecmp(tmp2->name,"accessConstraints")==0 || 322 strcasecmp(tmp2->name,"fees")==0){ 323 tmp2->name[0]=toupper(tmp2->name[0]); 324 nc1 = xmlNewNode(ns_ows, BAD_CAST tmp2->name); 325 xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value)); 326 xmlAddChild(nc,nc1); 327 } 328 else 329 if(strcmp(tmp2->name,"keywords")==0){ 330 nc1 = xmlNewNode(ns_ows, BAD_CAST "Keywords"); 331 char *toto=tmp2->value; 332 char buff[256]; 333 int i=0; 334 int j=0; 335 while(toto[i]){ 336 if(toto[i]!=',' && toto[i]!=0){ 337 buff[j]=toto[i]; 338 buff[j+1]=0; 339 j++; 340 } 341 else{ 342 nc2 = xmlNewNode(ns_ows, BAD_CAST "Keyword"); 343 xmlAddChild(nc2,xmlNewText(BAD_CAST buff)); 344 xmlAddChild(nc1,nc2); 345 j=0; 346 } 347 i++; 332 348 } 333 else{349 if(strlen(buff)>0){ 334 350 nc2 = xmlNewNode(ns_ows, BAD_CAST "Keyword"); 335 351 xmlAddChild(nc2,xmlNewText(BAD_CAST buff)); 336 352 xmlAddChild(nc1,nc2); 337 j=0;338 353 } 339 i++; 354 xmlAddChild(nc,nc1); 355 nc2 = xmlNewNode(ns_ows, BAD_CAST "ServiceType"); 356 xmlAddChild(nc2,xmlNewText(BAD_CAST "WPS")); 357 xmlAddChild(nc,nc2); 358 nc2 = xmlNewNode(ns_ows, BAD_CAST "ServiceTypeVersion"); 359 xmlAddChild(nc2,xmlNewText(BAD_CAST "1.0.0")); 360 xmlAddChild(nc,nc2); 340 361 } 341 if(strlen(buff)>0){ 342 nc2 = xmlNewNode(ns_ows, BAD_CAST "Keyword"); 343 xmlAddChild(nc2,xmlNewText(BAD_CAST buff)); 344 xmlAddChild(nc1,nc2); 345 } 346 xmlAddChild(nc,nc1); 347 nc2 = xmlNewNode(ns_ows, BAD_CAST "ServiceType"); 348 xmlAddChild(nc2,xmlNewText(BAD_CAST "WPS")); 349 xmlAddChild(nc,nc2); 350 nc2 = xmlNewNode(ns_ows, BAD_CAST "ServiceTypeVersion"); 351 xmlAddChild(nc2,xmlNewText(BAD_CAST "1.0.0")); 352 xmlAddChild(nc,nc2); 353 } 354 tmp2=tmp2->next; 355 } 362 tmp2=tmp2->next; 363 } 356 364 } 357 365 else{ … … 379 387 tmpPhone[0]="phoneVoice"; 380 388 tmpPhone[1]="phoneFacsimile"; 381 while(tmp2!=NULL){ 382 if(strcmp(tmp2->name,"keywords")!=0 && 383 strcmp(tmp2->name,"serverAddress")!=0 && 384 strcmp(tmp2->name,"lang")!=0){ 385 tmp2->name[0]=toupper(tmp2->name[0]); 386 if(strcmp(tmp2->name,"ProviderName")==0){ 387 nc1 = xmlNewNode(ns_ows, BAD_CAST tmp2->name); 388 xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value)); 389 xmlAddChild(nc,nc1); 390 } 391 else{ 392 if(strcmp(tmp2->name,"ProviderSite")==0){ 389 char *orderedFields[12]; 390 orderedFields[0]="providerName"; 391 orderedFields[1]="providerSite"; 392 orderedFields[2]="individualName"; 393 orderedFields[3]="positionName"; 394 orderedFields[4]=tmpPhone[0]; 395 orderedFields[5]=tmpPhone[1]; 396 orderedFields[6]=tmpAddress[0]; 397 orderedFields[7]=tmpAddress[1]; 398 orderedFields[8]=tmpAddress[2]; 399 orderedFields[9]=tmpAddress[3]; 400 orderedFields[10]=tmpAddress[4]; 401 orderedFields[11]=tmpAddress[5]; 402 int oI=0; 403 for(oI=0;oI<12;oI++) 404 if((tmp2=getMap(tmp4->content,orderedFields[oI]))!=NULL){ 405 if(strcmp(tmp2->name,"keywords")!=0 && 406 strcmp(tmp2->name,"serverAddress")!=0 && 407 strcmp(tmp2->name,"lang")!=0){ 408 tmp2->name[0]=toupper(tmp2->name[0]); 409 if(strcmp(tmp2->name,"ProviderName")==0){ 393 410 nc1 = xmlNewNode(ns_ows, BAD_CAST tmp2->name); 394 xml NewNsProp(nc1,ns_xlink,BAD_CAST "href",BAD_CAST tmp2->value);411 xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value)); 395 412 xmlAddChild(nc,nc1); 396 } 397 else 398 if(strcmp(tmp2->name,"IndividualName")==0 || 399 strcmp(tmp2->name,"PositionName")==0){ 413 } 414 else{ 415 if(strcmp(tmp2->name,"ProviderSite")==0){ 400 416 nc1 = xmlNewNode(ns_ows, BAD_CAST tmp2->name); 401 xml AddChild(nc1,xmlNewText(BAD_CAST tmp2->value));402 xmlAddChild(nc 3,nc1);417 xmlNewNsProp(nc1,ns_xlink,BAD_CAST "href",BAD_CAST tmp2->value); 418 xmlAddChild(nc,nc1); 403 419 } 404 else 405 if(strncmp(tmp2->name,"Phone",5)==0){ 406 int j; 407 for(j=0;j<2;j++) 408 if(strcasecmp(tmp2->name,tmpPhone[j])==0){ 409 char *toto=NULL; 410 char *toto1=tmp2->name; 411 toto=strstr(toto1,"Phone"); 412 nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+5); 413 xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value)); 414 xmlAddChild(nc5,nc1); 415 } 416 } 420 else 421 if(strcmp(tmp2->name,"IndividualName")==0 || 422 strcmp(tmp2->name,"PositionName")==0){ 423 nc1 = xmlNewNode(ns_ows, BAD_CAST tmp2->name); 424 xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value)); 425 xmlAddChild(nc3,nc1); 426 } 417 427 else 418 if(strncmp(tmp2->name," Address",7)==0){428 if(strncmp(tmp2->name,"Phone",5)==0){ 419 429 int j; 420 for(j=0;j< 6;j++)421 if(strcasecmp(tmp2->name,tmp Address[j])==0){430 for(j=0;j<2;j++) 431 if(strcasecmp(tmp2->name,tmpPhone[j])==0){ 422 432 char *toto=NULL; 423 433 char *toto1=tmp2->name; 424 toto=strstr(toto1," Address");425 nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+ 7);434 toto=strstr(toto1,"Phone"); 435 nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+5); 426 436 xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value)); 427 xmlAddChild(nc 6,nc1);437 xmlAddChild(nc5,nc1); 428 438 } 429 439 } 440 else 441 if(strncmp(tmp2->name,"Address",7)==0){ 442 int j; 443 for(j=0;j<6;j++) 444 if(strcasecmp(tmp2->name,tmpAddress[j])==0){ 445 char *toto=NULL; 446 char *toto1=tmp2->name; 447 toto=strstr(toto1,"Address"); 448 nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+7); 449 xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value)); 450 xmlAddChild(nc6,nc1); 451 } 452 } 453 } 430 454 } 431 } 432 else 433 if(strcmp(tmp2->name,"keywords")==0){ 434 nc1 = xmlNewNode(ns_ows, BAD_CAST "Keywords"); 435 char *toto=tmp2->value; 436 char buff[256]; 437 int i=0; 438 int j=0; 439 while(toto[i]){ 440 if(toto[i]!=',' && toto[i]!=0){ 441 buff[j]=toto[i]; 442 buff[j+1]=0; 443 j++; 455 else 456 if(strcmp(tmp2->name,"keywords")==0){ 457 nc1 = xmlNewNode(ns_ows, BAD_CAST "Keywords"); 458 char *toto=tmp2->value; 459 char buff[256]; 460 int i=0; 461 int j=0; 462 while(toto[i]){ 463 if(toto[i]!=',' && toto[i]!=0){ 464 buff[j]=toto[i]; 465 buff[j+1]=0; 466 j++; 467 } 468 else{ 469 nc2 = xmlNewNode(ns_ows, BAD_CAST "Keyword"); 470 xmlAddChild(nc2,xmlNewText(BAD_CAST buff)); 471 xmlAddChild(nc1,nc2); 472 j=0; 473 } 474 i++; 444 475 } 445 else{476 if(strlen(buff)>0){ 446 477 nc2 = xmlNewNode(ns_ows, BAD_CAST "Keyword"); 447 478 xmlAddChild(nc2,xmlNewText(BAD_CAST buff)); 448 479 xmlAddChild(nc1,nc2); 449 j=0;450 480 } 451 i++;481 xmlAddChild(nc,nc1); 452 482 } 453 if(strlen(buff)>0){ 454 nc2 = xmlNewNode(ns_ows, BAD_CAST "Keyword"); 455 xmlAddChild(nc2,xmlNewText(BAD_CAST buff)); 456 xmlAddChild(nc1,nc2); 457 } 458 xmlAddChild(nc,nc1); 459 } 460 tmp2=tmp2->next; 461 } 483 tmp2=tmp2->next; 484 } 462 485 } 463 486 else{ … … 708 731 int default1=0; 709 732 xmlNodePtr nc7; 710 while(tmp1!=NULL){ 711 #ifdef DEBUG 712 printf("DATATYPE DEFAULT ? %s\n",tmp1->name); 713 #endif 714 if(strncasecmp(tmp1->name,"DataType",8)==0){ 715 nc6 = xmlNewNode(ns_ows, BAD_CAST "DataType"); 716 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 717 char tmp[1024]; 718 sprintf(tmp,"http://www.w3.org/TR/xmlschema-2/#%s",tmp1->value); 719 xmlNewNsProp(nc6,ns_ows,BAD_CAST "reference",BAD_CAST tmp); 720 xmlAddChild(nc3,nc6); 721 tmp1=tmp1->next; 722 continue; 723 } 724 if(strcasecmp(tmp1->name,"asReference")!=0 && 725 strcasecmp(tmp1->name,"DataType")!=0 && 726 strncasecmp(tmp1->name,"AllowedValues",13)!=0 && 727 strcasecmp(tmp1->name,"value")!=0 && 728 strcasecmp(tmp1->name,"extension")!=0){ 729 if(datatype==0){ 730 char *tmp2=zCapitalize1(tmp1->name); 731 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 732 free(tmp2); 733 char *orderedFields[5]; 734 orderedFields[0]="mimeType"; 735 orderedFields[1]="encoding"; 736 orderedFields[2]="schema"; 737 orderedFields[3]="dataType"; 738 orderedFields[4]="uom"; 739 int oI=0; 740 for(oI=0;oI<5;oI++) 741 if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){ 742 #ifdef DEBUG 743 printf("DATATYPE DEFAULT ? %s\n",tmp1->name); 744 #endif 745 if(strncasecmp(tmp1->name,"DataType",8)==0){ 746 nc6 = xmlNewNode(ns_ows, BAD_CAST "DataType"); 747 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 748 char tmp[1024]; 749 sprintf(tmp,"http://www.w3.org/TR/xmlschema-2/#%s",tmp1->value); 750 xmlNewNsProp(nc6,ns_ows,BAD_CAST "reference",BAD_CAST tmp); 751 xmlAddChild(nc3,nc6); 752 tmp1=tmp1->next; 753 continue; 754 } 755 if(strcasecmp(tmp1->name,"asReference")!=0 && 756 strcasecmp(tmp1->name,"DataType")!=0 && 757 strncasecmp(tmp1->name,"AllowedValues",13)!=0 && 758 strcasecmp(tmp1->name,"value")!=0 && 759 strcasecmp(tmp1->name,"extension")!=0){ 760 if(datatype==0){ 761 char *tmp2=zCapitalize1(tmp1->name); 762 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 763 free(tmp2); 764 } 765 else{ 766 char *tmp2=zCapitalize(tmp1->name); 767 nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2); 768 free(tmp2); 769 } 770 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 771 xmlAddChild(nc5,nc6); 733 772 } 734 773 else{ 735 char *tmp2=zCapitalize(tmp1->name); 736 nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2); 737 free(tmp2); 738 } 739 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 740 xmlAddChild(nc5,nc6); 741 } 742 else{ 743 if(strcmp(tmp1->name,"value")==0){ 744 nc7 = xmlNewNode(NULL, BAD_CAST "DefaultValue"); 745 xmlAddChild(nc7,xmlNewText(BAD_CAST tmp1->value)); 746 default1=1; 747 } 748 if(strncasecmp(tmp1->name,"AllowedValues",13)==0){ 749 nc6 = xmlNewNode(ns_ows, BAD_CAST "AllowedValues"); 750 char *token,*saveptr1; 751 token=strtok_r(tmp1->value,",",&saveptr1); 752 while(token!=NULL){ 774 if(strcmp(tmp1->name,"value")==0){ 775 nc7 = xmlNewNode(NULL, BAD_CAST "DefaultValue"); 776 xmlAddChild(nc7,xmlNewText(BAD_CAST tmp1->value)); 777 default1=1; 778 } 779 if(strncasecmp(tmp1->name,"AllowedValues",13)==0){ 780 nc6 = xmlNewNode(ns_ows, BAD_CAST "AllowedValues"); 781 char *token,*saveptr1; 782 token=strtok_r(tmp1->value,",",&saveptr1); 783 while(token!=NULL){ 753 784 nc7 = xmlNewNode(ns_ows, BAD_CAST "Value"); 754 785 char *tmps=strdup(token); … … 758 789 xmlAddChild(nc6,nc7); 759 790 token=strtok_r(NULL,",",&saveptr1); 791 } 792 xmlAddChild(nc3,nc6); 793 isAnyValue=-1; 760 794 } 761 xmlAddChild(nc3,nc6);762 isAnyValue=-1;763 795 } 796 tmp1=tmp1->next; 764 797 } 765 tmp1=tmp1->next;766 }767 798 xmlAddChild(nc4,nc5); 768 799 xmlAddChild(nc3,nc4); … … 778 809 779 810 _tmp=e->supported; 811 int hasSupported=-1; 780 812 while(_tmp!=NULL){ 781 if(datatype==0){ 782 nc4 = xmlNewNode(NULL, BAD_CAST "Supported"); 783 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 784 } 785 else{ 786 nc5 = xmlNewNode(NULL, BAD_CAST "Supported"); 787 } 788 tmp1=_tmp->content; 789 while(tmp1!=NULL){ 790 /*if(strcmp(e->format,"LiteralData")==0) 791 xmlAddChild(nc5,nc6);*/ 813 if(hasSupported<0){ 792 814 if(datatype==0){ 793 char *tmp2=zCapitalize1(tmp1->name); 794 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 795 free(tmp2); 815 nc4 = xmlNewNode(NULL, BAD_CAST "Supported"); 816 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 796 817 } 797 818 else{ 798 char *tmp2=zCapitalize(tmp1->name); 799 nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2); 800 free(tmp2); 819 nc5 = xmlNewNode(NULL, BAD_CAST "Supported"); 801 820 } 802 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 803 xmlAddChild(nc5,nc6); 804 tmp1=tmp1->next; 805 } 806 if(datatype==0){ 807 xmlAddChild(nc4,nc5); 808 xmlAddChild(nc3,nc4); 821 hasSupported=0; 809 822 }else{ 810 xmlAddChild(nc4,nc5); 823 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 824 } 825 tmp1=_tmp->content; 826 char *orderedFields[5]; 827 orderedFields[0]="mimeType"; 828 orderedFields[1]="encoding"; 829 orderedFields[2]="schema"; 830 orderedFields[3]="dataType"; 831 orderedFields[4]="uom"; 832 int oI=0; 833 for(oI=0;oI<5;oI++) 834 if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){ 835 if(datatype==0){ 836 char *tmp2=zCapitalize1(tmp1->name); 837 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 838 free(tmp2); 839 } 840 else{ 841 char *tmp2=zCapitalize(tmp1->name); 842 nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2); 843 free(tmp2); 844 } 845 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 846 xmlAddChild(nc5,nc6); 847 tmp1=tmp1->next; 848 } 849 if(hasSupported<=0){ 850 if(datatype==0){ 851 xmlAddChild(nc4,nc5); 852 xmlAddChild(nc3,nc4); 853 }else{ 854 xmlAddChild(nc4,nc5); 855 } 856 hasSupported=1; 857 }else{ 858 xmlAddChild(nc4,nc5); 811 859 } 812 860 _tmp=_tmp->next; … … 896 944 } 897 945 _tmp=e->supported; 946 int hasSupported=-1; 898 947 while(_tmp!=NULL){ 899 if(datatype==0){ 900 nc4 = xmlNewNode(NULL, BAD_CAST "Supported"); 948 if(hasSupported<0){ 949 if(datatype==0){ 950 nc4 = xmlNewNode(NULL, BAD_CAST "Supported"); 951 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 952 } 953 else 954 nc5 = xmlNewNode(NULL, BAD_CAST "Supported"); 955 hasSupported=0; 956 }else 901 957 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 958 tmp1=_tmp->content; 959 char *orderedFields[5]; 960 orderedFields[0]="mimeType"; 961 orderedFields[1]="encoding"; 962 orderedFields[2]="schema"; 963 orderedFields[3]="dataType"; 964 orderedFields[4]="uom"; 965 int oI=0; 966 for(oI=0;oI<5;oI++) 967 if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){ 968 #ifdef DEBUG 969 printf("DATATYPE SUPPORTED ? %s\n",tmp1->name); 970 #endif 971 if(strcmp(tmp1->name,"asReference")!=0 && 972 strcmp(tmp1->name,"DataType")!=0 && 973 strcasecmp(tmp1->name,"extension")!=0){ 974 if(datatype==0){ 975 char *tmp2=zCapitalize1(tmp1->name); 976 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 977 free(tmp2); 978 } 979 else{ 980 char *tmp2=zCapitalize(tmp1->name); 981 nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2); 982 free(tmp2); 983 } 984 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 985 xmlAddChild(nc5,nc6); 986 } 987 tmp1=tmp1->next; 988 } 989 _tmp=_tmp->next; 990 if(hasSupported<=0){ 991 if(datatype==0){ 992 xmlAddChild(nc4,nc5); 993 xmlAddChild(nc3,nc4); 994 }else 995 xmlAddChild(nc4,nc5); 996 hasSupported=1; 902 997 } 903 998 else 904 nc5 = xmlNewNode(NULL, BAD_CAST "Supported"); 905 tmp1=_tmp->content; 906 while(tmp1!=NULL){ 907 #ifdef DEBUG 908 printf("DATATYPE SUPPORTED ? %s\n",tmp1->name); 909 #endif 910 if(strcmp(tmp1->name,"asReference")!=0 && 911 strcmp(tmp1->name,"DataType")!=0 && 912 strcasecmp(tmp1->name,"extension")!=0){ 913 if(datatype==0){ 914 char *tmp2=zCapitalize1(tmp1->name); 915 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 916 free(tmp2); 917 } 918 else{ 919 char *tmp2=zCapitalize(tmp1->name); 920 nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2); 921 free(tmp2); 922 } 923 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 924 xmlAddChild(nc5,nc6); 925 } 926 tmp1=tmp1->next; 927 } 928 _tmp=_tmp->next; 929 if(datatype==0){ 930 xmlAddChild(nc4,nc5); 931 xmlAddChild(nc3,nc4); 932 }else 933 xmlAddChild(nc4,nc5); 999 xmlAddChild(nc4,nc5); 934 1000 } 935 1001 xmlAddChild(nc2,nc3);
Note: See TracChangeset
for help on using the changeset viewer.