| 1 | /* | |
| 2 | * Copyright 1999-2006 University of Chicago | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | ||
| 17 | ||
| 18 | /* | |
| 19 | * This file is automatically generated by the Globus WSDLtoC converter | |
| 20 | */ | |
| 21 | ||
| 22 | #include "xsd_QName.h" | |
| 23 | #include "globus_soap_message.h" | |
| 24 | #include "globus_xsd_type_info.h" | |
| 25 | #include "topics_ConcreteTopicExpressionType.h" | |
| 26 | ||
| 27 | globus_result_t | |
| 28 | topics_ConcreteTopicExpressionType_serialize( | |
| 29 | const xsd_QName * element_qname, | |
| 30 | const topics_ConcreteTopicExpressionType * instance, | |
| 31 | globus_soap_message_handle_t message_handle, | |
| 32 | globus_xsd_element_options_t options) | |
| 33 | 0 | { |
| 34 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 35 | xsd_QName subelement; | |
| 36 | 0 | globus_list_t * any_attr_keys = NULL; |
| 37 | 0 | globus_list_t * any_attr_keys_iterator = NULL; |
| 38 | 0 | xsd_QName * type_attr = NULL; |
| 39 | ||
| 40 | 0 | char * prefix = NULL; |
| 41 | int prefix_created; | |
| 42 | 0 | int define_prefix = 0; |
| 43 | int i; | |
| 44 | 0 | int save_options = options; |
| 45 | ||
| 46 | GlobusFuncName(topics_ConcreteTopicExpressionType_serialize); | |
| 47 | 0 | GlobusSoapMessageDebugEnter(); |
| 48 | ||
| 49 | ||
| 50 | 0 | if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY)) |
| 51 | { | |
| 52 | /* serialize topics_ConcreteTopicExpressionType element */ | |
| 53 | 0 | result = globus_soap_message_element_ns_set( |
| 54 | message_handle, | |
| 55 | element_qname, | |
| 56 | element_qname->Namespace, | |
| 57 | &options); | |
| 58 | 0 | if(result != GLOBUS_SUCCESS) |
| 59 | { | |
| 60 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 61 | result, NULL, element_qname); | |
| 62 | 0 | goto exit; |
| 63 | } | |
| 64 | ||
| 65 | 0 | if(((options & GLOBUS_XSD_ELEMENT_TYPE_ATTR) && |
| 66 | !globus_soap_message_serialize_is_c14n_subset(message_handle))) | |
| 67 | { | |
| 68 | 0 | result = globus_soap_message_attribute_ns_set( |
| 69 | message_handle, | |
| 70 | element_qname, | |
| 71 | "http://www.w3.org/2001/XMLSchema-instance", | |
| 72 | &options); | |
| 73 | 0 | if(result != GLOBUS_SUCCESS) |
| 74 | { | |
| 75 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 76 | result, NULL, element_qname); | |
| 77 | 0 | goto exit; |
| 78 | } | |
| 79 | } | |
| 80 | ||
| 81 | 0 | if((options & GLOBUS_XSD_ELEMENT_TYPE_ATTR) && |
| 82 | !globus_soap_message_serialize_is_c14n_subset(message_handle)) | |
| 83 | { | |
| 84 | ||
| 85 | 0 | result = globus_soap_message_attribute_ns_set( |
| 86 | message_handle, | |
| 87 | element_qname, | |
| 88 | topics_ConcreteTopicExpressionType_qname.Namespace, | |
| 89 | &options); | |
| 90 | 0 | if(result != GLOBUS_SUCCESS) |
| 91 | { | |
| 92 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 93 | result, NULL, element_qname); | |
| 94 | 0 | goto exit; |
| 95 | } | |
| 96 | } | |
| 97 | ||
| 98 | 0 | result = globus_soap_message_serialize_element( |
| 99 | message_handle, | |
| 100 | element_qname, | |
| 101 | options, | |
| 102 | &topics_ConcreteTopicExpressionType_qname); | |
| 103 | 0 | if(result != GLOBUS_SUCCESS) |
| 104 | { | |
| 105 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 106 | result, NULL, element_qname); | |
| 107 | 0 | goto exit; |
| 108 | } | |
| 109 | ||
| 110 | 0 | if((options & GLOBUS_XSD_ELEMENT_TYPE_ATTR) && |
| 111 | !globus_soap_message_serialize_is_c14n_subset(message_handle)) | |
| 112 | { | |
| 113 | 0 | xsd_QName_init(&type_attr); |
| 114 | ||
| 115 | 0 | type_attr->local = globus_libc_strdup("type"); |
| 116 | 0 | type_attr->Namespace = globus_libc_strdup(XSI_NS); |
| 117 | } | |
| 118 | ||
| 119 | ||
| 120 | /* serialize namespaces */ | |
| 121 | 0 | result = globus_soap_message_element_ns_add( |
| 122 | message_handle, | |
| 123 | element_qname, | |
| 124 | element_qname->Namespace, | |
| 125 | &options); | |
| 126 | 0 | if(result != GLOBUS_SUCCESS) |
| 127 | { | |
| 128 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 129 | result, NULL, element_qname); | |
| 130 | 0 | goto exit; |
| 131 | } | |
| 132 | ||
| 133 | 0 | if(((options & GLOBUS_XSD_ELEMENT_TYPE_ATTR) && |
| 134 | !globus_soap_message_serialize_is_c14n_subset(message_handle))) | |
| 135 | { | |
| 136 | 0 | result = globus_soap_message_attribute_ns_add( |
| 137 | message_handle, | |
| 138 | element_qname, | |
| 139 | "http://www.w3.org/2001/XMLSchema-instance", | |
| 140 | &options); | |
| 141 | 0 | if(result != GLOBUS_SUCCESS) |
| 142 | { | |
| 143 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 144 | result, NULL, element_qname); | |
| 145 | 0 | goto exit; |
| 146 | } | |
| 147 | } | |
| 148 | 0 | if ((options & GLOBUS_XSD_ELEMENT_TYPE_ATTR) && |
| 149 | !globus_soap_message_serialize_is_c14n_subset(message_handle)) | |
| 150 | { | |
| 151 | ||
| 152 | 0 | result = globus_soap_message_attribute_ns_add( |
| 153 | message_handle, | |
| 154 | element_qname, | |
| 155 | topics_ConcreteTopicExpressionType_qname.Namespace, | |
| 156 | &options); | |
| 157 | 0 | if(result != GLOBUS_SUCCESS) |
| 158 | { | |
| 159 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 160 | result, NULL, element_qname); | |
| 161 | 0 | goto exit; |
| 162 | } | |
| 163 | } | |
| 164 | ||
| 165 | /* serialize attributes */ | |
| 166 | ||
| 167 | 0 | if((options & GLOBUS_XSD_ELEMENT_TYPE_ATTR) && |
| 168 | !globus_soap_message_serialize_is_c14n_subset(message_handle)) | |
| 169 | { | |
| 170 | 0 | result = globus_soap_message_serialize_QName_attribute( |
| 171 | message_handle, | |
| 172 | type_attr, | |
| 173 | &topics_ConcreteTopicExpressionType_qname); | |
| 174 | 0 | if(result != GLOBUS_SUCCESS) |
| 175 | { | |
| 176 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 177 | result, NULL, element_qname); | |
| 178 | 0 | goto exit; |
| 179 | } | |
| 180 | } | |
| 181 | ||
| 182 | ||
| 183 | } | |
| 184 | ||
| 185 | 0 | if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY)) |
| 186 | { | |
| 187 | 0 | result = globus_soap_message_serialize_element_begin_close( |
| 188 | message_handle, element_qname); | |
| 189 | 0 | if(result != GLOBUS_SUCCESS) |
| 190 | { | |
| 191 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 192 | result, NULL, element_qname); | |
| 193 | 0 | goto exit; |
| 194 | } | |
| 195 | } | |
| 196 | 0 | options &= ~GLOBUS_XSD_ELEMENT_CONTENTS_ONLY; |
| 197 | ||
| 198 | ||
| 199 | /* serialize contents of type */ | |
| 200 | ||
| 201 | 0 | subelement.local = "Root"; |
| 202 | 0 | subelement.Namespace = "http://www.globus.org/2006/05/Notification"; |
| 203 | ||
| 204 | 0 | result = xsd_QName_serialize_contents( |
| 205 | &subelement, | |
| 206 | &instance->Root, | |
| 207 | message_handle, | |
| 208 | options & (~GLOBUS_XSD_ELEMENT_SET_DEFAULT_NS)); | |
| 209 | 0 | if(result != GLOBUS_SUCCESS) |
| 210 | { | |
| 211 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 212 | result, NULL, &xsd_QName_qname); | |
| 213 | 0 | goto exit; |
| 214 | } | |
| 215 | ||
| 216 | 0 | for (i = 0; i < instance->Path.length; i++) |
| 217 | { | |
| 218 | 0 | const xsd_string delim = "/"; |
| 219 | ||
| 220 | 0 | subelement.local = "Path"; |
| 221 | 0 | subelement.Namespace = "http://www.globus.org/2006/05/Notification"; |
| 222 | ||
| 223 | 0 | result = xsd_string_serialize_contents( |
| 224 | &subelement, | |
| 225 | &delim, | |
| 226 | message_handle, | |
| 227 | 0); | |
| 228 | ||
| 229 | 0 | result = xsd_NCName_serialize_contents( |
| 230 | &subelement, | |
| 231 | &instance->Path.elements[i], | |
| 232 | message_handle, | |
| 233 | 0); | |
| 234 | 0 | if(result != GLOBUS_SUCCESS) |
| 235 | { | |
| 236 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 237 | result, NULL, &xsd_NCName_qname); | |
| 238 | 0 | goto exit; |
| 239 | } | |
| 240 | } | |
| 241 | ||
| 242 | 0 | options = save_options; |
| 243 | ||
| 244 | 0 | if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY)) |
| 245 | { | |
| 246 | /* add end element */ | |
| 247 | 0 | result = globus_soap_message_serialize_element_end( |
| 248 | message_handle, | |
| 249 | element_qname, | |
| 250 | options, | |
| 251 | &topics_ConcreteTopicExpressionType_qname); | |
| 252 | 0 | if(result != GLOBUS_SUCCESS) |
| 253 | { | |
| 254 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 255 | result, NULL, element_qname); | |
| 256 | 0 | goto exit; |
| 257 | } | |
| 258 | ||
| 259 | 0 | globus_soap_message_element_ns_remove( |
| 260 | message_handle, | |
| 261 | element_qname->Namespace, | |
| 262 | &options); | |
| 263 | ||
| 264 | /* remove namespace/prefix mappings for these types */ | |
| 265 | ||
| 266 | 0 | if(((options & GLOBUS_XSD_ELEMENT_TYPE_ATTR) && |
| 267 | !globus_soap_message_serialize_is_c14n_subset(message_handle))) | |
| 268 | { | |
| 269 | 0 | globus_soap_message_attribute_ns_remove( |
| 270 | message_handle, | |
| 271 | "http://www.w3.org/2001/XMLSchema-instance", | |
| 272 | &options); | |
| 273 | } | |
| 274 | 0 | if((options & GLOBUS_XSD_ELEMENT_TYPE_ATTR) && |
| 275 | !globus_soap_message_serialize_is_c14n_subset(message_handle)) | |
| 276 | { | |
| 277 | 0 | globus_soap_message_attribute_ns_remove( |
| 278 | message_handle, | |
| 279 | topics_ConcreteTopicExpressionType_qname.Namespace, | |
| 280 | &options); | |
| 281 | } | |
| 282 | ||
| 283 | } | |
| 284 | ||
| 285 | 0 | exit: |
| 286 | 0 | if (type_attr) |
| 287 | { | |
| 288 | 0 | xsd_QName_destroy(type_attr); |
| 289 | } | |
| 290 | ||
| 291 | ||
| 292 | 0 | if(any_attr_keys) |
| 293 | { | |
| 294 | 0 | globus_list_free(any_attr_keys); |
| 295 | } | |
| 296 | ||
| 297 | 0 | GlobusSoapMessageDebugExit(); |
| 298 | 0 | return result; |
| 299 | } | |
| 300 | ||
| 301 | globus_result_t | |
| 302 | topics_ConcreteTopicExpressionType_deserialize( | |
| 303 | const xsd_QName * element_qname, | |
| 304 | topics_ConcreteTopicExpressionType *instance, | |
| 305 | globus_soap_message_handle_t message_handle, | |
| 306 | globus_xsd_element_options_t options) | |
| 307 | 0 | { |
| 308 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 309 | xsd_anyURI namespace; | |
| 310 | xsd_NCName * path; | |
| 311 | char * start; | |
| 312 | ||
| 313 | GlobusFuncName(topics_ConcreteTopicExpressionType_deserialize); | |
| 314 | 0 | GlobusSoapMessageDebugEnter(); |
| 315 | ||
| 316 | 0 | if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY)) |
| 317 | { | |
| 318 | 0 | result = globus_soap_message_deserialize_element( |
| 319 | message_handle, element_qname); | |
| 320 | 0 | if(result != GLOBUS_SUCCESS) |
| 321 | { | |
| 322 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 323 | result, element_qname); | |
| 324 | 0 | goto exit; |
| 325 | } | |
| 326 | ||
| 327 | ||
| 328 | 0 | result = globus_soap_message_deserialize_element_begin_close( |
| 329 | message_handle); | |
| 330 | 0 | if(result != GLOBUS_SUCCESS) |
| 331 | { | |
| 332 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 333 | result, element_qname); | |
| 334 | 0 | goto fail_deserialize; |
| 335 | } | |
| 336 | } | |
| 337 | ||
| 338 | 0 | result = globus_soap_message_deserialize_QName( |
| 339 | message_handle, | |
| 340 | &instance->Root); | |
| 341 | 0 | if(result != GLOBUS_SUCCESS) |
| 342 | { | |
| 343 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 344 | result, | |
| 345 | &topics_ConcreteTopicExpressionType_qname); | |
| 346 | 0 | goto fail_deserialize; |
| 347 | } | |
| 348 | ||
| 349 | /* Split local name of QName into Root and Path components */ | |
| 350 | 0 | start = instance->Root.local; |
| 351 | ||
| 352 | do | |
| 353 | { | |
| 354 | 0 | while (*start && *start != '/') |
| 355 | { | |
| 356 | 0 | start++; |
| 357 | } | |
| 358 | 0 | if (*start == '/') |
| 359 | { | |
| 360 | 0 | *start = 0; |
| 361 | 0 | start++; |
| 362 | ||
| 363 | 0 | path = xsd_NCName_array_push(&instance->Path); |
| 364 | 0 | *path = globus_libc_strdup(start); |
| 365 | ||
| 366 | 0 | start = *path; |
| 367 | } | |
| 368 | } | |
| 369 | 0 | while (*start); |
| 370 | ||
| 371 | 0 | if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY)) |
| 372 | { | |
| 373 | 0 | result = globus_soap_message_deserialize_element_end( |
| 374 | message_handle, | |
| 375 | element_qname); | |
| 376 | 0 | if(result != GLOBUS_SUCCESS) |
| 377 | { | |
| 378 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 379 | result, element_qname); | |
| 380 | 0 | goto fail_deserialize; |
| 381 | } | |
| 382 | } | |
| 383 | ||
| 384 | 0 | goto exit; |
| 385 | ||
| 386 | 0 | fail_deserialize: |
| 387 | 0 | xsd_NCName_array_destroy_contents( |
| 388 | &instance->Path); | |
| 389 | ||
| 390 | 0 | Path_destroy_array: |
| 391 | 0 | xsd_QName_destroy_contents( |
| 392 | &instance->Root); | |
| 393 | ||
| 394 | 0 | Root_destroy: |
| 395 | ||
| 396 | ||
| 397 | 0 | exit: |
| 398 | ||
| 399 | 0 | GlobusSoapMessageDebugExit(); |
| 400 | 0 | return result; |