OLD | NEW |
1 /* | 1 /* |
2 * schemastypes.c : implementation of the XML Schema Datatypes | 2 * schemastypes.c : implementation of the XML Schema Datatypes |
3 * definition and validity checking | 3 * definition and validity checking |
4 * | 4 * |
5 * See Copyright for the status of this software. | 5 * See Copyright for the status of this software. |
6 * | 6 * |
7 * Daniel Veillard <veillard@redhat.com> | 7 * Daniel Veillard <veillard@redhat.com> |
8 */ | 8 */ |
9 | 9 |
10 #define IN_LIBXML | 10 #define IN_LIBXML |
(...skipping 22 matching lines...) Expand all Loading... |
33 #endif | 33 #endif |
34 | 34 |
35 #define DEBUG | 35 #define DEBUG |
36 | 36 |
37 #ifndef LIBXML_XPATH_ENABLED | 37 #ifndef LIBXML_XPATH_ENABLED |
38 extern double xmlXPathNAN; | 38 extern double xmlXPathNAN; |
39 extern double xmlXPathPINF; | 39 extern double xmlXPathPINF; |
40 extern double xmlXPathNINF; | 40 extern double xmlXPathNINF; |
41 #endif | 41 #endif |
42 | 42 |
43 #define TODO » » » » » » » » \ | 43 #define TODO» » » » » » » » \ |
44 xmlGenericError(xmlGenericErrorContext, \ | 44 xmlGenericError(xmlGenericErrorContext, \ |
45 "Unimplemented block at %s:%d\n", \ | 45 "Unimplemented block at %s:%d\n", \ |
46 __FILE__, __LINE__); | 46 __FILE__, __LINE__); |
47 | 47 |
48 #define XML_SCHEMAS_NAMESPACE_NAME \ | 48 #define XML_SCHEMAS_NAMESPACE_NAME \ |
49 (const xmlChar *)"http://www.w3.org/2001/XMLSchema" | 49 (const xmlChar *)"http://www.w3.org/2001/XMLSchema" |
50 | 50 |
51 #define IS_WSP_REPLACE_CH(c) ((((c) == 0x9) || ((c) == 0xa)) || \ | 51 #define IS_WSP_REPLACE_CH(c) ((((c) == 0x9) || ((c) == 0xa)) || \ |
52 ((c) == 0xd)) | 52 ((c) == 0xd)) |
53 | 53 |
(...skipping 14 matching lines...) Expand all Loading... |
68 unsigned int tz_flag :1; /* is tzo explicitely set? */ | 68 unsigned int tz_flag :1; /* is tzo explicitely set? */ |
69 signed int tzo :12; /* -1440 <= tzo <= 1440; | 69 signed int tzo :12; /* -1440 <= tzo <= 1440; |
70 currently only -840 to +840 are neede
d */ | 70 currently only -840 to +840 are neede
d */ |
71 }; | 71 }; |
72 | 72 |
73 /* Duration value */ | 73 /* Duration value */ |
74 typedef struct _xmlSchemaValDuration xmlSchemaValDuration; | 74 typedef struct _xmlSchemaValDuration xmlSchemaValDuration; |
75 typedef xmlSchemaValDuration *xmlSchemaValDurationPtr; | 75 typedef xmlSchemaValDuration *xmlSchemaValDurationPtr; |
76 struct _xmlSchemaValDuration { | 76 struct _xmlSchemaValDuration { |
77 long mon; /* mon stores years also */ | 77 long mon; /* mon stores years also */ |
78 long » day; | 78 long» day; |
79 double sec; /* sec stores min and hour also */ | 79 double sec; /* sec stores min and hour also */ |
80 }; | 80 }; |
81 | 81 |
82 typedef struct _xmlSchemaValDecimal xmlSchemaValDecimal; | 82 typedef struct _xmlSchemaValDecimal xmlSchemaValDecimal; |
83 typedef xmlSchemaValDecimal *xmlSchemaValDecimalPtr; | 83 typedef xmlSchemaValDecimal *xmlSchemaValDecimalPtr; |
84 struct _xmlSchemaValDecimal { | 84 struct _xmlSchemaValDecimal { |
85 /* would use long long but not portable */ | 85 /* would use long long but not portable */ |
86 unsigned long lo; | 86 unsigned long lo; |
87 unsigned long mi; | 87 unsigned long mi; |
88 unsigned long hi; | 88 unsigned long hi; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 static xmlSchemaTypePtr xmlSchemaTypeIdrefDef = NULL; | 182 static xmlSchemaTypePtr xmlSchemaTypeIdrefDef = NULL; |
183 static xmlSchemaTypePtr xmlSchemaTypeIdrefsDef = NULL; | 183 static xmlSchemaTypePtr xmlSchemaTypeIdrefsDef = NULL; |
184 static xmlSchemaTypePtr xmlSchemaTypeEntityDef = NULL; | 184 static xmlSchemaTypePtr xmlSchemaTypeEntityDef = NULL; |
185 static xmlSchemaTypePtr xmlSchemaTypeEntitiesDef = NULL; | 185 static xmlSchemaTypePtr xmlSchemaTypeEntitiesDef = NULL; |
186 static xmlSchemaTypePtr xmlSchemaTypeNotationDef = NULL; | 186 static xmlSchemaTypePtr xmlSchemaTypeNotationDef = NULL; |
187 static xmlSchemaTypePtr xmlSchemaTypeNmtokenDef = NULL; | 187 static xmlSchemaTypePtr xmlSchemaTypeNmtokenDef = NULL; |
188 static xmlSchemaTypePtr xmlSchemaTypeNmtokensDef = NULL; | 188 static xmlSchemaTypePtr xmlSchemaTypeNmtokensDef = NULL; |
189 | 189 |
190 /************************************************************************ | 190 /************************************************************************ |
191 * * | 191 * * |
192 * » » » Datatype error handlers»» » » * | 192 *» » » Datatype error handlers»» » » * |
193 * * | 193 * * |
194 ************************************************************************/ | 194 ************************************************************************/ |
195 /** | 195 /** |
196 * xmlSchemaTypeErrMemory: | 196 * xmlSchemaTypeErrMemory: |
197 * @extra: extra informations | 197 * @extra: extra informations |
198 * | 198 * |
199 * Handle an out of memory condition | 199 * Handle an out of memory condition |
200 */ | 200 */ |
201 static void | 201 static void |
202 xmlSchemaTypeErrMemory(xmlNodePtr node, const char *extra) | 202 xmlSchemaTypeErrMemory(xmlNodePtr node, const char *extra) |
203 { | 203 { |
204 __xmlSimpleError(XML_FROM_DATATYPE, XML_ERR_NO_MEMORY, node, NULL, extra); | 204 __xmlSimpleError(XML_FROM_DATATYPE, XML_ERR_NO_MEMORY, node, NULL, extra); |
205 } | 205 } |
206 | 206 |
207 /************************************************************************ | 207 /************************************************************************ |
208 * * | 208 * * |
209 * » » » Base types support» » » » * | 209 *» » » Base types support» » » » * |
210 * * | 210 * * |
211 ************************************************************************/ | 211 ************************************************************************/ |
212 | 212 |
213 /** | 213 /** |
214 * xmlSchemaNewValue: | 214 * xmlSchemaNewValue: |
215 * @type: the value type | 215 * @type: the value type |
216 * | 216 * |
217 * Allocate a new simple type value | 217 * Allocate a new simple type value |
218 * | 218 * |
219 * Returns a pointer to the new value or NULL in case of error | 219 * Returns a pointer to the new value or NULL in case of error |
(...skipping 15 matching lines...) Expand all Loading... |
235 xmlSchemaNewMinLengthFacet(int value) | 235 xmlSchemaNewMinLengthFacet(int value) |
236 { | 236 { |
237 xmlSchemaFacetPtr ret; | 237 xmlSchemaFacetPtr ret; |
238 | 238 |
239 ret = xmlSchemaNewFacet(); | 239 ret = xmlSchemaNewFacet(); |
240 if (ret == NULL) { | 240 if (ret == NULL) { |
241 return(NULL); | 241 return(NULL); |
242 } | 242 } |
243 ret->type = XML_SCHEMA_FACET_MINLENGTH; | 243 ret->type = XML_SCHEMA_FACET_MINLENGTH; |
244 ret->val = xmlSchemaNewValue(XML_SCHEMAS_NNINTEGER); | 244 ret->val = xmlSchemaNewValue(XML_SCHEMAS_NNINTEGER); |
| 245 if (ret->val == NULL) { |
| 246 xmlFree(ret); |
| 247 return(NULL); |
| 248 } |
245 ret->val->value.decimal.lo = value; | 249 ret->val->value.decimal.lo = value; |
246 return (ret); | 250 return (ret); |
247 } | 251 } |
248 | 252 |
249 /* | 253 /* |
250 * xmlSchemaInitBasicType: | 254 * xmlSchemaInitBasicType: |
251 * @name: the type name | 255 * @name: the type name |
252 * @type: the value type associated | 256 * @type: the value type associated |
253 * | 257 * |
254 * Initialize one primitive built-in type | 258 * Initialize one primitive built-in type |
255 */ | 259 */ |
256 static xmlSchemaTypePtr | 260 static xmlSchemaTypePtr |
257 xmlSchemaInitBasicType(const char *name, xmlSchemaValType type, | 261 xmlSchemaInitBasicType(const char *name, xmlSchemaValType type, |
258 xmlSchemaTypePtr baseType) { | 262 xmlSchemaTypePtr baseType) { |
259 xmlSchemaTypePtr ret; | 263 xmlSchemaTypePtr ret; |
260 | 264 |
261 ret = (xmlSchemaTypePtr) xmlMalloc(sizeof(xmlSchemaType)); | 265 ret = (xmlSchemaTypePtr) xmlMalloc(sizeof(xmlSchemaType)); |
262 if (ret == NULL) { | 266 if (ret == NULL) { |
263 xmlSchemaTypeErrMemory(NULL, "could not initialize basic types"); | 267 xmlSchemaTypeErrMemory(NULL, "could not initialize basic types"); |
264 return(NULL); | 268 return(NULL); |
265 } | 269 } |
266 memset(ret, 0, sizeof(xmlSchemaType)); | 270 memset(ret, 0, sizeof(xmlSchemaType)); |
267 ret->name = (const xmlChar *)name; | 271 ret->name = (const xmlChar *)name; |
268 ret->targetNamespace = XML_SCHEMAS_NAMESPACE_NAME; | 272 ret->targetNamespace = XML_SCHEMAS_NAMESPACE_NAME; |
269 ret->type = XML_SCHEMA_TYPE_BASIC; | 273 ret->type = XML_SCHEMA_TYPE_BASIC; |
270 ret->baseType = baseType;» | 274 ret->baseType = baseType; |
271 ret->contentType = XML_SCHEMA_CONTENT_BASIC; | 275 ret->contentType = XML_SCHEMA_CONTENT_BASIC; |
272 /* | 276 /* |
273 * Primitive types. | 277 * Primitive types. |
274 */ | 278 */ |
275 switch (type) {» » | 279 switch (type) { |
276 » case XML_SCHEMAS_STRING: | 280 » case XML_SCHEMAS_STRING: |
277 » case XML_SCHEMAS_DECIMAL: | 281 » case XML_SCHEMAS_DECIMAL: |
278 » case XML_SCHEMAS_DATE: | 282 » case XML_SCHEMAS_DATE: |
279 » case XML_SCHEMAS_DATETIME: | 283 » case XML_SCHEMAS_DATETIME: |
280 » case XML_SCHEMAS_TIME: | 284 » case XML_SCHEMAS_TIME: |
281 » case XML_SCHEMAS_GYEAR: | 285 » case XML_SCHEMAS_GYEAR: |
282 » case XML_SCHEMAS_GYEARMONTH: | 286 » case XML_SCHEMAS_GYEARMONTH: |
283 » case XML_SCHEMAS_GMONTH: | 287 » case XML_SCHEMAS_GMONTH: |
284 » case XML_SCHEMAS_GMONTHDAY: | 288 » case XML_SCHEMAS_GMONTHDAY: |
285 » case XML_SCHEMAS_GDAY: | 289 » case XML_SCHEMAS_GDAY: |
286 » case XML_SCHEMAS_DURATION: | 290 » case XML_SCHEMAS_DURATION: |
287 » case XML_SCHEMAS_FLOAT: | 291 » case XML_SCHEMAS_FLOAT: |
288 » case XML_SCHEMAS_DOUBLE: | 292 » case XML_SCHEMAS_DOUBLE: |
289 » case XML_SCHEMAS_BOOLEAN: | 293 » case XML_SCHEMAS_BOOLEAN: |
290 » case XML_SCHEMAS_ANYURI: | 294 » case XML_SCHEMAS_ANYURI: |
291 » case XML_SCHEMAS_HEXBINARY: | 295 » case XML_SCHEMAS_HEXBINARY: |
292 » case XML_SCHEMAS_BASE64BINARY:» | 296 » case XML_SCHEMAS_BASE64BINARY: |
293 » case XML_SCHEMAS_QNAME:» | 297 » case XML_SCHEMAS_QNAME: |
294 » case XML_SCHEMAS_NOTATION:» | 298 » case XML_SCHEMAS_NOTATION: |
295 ret->flags |= XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE; | 299 ret->flags |= XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE; |
296 break; | 300 break; |
297 default: | 301 default: |
298 break; | 302 break; |
299 } | 303 } |
300 /* | 304 /* |
301 * Set variety. | 305 * Set variety. |
302 */ | 306 */ |
303 switch (type) { | 307 switch (type) { |
304 case XML_SCHEMAS_ANYTYPE: | 308 case XML_SCHEMAS_ANYTYPE: |
305 case XML_SCHEMAS_ANYSIMPLETYPE: | 309 case XML_SCHEMAS_ANYSIMPLETYPE: |
306 break; | 310 break; |
307 case XML_SCHEMAS_IDREFS: | 311 case XML_SCHEMAS_IDREFS: |
308 case XML_SCHEMAS_NMTOKENS: | 312 case XML_SCHEMAS_NMTOKENS: |
309 case XML_SCHEMAS_ENTITIES: | 313 case XML_SCHEMAS_ENTITIES: |
310 ret->flags |= XML_SCHEMAS_TYPE_VARIETY_LIST; | 314 ret->flags |= XML_SCHEMAS_TYPE_VARIETY_LIST; |
311 ret->facets = xmlSchemaNewMinLengthFacet(1); | 315 ret->facets = xmlSchemaNewMinLengthFacet(1); |
312 » ret->flags |= XML_SCHEMAS_TYPE_HAS_FACETS;» | 316 » ret->flags |= XML_SCHEMAS_TYPE_HAS_FACETS; |
313 break; | 317 break; |
314 default: | 318 default: |
315 ret->flags |= XML_SCHEMAS_TYPE_VARIETY_ATOMIC; | 319 ret->flags |= XML_SCHEMAS_TYPE_VARIETY_ATOMIC; |
316 break; | 320 break; |
317 } | 321 } |
318 xmlHashAddEntry2(xmlSchemaTypesBank, ret->name, | 322 xmlHashAddEntry2(xmlSchemaTypesBank, ret->name, |
319 XML_SCHEMAS_NAMESPACE_NAME, ret); | 323 XML_SCHEMAS_NAMESPACE_NAME, ret); |
320 ret->builtInType = type; | 324 ret->builtInType = type; |
321 return(ret); | 325 return(ret); |
322 } | 326 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 * | 387 * |
384 * Initialize the default XML Schemas type library | 388 * Initialize the default XML Schemas type library |
385 */ | 389 */ |
386 void | 390 void |
387 xmlSchemaInitTypes(void) | 391 xmlSchemaInitTypes(void) |
388 { | 392 { |
389 if (xmlSchemaTypesInitialized != 0) | 393 if (xmlSchemaTypesInitialized != 0) |
390 return; | 394 return; |
391 xmlSchemaTypesBank = xmlHashCreate(40); | 395 xmlSchemaTypesBank = xmlHashCreate(40); |
392 | 396 |
393 | 397 |
394 /* | 398 /* |
395 * 3.4.7 Built-in Complex Type Definition | 399 * 3.4.7 Built-in Complex Type Definition |
396 */ | 400 */ |
397 xmlSchemaTypeAnyTypeDef = xmlSchemaInitBasicType("anyType", | 401 xmlSchemaTypeAnyTypeDef = xmlSchemaInitBasicType("anyType", |
398 XML_SCHEMAS_ANYTYPE, | 402 XML_SCHEMAS_ANYTYPE, |
399 NULL); | 403 NULL); |
400 xmlSchemaTypeAnyTypeDef->baseType = xmlSchemaTypeAnyTypeDef; | 404 xmlSchemaTypeAnyTypeDef->baseType = xmlSchemaTypeAnyTypeDef; |
401 xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED; | 405 xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED; |
402 /* | 406 /* |
403 * Init the content type. | 407 * Init the content type. |
404 */ | 408 */ |
405 xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED; | 409 xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED; |
406 { | 410 { |
407 xmlSchemaParticlePtr particle; | 411 xmlSchemaParticlePtr particle; |
408 xmlSchemaModelGroupPtr sequence; | 412 xmlSchemaModelGroupPtr sequence; |
409 xmlSchemaWildcardPtr wild; | 413 xmlSchemaWildcardPtr wild; |
410 /* First particle. */ | 414 /* First particle. */ |
411 particle = xmlSchemaAddParticle(); | 415 particle = xmlSchemaAddParticle(); |
412 if (particle == NULL) | 416 if (particle == NULL) |
413 return; | 417 return; |
414 xmlSchemaTypeAnyTypeDef->subtypes = (xmlSchemaTypePtr) particle; | 418 xmlSchemaTypeAnyTypeDef->subtypes = (xmlSchemaTypePtr) particle; |
415 /* Sequence model group. */ | 419 /* Sequence model group. */ |
416 sequence = (xmlSchemaModelGroupPtr) | 420 sequence = (xmlSchemaModelGroupPtr) |
417 xmlMalloc(sizeof(xmlSchemaModelGroup)); | 421 xmlMalloc(sizeof(xmlSchemaModelGroup)); |
418 if (sequence == NULL) { | 422 if (sequence == NULL) { |
419 xmlSchemaTypeErrMemory(NULL, "allocating model group component"); | 423 xmlSchemaTypeErrMemory(NULL, "allocating model group component"); |
420 return; | 424 return; |
421 } | 425 } |
422 memset(sequence, 0, sizeof(xmlSchemaModelGroup)); | 426 memset(sequence, 0, sizeof(xmlSchemaModelGroup)); |
423 » sequence->type = XML_SCHEMA_TYPE_SEQUENCE;» | 427 » sequence->type = XML_SCHEMA_TYPE_SEQUENCE; |
424 particle->children = (xmlSchemaTreeItemPtr) sequence; | 428 particle->children = (xmlSchemaTreeItemPtr) sequence; |
425 /* Second particle. */ | 429 /* Second particle. */ |
426 particle = xmlSchemaAddParticle(); | 430 particle = xmlSchemaAddParticle(); |
427 if (particle == NULL) | 431 if (particle == NULL) |
428 return; | 432 return; |
429 particle->minOccurs = 0; | 433 particle->minOccurs = 0; |
430 particle->maxOccurs = UNBOUNDED; | 434 particle->maxOccurs = UNBOUNDED; |
431 sequence->children = (xmlSchemaTreeItemPtr) particle; | 435 sequence->children = (xmlSchemaTreeItemPtr) particle; |
432 /* The wildcard */ | 436 /* The wildcard */ |
433 wild = (xmlSchemaWildcardPtr) xmlMalloc(sizeof(xmlSchemaWildcard)); | 437 wild = (xmlSchemaWildcardPtr) xmlMalloc(sizeof(xmlSchemaWildcard)); |
434 if (wild == NULL) { | 438 if (wild == NULL) { |
435 xmlSchemaTypeErrMemory(NULL, "allocating wildcard component"); | 439 xmlSchemaTypeErrMemory(NULL, "allocating wildcard component"); |
436 return; | 440 return; |
437 } | 441 } |
438 memset(wild, 0, sizeof(xmlSchemaWildcard)); | 442 memset(wild, 0, sizeof(xmlSchemaWildcard)); |
439 wild->type = XML_SCHEMA_TYPE_ANY; | 443 wild->type = XML_SCHEMA_TYPE_ANY; |
440 » wild->any = 1;» | 444 » wild->any = 1; |
441 » wild->processContents = XML_SCHEMAS_ANY_LAX;» | 445 » wild->processContents = XML_SCHEMAS_ANY_LAX; |
442 » particle->children = (xmlSchemaTreeItemPtr) wild; | 446 » particle->children = (xmlSchemaTreeItemPtr) wild; |
443 /* | 447 /* |
444 * Create the attribute wildcard. | 448 * Create the attribute wildcard. |
445 */ | 449 */ |
446 wild = (xmlSchemaWildcardPtr) xmlMalloc(sizeof(xmlSchemaWildcard)); | 450 wild = (xmlSchemaWildcardPtr) xmlMalloc(sizeof(xmlSchemaWildcard)); |
447 if (wild == NULL) { | 451 if (wild == NULL) { |
448 xmlSchemaTypeErrMemory(NULL, "could not create an attribute " | 452 xmlSchemaTypeErrMemory(NULL, "could not create an attribute " |
449 "wildcard on anyType"); | 453 "wildcard on anyType"); |
450 return; | 454 return; |
451 } | 455 } |
452 memset(wild, 0, sizeof(xmlSchemaWildcard)); | 456 memset(wild, 0, sizeof(xmlSchemaWildcard)); |
453 wild->any = 1; | 457 wild->any = 1; |
454 » wild->processContents = XML_SCHEMAS_ANY_LAX;» | 458 » wild->processContents = XML_SCHEMAS_ANY_LAX; |
455 xmlSchemaTypeAnyTypeDef->attributeWildcard = wild; | 459 xmlSchemaTypeAnyTypeDef->attributeWildcard = wild; |
456 } | 460 } |
457 xmlSchemaTypeAnySimpleTypeDef = xmlSchemaInitBasicType("anySimpleType", | 461 xmlSchemaTypeAnySimpleTypeDef = xmlSchemaInitBasicType("anySimpleType", |
458 XML_SCHEMAS_ANYSIMPLE
TYPE, | 462 XML_SCHEMAS_ANYSIMPLE
TYPE, |
459 xmlSchemaTypeAnyTypeD
ef); | 463 xmlSchemaTypeAnyTypeD
ef); |
460 /* | 464 /* |
461 * primitive datatypes | 465 * primitive datatypes |
462 */ | 466 */ |
463 xmlSchemaTypeStringDef = xmlSchemaInitBasicType("string", | 467 xmlSchemaTypeStringDef = xmlSchemaInitBasicType("string", |
464 XML_SCHEMAS_STRING, | 468 XML_SCHEMAS_STRING, |
465 xmlSchemaTypeAnySimpleTypeDe
f); | 469 xmlSchemaTypeAnySimpleTypeDe
f); |
466 xmlSchemaTypeDecimalDef = xmlSchemaInitBasicType("decimal", | 470 xmlSchemaTypeDecimalDef = xmlSchemaInitBasicType("decimal", |
467 XML_SCHEMAS_DECIMAL, | 471 XML_SCHEMAS_DECIMAL, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 XML_SCHEMAS_ANYURI, | 510 XML_SCHEMAS_ANYURI, |
507 xmlSchemaTypeAnySimpleTypeDe
f); | 511 xmlSchemaTypeAnySimpleTypeDe
f); |
508 xmlSchemaTypeHexBinaryDef = xmlSchemaInitBasicType("hexBinary", | 512 xmlSchemaTypeHexBinaryDef = xmlSchemaInitBasicType("hexBinary", |
509 XML_SCHEMAS_HEXBINARY, | 513 XML_SCHEMAS_HEXBINARY, |
510 xmlSchemaTypeAnySimpleTypeD
ef); | 514 xmlSchemaTypeAnySimpleTypeD
ef); |
511 xmlSchemaTypeBase64BinaryDef | 515 xmlSchemaTypeBase64BinaryDef |
512 = xmlSchemaInitBasicType("base64Binary", XML_SCHEMAS_BASE64BINARY, | 516 = xmlSchemaInitBasicType("base64Binary", XML_SCHEMAS_BASE64BINARY, |
513 xmlSchemaTypeAnySimpleTypeDef); | 517 xmlSchemaTypeAnySimpleTypeDef); |
514 xmlSchemaTypeNotationDef = xmlSchemaInitBasicType("NOTATION", | 518 xmlSchemaTypeNotationDef = xmlSchemaInitBasicType("NOTATION", |
515 XML_SCHEMAS_NOTATION, | 519 XML_SCHEMAS_NOTATION, |
516 » » » » » » xmlSchemaTypeAnySimpleTypeDe
f); | 520 » » » » » » xmlSchemaTypeAnySimpleTypeDe
f); |
517 xmlSchemaTypeQNameDef = xmlSchemaInitBasicType("QName", | 521 xmlSchemaTypeQNameDef = xmlSchemaInitBasicType("QName", |
518 XML_SCHEMAS_QNAME, | 522 XML_SCHEMAS_QNAME, |
519 xmlSchemaTypeAnySimpleTypeDef
); | 523 xmlSchemaTypeAnySimpleTypeDef
); |
520 | 524 |
521 /* | 525 /* |
522 * derived datatypes | 526 * derived datatypes |
523 */ | 527 */ |
524 xmlSchemaTypeIntegerDef = xmlSchemaInitBasicType("integer", | 528 xmlSchemaTypeIntegerDef = xmlSchemaInitBasicType("integer", |
525 XML_SCHEMAS_INTEGER, | 529 XML_SCHEMAS_INTEGER, |
526 xmlSchemaTypeDecimalDef); | 530 xmlSchemaTypeDecimalDef); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 xmlSchemaTypeNmtokenDef = xmlSchemaInitBasicType("NMTOKEN", | 580 xmlSchemaTypeNmtokenDef = xmlSchemaInitBasicType("NMTOKEN", |
577 XML_SCHEMAS_NMTOKEN, | 581 XML_SCHEMAS_NMTOKEN, |
578 xmlSchemaTypeTokenDef); | 582 xmlSchemaTypeTokenDef); |
579 xmlSchemaTypeNCNameDef = xmlSchemaInitBasicType("NCName", | 583 xmlSchemaTypeNCNameDef = xmlSchemaInitBasicType("NCName", |
580 XML_SCHEMAS_NCNAME, | 584 XML_SCHEMAS_NCNAME, |
581 xmlSchemaTypeNameDef); | 585 xmlSchemaTypeNameDef); |
582 xmlSchemaTypeIdDef = xmlSchemaInitBasicType("ID", XML_SCHEMAS_ID, | 586 xmlSchemaTypeIdDef = xmlSchemaInitBasicType("ID", XML_SCHEMAS_ID, |
583 xmlSchemaTypeNCNameDef); | 587 xmlSchemaTypeNCNameDef); |
584 xmlSchemaTypeIdrefDef = xmlSchemaInitBasicType("IDREF", | 588 xmlSchemaTypeIdrefDef = xmlSchemaInitBasicType("IDREF", |
585 XML_SCHEMAS_IDREF, | 589 XML_SCHEMAS_IDREF, |
586 » » » » » » xmlSchemaTypeNCNameDef);
| 590 » » » » » » xmlSchemaTypeNCNameDef); |
587 xmlSchemaTypeEntityDef = xmlSchemaInitBasicType("ENTITY", | 591 xmlSchemaTypeEntityDef = xmlSchemaInitBasicType("ENTITY", |
588 XML_SCHEMAS_ENTITY, | 592 XML_SCHEMAS_ENTITY, |
589 xmlSchemaTypeNCNameDef); | 593 xmlSchemaTypeNCNameDef); |
590 /* | 594 /* |
591 * Derived list types. | 595 * Derived list types. |
592 */ | 596 */ |
593 /* ENTITIES */ | 597 /* ENTITIES */ |
594 xmlSchemaTypeEntitiesDef = xmlSchemaInitBasicType("ENTITIES", | 598 xmlSchemaTypeEntitiesDef = xmlSchemaInitBasicType("ENTITIES", |
595 XML_SCHEMAS_ENTITIES, | 599 XML_SCHEMAS_ENTITIES, |
596 xmlSchemaTypeAnySimpleType
Def); | 600 xmlSchemaTypeAnySimpleType
Def); |
(...skipping 11 matching lines...) Expand all Loading... |
608 xmlSchemaTypeNmtokensDef->subtypes = xmlSchemaTypeNmtokenDef; | 612 xmlSchemaTypeNmtokensDef->subtypes = xmlSchemaTypeNmtokenDef; |
609 | 613 |
610 xmlSchemaTypesInitialized = 1; | 614 xmlSchemaTypesInitialized = 1; |
611 } | 615 } |
612 | 616 |
613 /** | 617 /** |
614 * xmlSchemaCleanupTypes: | 618 * xmlSchemaCleanupTypes: |
615 * | 619 * |
616 * Cleanup the default XML Schemas type library | 620 * Cleanup the default XML Schemas type library |
617 */ | 621 */ |
618 void» | 622 void |
619 xmlSchemaCleanupTypes(void) { | 623 xmlSchemaCleanupTypes(void) { |
620 if (xmlSchemaTypesInitialized == 0) | 624 if (xmlSchemaTypesInitialized == 0) |
621 return; | 625 return; |
622 /* | 626 /* |
623 * Free xs:anyType. | 627 * Free xs:anyType. |
624 */ | 628 */ |
625 { | 629 { |
626 xmlSchemaParticlePtr particle; | 630 xmlSchemaParticlePtr particle; |
627 /* Attribute wildcard. */ | 631 /* Attribute wildcard. */ |
628 xmlSchemaFreeWildcard(xmlSchemaTypeAnyTypeDef->attributeWildcard); | 632 xmlSchemaFreeWildcard(xmlSchemaTypeAnyTypeDef->attributeWildcard); |
629 /* Content type. */ | 633 /* Content type. */ |
630 particle = (xmlSchemaParticlePtr) xmlSchemaTypeAnyTypeDef->subtypes; | 634 particle = (xmlSchemaParticlePtr) xmlSchemaTypeAnyTypeDef->subtypes; |
631 /* Wildcard. */ | 635 /* Wildcard. */ |
632 » xmlSchemaFreeWildcard((xmlSchemaWildcardPtr) | 636 » xmlSchemaFreeWildcard((xmlSchemaWildcardPtr) |
633 particle->children->children->children); | 637 particle->children->children->children); |
634 xmlFree((xmlSchemaParticlePtr) particle->children->children); | 638 xmlFree((xmlSchemaParticlePtr) particle->children->children); |
635 /* Sequence model group. */ | 639 /* Sequence model group. */ |
636 xmlFree((xmlSchemaModelGroupPtr) particle->children); | 640 xmlFree((xmlSchemaModelGroupPtr) particle->children); |
637 xmlFree((xmlSchemaParticlePtr) particle); | 641 xmlFree((xmlSchemaParticlePtr) particle); |
638 » xmlSchemaTypeAnyTypeDef->subtypes = NULL;» | 642 » xmlSchemaTypeAnyTypeDef->subtypes = NULL; |
639 } | 643 } |
640 xmlHashFree(xmlSchemaTypesBank, (xmlHashDeallocator) xmlSchemaFreeType); | 644 xmlHashFree(xmlSchemaTypesBank, (xmlHashDeallocator) xmlSchemaFreeType); |
641 xmlSchemaTypesInitialized = 0; | 645 xmlSchemaTypesInitialized = 0; |
642 } | 646 } |
643 | 647 |
644 /** | 648 /** |
645 * xmlSchemaIsBuiltInTypeFacet: | 649 * xmlSchemaIsBuiltInTypeFacet: |
646 * @type: the built-in type | 650 * @type: the built-in type |
647 * @facetType: the facet type | 651 * @facetType: the facet type |
648 * | 652 * |
649 * Evaluates if a specific facet can be | 653 * Evaluates if a specific facet can be |
650 * used in conjunction with a type. | 654 * used in conjunction with a type. |
651 * | 655 * |
652 * Returns 1 if the facet can be used with the given built-in type, | 656 * Returns 1 if the facet can be used with the given built-in type, |
653 * 0 otherwise and -1 in case the type is not a built-in type. | 657 * 0 otherwise and -1 in case the type is not a built-in type. |
654 */ | 658 */ |
655 int | 659 int |
656 xmlSchemaIsBuiltInTypeFacet(xmlSchemaTypePtr type, int facetType) | 660 xmlSchemaIsBuiltInTypeFacet(xmlSchemaTypePtr type, int facetType) |
657 { | 661 { |
658 if (type == NULL) | 662 if (type == NULL) |
659 return (-1); | 663 return (-1); |
660 if (type->type != XML_SCHEMA_TYPE_BASIC) | 664 if (type->type != XML_SCHEMA_TYPE_BASIC) |
661 return (-1); | 665 return (-1); |
662 switch (type->builtInType) { | 666 switch (type->builtInType) { |
663 case XML_SCHEMAS_BOOLEAN: | 667 case XML_SCHEMAS_BOOLEAN: |
664 if ((facetType == XML_SCHEMA_FACET_PATTERN) || | 668 if ((facetType == XML_SCHEMA_FACET_PATTERN) || |
665 (facetType == XML_SCHEMA_FACET_WHITESPACE)) | 669 (facetType == XML_SCHEMA_FACET_WHITESPACE)) |
666 return (1); | 670 return (1); |
667 else | 671 else |
668 » » return (0);» | 672 » » return (0); |
669 case XML_SCHEMAS_STRING: | 673 case XML_SCHEMAS_STRING: |
670 case XML_SCHEMAS_NOTATION: | 674 case XML_SCHEMAS_NOTATION: |
671 case XML_SCHEMAS_QNAME: | 675 case XML_SCHEMAS_QNAME: |
672 » case XML_SCHEMAS_ANYURI:» | 676 » case XML_SCHEMAS_ANYURI: |
673 » case XML_SCHEMAS_BASE64BINARY: | 677 » case XML_SCHEMAS_BASE64BINARY: |
674 case XML_SCHEMAS_HEXBINARY: | 678 case XML_SCHEMAS_HEXBINARY: |
675 if ((facetType == XML_SCHEMA_FACET_LENGTH) || | 679 if ((facetType == XML_SCHEMA_FACET_LENGTH) || |
676 (facetType == XML_SCHEMA_FACET_MINLENGTH) || | 680 (facetType == XML_SCHEMA_FACET_MINLENGTH) || |
677 (facetType == XML_SCHEMA_FACET_MAXLENGTH) || | 681 (facetType == XML_SCHEMA_FACET_MAXLENGTH) || |
678 (facetType == XML_SCHEMA_FACET_PATTERN) || | 682 (facetType == XML_SCHEMA_FACET_PATTERN) || |
679 (facetType == XML_SCHEMA_FACET_ENUMERATION) || | 683 (facetType == XML_SCHEMA_FACET_ENUMERATION) || |
680 (facetType == XML_SCHEMA_FACET_WHITESPACE)) | 684 (facetType == XML_SCHEMA_FACET_WHITESPACE)) |
681 return (1); | 685 return (1); |
682 else | 686 else |
683 return (0); | 687 return (0); |
684 case XML_SCHEMAS_DECIMAL: | 688 case XML_SCHEMAS_DECIMAL: |
685 if ((facetType == XML_SCHEMA_FACET_TOTALDIGITS) || | 689 if ((facetType == XML_SCHEMA_FACET_TOTALDIGITS) || |
686 (facetType == XML_SCHEMA_FACET_FRACTIONDIGITS) || | 690 (facetType == XML_SCHEMA_FACET_FRACTIONDIGITS) || |
687 (facetType == XML_SCHEMA_FACET_PATTERN) || | 691 (facetType == XML_SCHEMA_FACET_PATTERN) || |
688 (facetType == XML_SCHEMA_FACET_WHITESPACE) || | 692 (facetType == XML_SCHEMA_FACET_WHITESPACE) || |
689 (facetType == XML_SCHEMA_FACET_ENUMERATION) || | 693 (facetType == XML_SCHEMA_FACET_ENUMERATION) || |
690 (facetType == XML_SCHEMA_FACET_MAXINCLUSIVE) || | 694 (facetType == XML_SCHEMA_FACET_MAXINCLUSIVE) || |
691 (facetType == XML_SCHEMA_FACET_MAXEXCLUSIVE) || | 695 (facetType == XML_SCHEMA_FACET_MAXEXCLUSIVE) || |
692 (facetType == XML_SCHEMA_FACET_MININCLUSIVE) || | 696 (facetType == XML_SCHEMA_FACET_MININCLUSIVE) || |
693 (facetType == XML_SCHEMA_FACET_MINEXCLUSIVE)) | 697 (facetType == XML_SCHEMA_FACET_MINEXCLUSIVE)) |
694 return (1); | 698 return (1); |
695 else | 699 else |
696 » » return (0); | 700 » » return (0); |
697 case XML_SCHEMAS_TIME: | 701 case XML_SCHEMAS_TIME: |
698 » case XML_SCHEMAS_GDAY: | 702 » case XML_SCHEMAS_GDAY: |
699 case XML_SCHEMAS_GMONTH: | 703 case XML_SCHEMAS_GMONTH: |
700 » case XML_SCHEMAS_GMONTHDAY: | 704 » case XML_SCHEMAS_GMONTHDAY: |
701 » case XML_SCHEMAS_GYEAR: | 705 » case XML_SCHEMAS_GYEAR: |
702 case XML_SCHEMAS_GYEARMONTH: | 706 case XML_SCHEMAS_GYEARMONTH: |
703 case XML_SCHEMAS_DATE: | 707 case XML_SCHEMAS_DATE: |
704 case XML_SCHEMAS_DATETIME: | 708 case XML_SCHEMAS_DATETIME: |
705 case XML_SCHEMAS_DURATION: | 709 case XML_SCHEMAS_DURATION: |
706 case XML_SCHEMAS_FLOAT: | 710 case XML_SCHEMAS_FLOAT: |
707 case XML_SCHEMAS_DOUBLE: | 711 case XML_SCHEMAS_DOUBLE: |
708 if ((facetType == XML_SCHEMA_FACET_PATTERN) || | 712 if ((facetType == XML_SCHEMA_FACET_PATTERN) || |
709 (facetType == XML_SCHEMA_FACET_ENUMERATION) || | 713 (facetType == XML_SCHEMA_FACET_ENUMERATION) || |
710 (facetType == XML_SCHEMA_FACET_WHITESPACE) || | 714 (facetType == XML_SCHEMA_FACET_WHITESPACE) || |
711 (facetType == XML_SCHEMA_FACET_MAXINCLUSIVE) || | 715 (facetType == XML_SCHEMA_FACET_MAXINCLUSIVE) || |
712 (facetType == XML_SCHEMA_FACET_MAXEXCLUSIVE) || | 716 (facetType == XML_SCHEMA_FACET_MAXEXCLUSIVE) || |
713 (facetType == XML_SCHEMA_FACET_MININCLUSIVE) || | 717 (facetType == XML_SCHEMA_FACET_MININCLUSIVE) || |
714 (facetType == XML_SCHEMA_FACET_MINEXCLUSIVE)) | 718 (facetType == XML_SCHEMA_FACET_MINEXCLUSIVE)) |
715 return (1); | 719 return (1); |
716 else | 720 else |
717 » » return (0);» » » » » | 721 » » return (0); |
718 default: | 722 default: |
719 break; | 723 break; |
720 } | 724 } |
721 return (0); | 725 return (0); |
722 } | 726 } |
723 | 727 |
724 /** | 728 /** |
725 * xmlSchemaGetBuiltInType: | 729 * xmlSchemaGetBuiltInType: |
726 * @type: the type of the built in type | 730 * @type: the type of the built in type |
727 * | 731 * |
728 * Gives you the type struct for a built-in | 732 * Gives you the type struct for a built-in |
729 * type by its type id. | 733 * type by its type id. |
730 * | 734 * |
731 * Returns the type if found, NULL otherwise. | 735 * Returns the type if found, NULL otherwise. |
732 */ | 736 */ |
733 xmlSchemaTypePtr | 737 xmlSchemaTypePtr |
734 xmlSchemaGetBuiltInType(xmlSchemaValType type) | 738 xmlSchemaGetBuiltInType(xmlSchemaValType type) |
735 { | 739 { |
736 if (xmlSchemaTypesInitialized == 0) | 740 if (xmlSchemaTypesInitialized == 0) |
737 xmlSchemaInitTypes(); | 741 xmlSchemaInitTypes(); |
738 switch (type) { | 742 switch (type) { |
739 » | 743 |
740 case XML_SCHEMAS_ANYSIMPLETYPE: | 744 case XML_SCHEMAS_ANYSIMPLETYPE: |
741 return (xmlSchemaTypeAnySimpleTypeDef); | 745 return (xmlSchemaTypeAnySimpleTypeDef); |
742 case XML_SCHEMAS_STRING: | 746 case XML_SCHEMAS_STRING: |
743 return (xmlSchemaTypeStringDef); | 747 return (xmlSchemaTypeStringDef); |
744 case XML_SCHEMAS_NORMSTRING: | 748 case XML_SCHEMAS_NORMSTRING: |
745 return (xmlSchemaTypeNormStringDef); | 749 return (xmlSchemaTypeNormStringDef); |
746 case XML_SCHEMAS_DECIMAL: | 750 case XML_SCHEMAS_DECIMAL: |
747 return (xmlSchemaTypeDecimalDef); | 751 return (xmlSchemaTypeDecimalDef); |
748 case XML_SCHEMAS_TIME: | 752 case XML_SCHEMAS_TIME: |
749 return (xmlSchemaTypeTimeDef); | 753 return (xmlSchemaTypeTimeDef); |
750 case XML_SCHEMAS_GDAY: | 754 case XML_SCHEMAS_GDAY: |
751 return (xmlSchemaTypeGDayDef); | 755 return (xmlSchemaTypeGDayDef); |
752 case XML_SCHEMAS_GMONTH: | 756 case XML_SCHEMAS_GMONTH: |
753 return (xmlSchemaTypeGMonthDef); | 757 return (xmlSchemaTypeGMonthDef); |
754 case XML_SCHEMAS_GMONTHDAY: | 758 case XML_SCHEMAS_GMONTHDAY: |
755 » return (xmlSchemaTypeGMonthDayDef); | 759 » return (xmlSchemaTypeGMonthDayDef); |
756 case XML_SCHEMAS_GYEAR: | 760 case XML_SCHEMAS_GYEAR: |
757 return (xmlSchemaTypeGYearDef); | 761 return (xmlSchemaTypeGYearDef); |
758 case XML_SCHEMAS_GYEARMONTH: | 762 case XML_SCHEMAS_GYEARMONTH: |
759 return (xmlSchemaTypeGYearMonthDef); | 763 return (xmlSchemaTypeGYearMonthDef); |
760 case XML_SCHEMAS_DATE: | 764 case XML_SCHEMAS_DATE: |
761 return (xmlSchemaTypeDateDef); | 765 return (xmlSchemaTypeDateDef); |
762 case XML_SCHEMAS_DATETIME: | 766 case XML_SCHEMAS_DATETIME: |
763 return (xmlSchemaTypeDatetimeDef); | 767 return (xmlSchemaTypeDatetimeDef); |
764 case XML_SCHEMAS_DURATION: | 768 case XML_SCHEMAS_DURATION: |
765 return (xmlSchemaTypeDurationDef); | 769 return (xmlSchemaTypeDurationDef); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 return (xmlSchemaTypeUnsignedShortDef); | 825 return (xmlSchemaTypeUnsignedShortDef); |
822 case XML_SCHEMAS_BYTE: | 826 case XML_SCHEMAS_BYTE: |
823 return (xmlSchemaTypeByteDef); | 827 return (xmlSchemaTypeByteDef); |
824 case XML_SCHEMAS_UBYTE: | 828 case XML_SCHEMAS_UBYTE: |
825 return (xmlSchemaTypeUnsignedByteDef); | 829 return (xmlSchemaTypeUnsignedByteDef); |
826 case XML_SCHEMAS_HEXBINARY: | 830 case XML_SCHEMAS_HEXBINARY: |
827 return (xmlSchemaTypeHexBinaryDef); | 831 return (xmlSchemaTypeHexBinaryDef); |
828 case XML_SCHEMAS_BASE64BINARY: | 832 case XML_SCHEMAS_BASE64BINARY: |
829 return (xmlSchemaTypeBase64BinaryDef); | 833 return (xmlSchemaTypeBase64BinaryDef); |
830 case XML_SCHEMAS_ANYTYPE: | 834 case XML_SCHEMAS_ANYTYPE: |
831 » return (xmlSchemaTypeAnyTypeDef);» | 835 » return (xmlSchemaTypeAnyTypeDef); |
832 default: | 836 default: |
833 return (NULL); | 837 return (NULL); |
834 } | 838 } |
835 } | 839 } |
836 | 840 |
837 /** | 841 /** |
838 * xmlSchemaValueAppend: | 842 * xmlSchemaValueAppend: |
839 * @prev: the value | 843 * @prev: the value |
840 * @cur: the value to be appended | 844 * @cur: the value to be appended |
841 * | 845 * |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 * xmlSchemaValueGetAsString: | 877 * xmlSchemaValueGetAsString: |
874 * @val: the value | 878 * @val: the value |
875 * | 879 * |
876 * Accessor for the string value of a computed value. | 880 * Accessor for the string value of a computed value. |
877 * | 881 * |
878 * Returns the string value or NULL if there was none, or on | 882 * Returns the string value or NULL if there was none, or on |
879 * API errors. | 883 * API errors. |
880 */ | 884 */ |
881 const xmlChar * | 885 const xmlChar * |
882 xmlSchemaValueGetAsString(xmlSchemaValPtr val) | 886 xmlSchemaValueGetAsString(xmlSchemaValPtr val) |
883 { | 887 { |
884 if (val == NULL) | 888 if (val == NULL) |
885 return (NULL); | 889 return (NULL); |
886 switch (val->type) { | 890 switch (val->type) { |
887 case XML_SCHEMAS_STRING: | 891 case XML_SCHEMAS_STRING: |
888 case XML_SCHEMAS_NORMSTRING: | 892 case XML_SCHEMAS_NORMSTRING: |
889 case XML_SCHEMAS_ANYSIMPLETYPE: | 893 case XML_SCHEMAS_ANYSIMPLETYPE: |
890 case XML_SCHEMAS_TOKEN: | 894 case XML_SCHEMAS_TOKEN: |
891 case XML_SCHEMAS_LANGUAGE: | 895 case XML_SCHEMAS_LANGUAGE: |
892 case XML_SCHEMAS_NMTOKEN: | 896 case XML_SCHEMAS_NMTOKEN: |
893 case XML_SCHEMAS_NAME: | 897 case XML_SCHEMAS_NAME: |
(...skipping 12 matching lines...) Expand all Loading... |
906 /** | 910 /** |
907 * xmlSchemaValueGetAsBoolean: | 911 * xmlSchemaValueGetAsBoolean: |
908 * @val: the value | 912 * @val: the value |
909 * | 913 * |
910 * Accessor for the boolean value of a computed value. | 914 * Accessor for the boolean value of a computed value. |
911 * | 915 * |
912 * Returns 1 if true and 0 if false, or in case of an error. Hmm. | 916 * Returns 1 if true and 0 if false, or in case of an error. Hmm. |
913 */ | 917 */ |
914 int | 918 int |
915 xmlSchemaValueGetAsBoolean(xmlSchemaValPtr val) | 919 xmlSchemaValueGetAsBoolean(xmlSchemaValPtr val) |
916 { | 920 { |
917 if ((val == NULL) || (val->type != XML_SCHEMAS_BOOLEAN)) | 921 if ((val == NULL) || (val->type != XML_SCHEMAS_BOOLEAN)) |
918 return (0); | 922 return (0); |
919 return (val->value.b); | 923 return (val->value.b); |
920 } | 924 } |
921 | 925 |
922 /** | 926 /** |
923 * xmlSchemaNewStringValue: | 927 * xmlSchemaNewStringValue: |
924 * @type: the value type | 928 * @type: the value type |
925 * @value: the value | 929 * @value: the value |
926 * | 930 * |
927 * Allocate a new simple type value. The type can be | 931 * Allocate a new simple type value. The type can be |
928 * of XML_SCHEMAS_STRING. | 932 * of XML_SCHEMAS_STRING. |
929 * WARNING: This one is intended to be expanded for other | 933 * WARNING: This one is intended to be expanded for other |
930 * string based types. We need this for anySimpleType as well. | 934 * string based types. We need this for anySimpleType as well. |
931 * The given value is consumed and freed with the struct. | 935 * The given value is consumed and freed with the struct. |
932 * | 936 * |
933 * Returns a pointer to the new value or NULL in case of error | 937 * Returns a pointer to the new value or NULL in case of error |
934 */ | 938 */ |
935 xmlSchemaValPtr | 939 xmlSchemaValPtr |
936 xmlSchemaNewStringValue(xmlSchemaValType type, | 940 xmlSchemaNewStringValue(xmlSchemaValType type, |
937 const xmlChar *value) | 941 const xmlChar *value) |
938 { | 942 { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 val->value.qname.uri = (xmlChar *) namespaceName; | 1004 val->value.qname.uri = (xmlChar *) namespaceName; |
1001 return(val); | 1005 return(val); |
1002 } | 1006 } |
1003 | 1007 |
1004 /** | 1008 /** |
1005 * xmlSchemaFreeValue: | 1009 * xmlSchemaFreeValue: |
1006 * @value: the value to free | 1010 * @value: the value to free |
1007 * | 1011 * |
1008 * Cleanup the default XML Schemas type library | 1012 * Cleanup the default XML Schemas type library |
1009 */ | 1013 */ |
1010 void» | 1014 void |
1011 xmlSchemaFreeValue(xmlSchemaValPtr value) { | 1015 xmlSchemaFreeValue(xmlSchemaValPtr value) { |
1012 xmlSchemaValPtr prev; | 1016 xmlSchemaValPtr prev; |
1013 | 1017 |
1014 while (value != NULL) {» | 1018 while (value != NULL) { |
1015 switch (value->type) { | 1019 switch (value->type) { |
1016 case XML_SCHEMAS_STRING: | 1020 case XML_SCHEMAS_STRING: |
1017 case XML_SCHEMAS_NORMSTRING: | 1021 case XML_SCHEMAS_NORMSTRING: |
1018 case XML_SCHEMAS_TOKEN: | 1022 case XML_SCHEMAS_TOKEN: |
1019 case XML_SCHEMAS_LANGUAGE: | 1023 case XML_SCHEMAS_LANGUAGE: |
1020 case XML_SCHEMAS_NMTOKEN: | 1024 case XML_SCHEMAS_NMTOKEN: |
1021 case XML_SCHEMAS_NMTOKENS: | 1025 case XML_SCHEMAS_NMTOKENS: |
1022 case XML_SCHEMAS_NAME: | 1026 case XML_SCHEMAS_NAME: |
1023 case XML_SCHEMAS_NCNAME: | 1027 case XML_SCHEMAS_NCNAME: |
1024 case XML_SCHEMAS_ID: | 1028 case XML_SCHEMAS_ID: |
1025 case XML_SCHEMAS_IDREF: | 1029 case XML_SCHEMAS_IDREF: |
1026 case XML_SCHEMAS_IDREFS: | 1030 case XML_SCHEMAS_IDREFS: |
1027 case XML_SCHEMAS_ENTITY: | 1031 case XML_SCHEMAS_ENTITY: |
1028 » case XML_SCHEMAS_ENTITIES: | 1032 » case XML_SCHEMAS_ENTITIES: |
1029 case XML_SCHEMAS_ANYURI: | 1033 case XML_SCHEMAS_ANYURI: |
1030 case XML_SCHEMAS_ANYSIMPLETYPE: | 1034 case XML_SCHEMAS_ANYSIMPLETYPE: |
1031 if (value->value.str != NULL) | 1035 if (value->value.str != NULL) |
1032 xmlFree(value->value.str); | 1036 xmlFree(value->value.str); |
1033 break; | 1037 break; |
1034 case XML_SCHEMAS_NOTATION: | 1038 case XML_SCHEMAS_NOTATION: |
1035 case XML_SCHEMAS_QNAME: | 1039 case XML_SCHEMAS_QNAME: |
1036 if (value->value.qname.uri != NULL) | 1040 if (value->value.qname.uri != NULL) |
1037 xmlFree(value->value.qname.uri); | 1041 xmlFree(value->value.qname.uri); |
1038 if (value->value.qname.name != NULL) | 1042 if (value->value.qname.name != NULL) |
1039 xmlFree(value->value.qname.name); | 1043 xmlFree(value->value.qname.name); |
1040 break; | 1044 break; |
1041 case XML_SCHEMAS_HEXBINARY: | 1045 case XML_SCHEMAS_HEXBINARY: |
1042 if (value->value.hex.str != NULL) | 1046 if (value->value.hex.str != NULL) |
1043 xmlFree(value->value.hex.str); | 1047 xmlFree(value->value.hex.str); |
1044 break; | 1048 break; |
1045 case XML_SCHEMAS_BASE64BINARY: | 1049 case XML_SCHEMAS_BASE64BINARY: |
1046 if (value->value.base64.str != NULL) | 1050 if (value->value.base64.str != NULL) |
1047 xmlFree(value->value.base64.str); | 1051 xmlFree(value->value.base64.str); |
1048 break; | 1052 break; |
1049 default: | 1053 default: |
1050 break; | 1054 break; |
1051 } | 1055 } |
1052 prev = value; | 1056 prev = value; |
1053 value = value->next; | 1057 value = value->next; |
1054 xmlFree(prev); | 1058 xmlFree(prev); |
1055 } | 1059 } |
1056 } | 1060 } |
1057 | 1061 |
1058 /** | 1062 /** |
1059 * xmlSchemaGetPredefinedType: | 1063 * xmlSchemaGetPredefinedType: |
1060 * @name: the type name | 1064 * @name: the type name |
1061 * @ns: the URI of the namespace usually "http://www.w3.org/2001/XMLSchema" | 1065 * @ns: the URI of the namespace usually "http://www.w3.org/2001/XMLSchema" |
1062 * | 1066 * |
1063 * Lookup a type in the default XML Schemas type library | 1067 * Lookup a type in the default XML Schemas type library |
1064 * | 1068 * |
1065 * Returns the type if found, NULL otherwise | 1069 * Returns the type if found, NULL otherwise |
(...skipping 15 matching lines...) Expand all Loading... |
1081 * | 1085 * |
1082 * Returns the item type of @type as defined by the built-in datatype | 1086 * Returns the item type of @type as defined by the built-in datatype |
1083 * hierarchy of XML Schema Part 2: Datatypes, or NULL in case of an error. | 1087 * hierarchy of XML Schema Part 2: Datatypes, or NULL in case of an error. |
1084 */ | 1088 */ |
1085 xmlSchemaTypePtr | 1089 xmlSchemaTypePtr |
1086 xmlSchemaGetBuiltInListSimpleTypeItemType(xmlSchemaTypePtr type) | 1090 xmlSchemaGetBuiltInListSimpleTypeItemType(xmlSchemaTypePtr type) |
1087 { | 1091 { |
1088 if ((type == NULL) || (type->type != XML_SCHEMA_TYPE_BASIC)) | 1092 if ((type == NULL) || (type->type != XML_SCHEMA_TYPE_BASIC)) |
1089 return (NULL); | 1093 return (NULL); |
1090 switch (type->builtInType) { | 1094 switch (type->builtInType) { |
1091 » case XML_SCHEMAS_NMTOKENS: | 1095 » case XML_SCHEMAS_NMTOKENS: |
1092 return (xmlSchemaTypeNmtokenDef ); | 1096 return (xmlSchemaTypeNmtokenDef ); |
1093 » case XML_SCHEMAS_IDREFS: | 1097 » case XML_SCHEMAS_IDREFS: |
1094 return (xmlSchemaTypeIdrefDef); | 1098 return (xmlSchemaTypeIdrefDef); |
1095 case XML_SCHEMAS_ENTITIES: | 1099 case XML_SCHEMAS_ENTITIES: |
1096 return (xmlSchemaTypeEntityDef); | 1100 return (xmlSchemaTypeEntityDef); |
1097 default: | 1101 default: |
1098 return (NULL); | 1102 return (NULL); |
1099 } | 1103 } |
1100 } | 1104 } |
1101 | 1105 |
1102 /**************************************************************** | 1106 /**************************************************************** |
1103 * * | 1107 * * |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 * | 1339 * |
1336 * Parses a xs:time without time zone and fills in the appropriate | 1340 * Parses a xs:time without time zone and fills in the appropriate |
1337 * fields of the @dt structure. @str is updated to point just after the | 1341 * fields of the @dt structure. @str is updated to point just after the |
1338 * xs:time. | 1342 * xs:time. |
1339 * In case of error, values of @dt fields are undefined. | 1343 * In case of error, values of @dt fields are undefined. |
1340 * | 1344 * |
1341 * Returns 0 or the error code | 1345 * Returns 0 or the error code |
1342 */ | 1346 */ |
1343 static int | 1347 static int |
1344 _xmlSchemaParseTime (xmlSchemaValDatePtr dt, const xmlChar **str) { | 1348 _xmlSchemaParseTime (xmlSchemaValDatePtr dt, const xmlChar **str) { |
1345 const xmlChar *cur = *str; | 1349 const xmlChar *cur = *str; |
1346 int ret = 0; | 1350 int ret = 0; |
1347 int value = 0; | 1351 int value = 0; |
1348 | 1352 |
1349 PARSE_2_DIGITS(value, cur, ret); | 1353 PARSE_2_DIGITS(value, cur, ret); |
1350 if (ret != 0) | 1354 if (ret != 0) |
1351 » return ret; | 1355 » return ret; |
1352 if (*cur != ':') | 1356 if (*cur != ':') |
1353 return 1; | 1357 return 1; |
1354 if (!VALID_HOUR(value)) | 1358 if (!VALID_HOUR(value)) |
1355 return 2; | 1359 return 2; |
1356 cur++; | 1360 cur++; |
1357 | 1361 |
1358 /* the ':' insures this string is xs:time */ | 1362 /* the ':' insures this string is xs:time */ |
1359 dt->hour = value; | 1363 dt->hour = value; |
1360 | 1364 |
1361 PARSE_2_DIGITS(value, cur, ret); | 1365 PARSE_2_DIGITS(value, cur, ret); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1607 * a negative time zone offset. Check for xs:gMonthDay first. | 1611 * a negative time zone offset. Check for xs:gMonthDay first. |
1608 * Also the first three char's of a negative tzo (-MM:SS) can | 1612 * Also the first three char's of a negative tzo (-MM:SS) can |
1609 * appear to be a valid day; so even if the day portion | 1613 * appear to be a valid day; so even if the day portion |
1610 * of the xs:gMonthDay verifies, we must insure it was not | 1614 * of the xs:gMonthDay verifies, we must insure it was not |
1611 * a tzo. | 1615 * a tzo. |
1612 */ | 1616 */ |
1613 if (*cur == '-') { | 1617 if (*cur == '-') { |
1614 const xmlChar *rewnd = cur; | 1618 const xmlChar *rewnd = cur; |
1615 cur++; | 1619 cur++; |
1616 | 1620 |
1617 » ret = _xmlSchemaParseGDay(&(dt->value.date), &cur); | 1621 » ret = _xmlSchemaParseGDay(&(dt->value.date), &cur); |
1618 if ((ret == 0) && ((*cur == 0) || (*cur != ':'))) { | 1622 if ((ret == 0) && ((*cur == 0) || (*cur != ':'))) { |
1619 | 1623 |
1620 /* | 1624 /* |
1621 * we can use the VALID_MDAY macro to validate the month | 1625 * we can use the VALID_MDAY macro to validate the month |
1622 * and day because the leap year test will flag year zero | 1626 * and day because the leap year test will flag year zero |
1623 * as a leap year (even though zero is an invalid year). | 1627 * as a leap year (even though zero is an invalid year). |
1624 * FUTURE TODO: Zero will become valid in XML Schema 1.1 | 1628 * FUTURE TODO: Zero will become valid in XML Schema 1.1 |
1625 * probably. | 1629 * probably. |
1626 */ | 1630 */ |
1627 if (VALID_MDAY((&(dt->value.date)))) { | 1631 if (VALID_MDAY((&(dt->value.date)))) { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 } | 1849 } |
1846 | 1850 |
1847 break; /* exit loop */ | 1851 break; /* exit loop */ |
1848 } | 1852 } |
1849 /* no date designators found? */ | 1853 /* no date designators found? */ |
1850 if ((++seq == 3) || (seq == 6)) | 1854 if ((++seq == 3) || (seq == 6)) |
1851 goto error; | 1855 goto error; |
1852 } | 1856 } |
1853 cur++; | 1857 cur++; |
1854 if (collapse) | 1858 if (collapse) |
1855 » while IS_WSP_BLANK_CH(*cur) cur++; | 1859 » while IS_WSP_BLANK_CH(*cur) cur++; |
1856 } | 1860 } |
1857 | 1861 |
1858 if (isneg) { | 1862 if (isneg) { |
1859 dur->value.dur.mon = -dur->value.dur.mon; | 1863 dur->value.dur.mon = -dur->value.dur.mon; |
1860 dur->value.dur.day = -dur->value.dur.day; | 1864 dur->value.dur.day = -dur->value.dur.day; |
1861 dur->value.dur.sec = -dur->value.dur.sec; | 1865 dur->value.dur.sec = -dur->value.dur.sec; |
1862 } | 1866 } |
1863 | 1867 |
1864 if (val != NULL) | 1868 if (val != NULL) |
1865 *val = dur; | 1869 *val = dur; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 /** | 1905 /** |
1902 * xmlSchemaWhiteSpaceReplace: | 1906 * xmlSchemaWhiteSpaceReplace: |
1903 * @value: a value | 1907 * @value: a value |
1904 * | 1908 * |
1905 * Replaces 0xd, 0x9 and 0xa with a space. | 1909 * Replaces 0xd, 0x9 and 0xa with a space. |
1906 * | 1910 * |
1907 * Returns the new string or NULL if no change was required. | 1911 * Returns the new string or NULL if no change was required. |
1908 */ | 1912 */ |
1909 xmlChar * | 1913 xmlChar * |
1910 xmlSchemaWhiteSpaceReplace(const xmlChar *value) { | 1914 xmlSchemaWhiteSpaceReplace(const xmlChar *value) { |
1911 const xmlChar *cur = value; | 1915 const xmlChar *cur = value; |
1912 xmlChar *ret = NULL, *mcur; | 1916 xmlChar *ret = NULL, *mcur; |
1913 | 1917 |
1914 if (value == NULL) | 1918 if (value == NULL) |
1915 return(NULL); | 1919 return(NULL); |
1916 | 1920 |
1917 while ((*cur != 0) && | 1921 while ((*cur != 0) && |
1918 (((*cur) != 0xd) && ((*cur) != 0x9) && ((*cur) != 0xa))) { | 1922 (((*cur) != 0xd) && ((*cur) != 0x9) && ((*cur) != 0xa))) { |
1919 cur++; | 1923 cur++; |
1920 } | 1924 } |
1921 if (*cur == 0) | 1925 if (*cur == 0) |
1922 return (NULL); | 1926 return (NULL); |
1923 ret = xmlStrdup(value); | 1927 ret = xmlStrdup(value); |
1924 /* TODO FIXME: I guess gcc will bark at this. */ | 1928 /* TODO FIXME: I guess gcc will bark at this. */ |
1925 mcur = (xmlChar *) (ret + (cur - value)); | 1929 mcur = (xmlChar *) (ret + (cur - value)); |
1926 do { | 1930 do { |
1927 if ( ((*mcur) == 0xd) || ((*mcur) == 0x9) || ((*mcur) == 0xa) ) | 1931 if ( ((*mcur) == 0xd) || ((*mcur) == 0x9) || ((*mcur) == 0xa) ) |
1928 *mcur = ' '; | 1932 *mcur = ' '; |
1929 mcur++; | 1933 mcur++; |
1930 } while (*mcur != 0);» | 1934 } while (*mcur != 0); |
1931 return(ret); | 1935 return(ret); |
1932 } | 1936 } |
1933 | 1937 |
1934 /** | 1938 /** |
1935 * xmlSchemaCollapseString: | 1939 * xmlSchemaCollapseString: |
1936 * @value: a value | 1940 * @value: a value |
1937 * | 1941 * |
1938 * Removes and normalize white spaces in the string | 1942 * Removes and normalize white spaces in the string |
1939 * | 1943 * |
1940 * Returns the new string or NULL if no change was required. | 1944 * Returns the new string or NULL if no change was required. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 * Returns the number of significant digits in the number or | 2069 * Returns the number of significant digits in the number or |
2066 * -1 if overflow of the capacity and -2 if it's not a number. | 2070 * -1 if overflow of the capacity and -2 if it's not a number. |
2067 */ | 2071 */ |
2068 static int | 2072 static int |
2069 xmlSchemaParseUInt(const xmlChar **str, unsigned long *llo, | 2073 xmlSchemaParseUInt(const xmlChar **str, unsigned long *llo, |
2070 unsigned long *lmi, unsigned long *lhi) { | 2074 unsigned long *lmi, unsigned long *lhi) { |
2071 unsigned long lo = 0, mi = 0, hi = 0; | 2075 unsigned long lo = 0, mi = 0, hi = 0; |
2072 const xmlChar *tmp, *cur = *str; | 2076 const xmlChar *tmp, *cur = *str; |
2073 int ret = 0, i = 0; | 2077 int ret = 0, i = 0; |
2074 | 2078 |
2075 if (!((*cur >= '0') && (*cur <= '9'))) | 2079 if (!((*cur >= '0') && (*cur <= '9'))) |
2076 return(-2); | 2080 return(-2); |
2077 | 2081 |
2078 while (*cur == '0') { /* ignore leading zeroes */ | 2082 while (*cur == '0') { /* ignore leading zeroes */ |
2079 cur++; | 2083 cur++; |
2080 } | 2084 } |
2081 tmp = cur; | 2085 tmp = cur; |
2082 while ((*tmp != 0) && (*tmp >= '0') && (*tmp <= '9')) { | 2086 while ((*tmp != 0) && (*tmp >= '0') && (*tmp <= '9')) { |
2083 i++;tmp++;ret++; | 2087 i++;tmp++;ret++; |
2084 } | 2088 } |
2085 if (i > 24) { | 2089 if (i > 24) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2141 * an empty one. | 2145 * an empty one. |
2142 */ | 2146 */ |
2143 if (value == NULL) | 2147 if (value == NULL) |
2144 value = BAD_CAST ""; | 2148 value = BAD_CAST ""; |
2145 | 2149 |
2146 if (val != NULL) | 2150 if (val != NULL) |
2147 *val = NULL; | 2151 *val = NULL; |
2148 if ((flags == 0) && (value != NULL)) { | 2152 if ((flags == 0) && (value != NULL)) { |
2149 | 2153 |
2150 if ((type->builtInType != XML_SCHEMAS_STRING) && | 2154 if ((type->builtInType != XML_SCHEMAS_STRING) && |
2151 » (type->builtInType != XML_SCHEMAS_ANYTYPE) && | 2155 » (type->builtInType != XML_SCHEMAS_ANYTYPE) && |
2152 (type->builtInType != XML_SCHEMAS_ANYSIMPLETYPE)) { | 2156 (type->builtInType != XML_SCHEMAS_ANYSIMPLETYPE)) { |
2153 if (type->builtInType == XML_SCHEMAS_NORMSTRING) | 2157 if (type->builtInType == XML_SCHEMAS_NORMSTRING) |
2154 norm = xmlSchemaWhiteSpaceReplace(value); | 2158 norm = xmlSchemaWhiteSpaceReplace(value); |
2155 else | 2159 else |
2156 norm = xmlSchemaCollapseString(value); | 2160 norm = xmlSchemaCollapseString(value); |
2157 if (norm != NULL) | 2161 if (norm != NULL) |
2158 value = norm; | 2162 value = norm; |
2159 } | 2163 } |
2160 } | 2164 } |
2161 | 2165 |
2162 switch (type->builtInType) { | 2166 switch (type->builtInType) { |
2163 case XML_SCHEMAS_UNKNOWN: | 2167 case XML_SCHEMAS_UNKNOWN: |
2164 goto error; | 2168 goto error; |
2165 case XML_SCHEMAS_ANYTYPE: | 2169 case XML_SCHEMAS_ANYTYPE: |
2166 case XML_SCHEMAS_ANYSIMPLETYPE: | 2170 case XML_SCHEMAS_ANYSIMPLETYPE: |
2167 if ((createStringValue) && (val != NULL)) { | 2171 if ((createStringValue) && (val != NULL)) { |
2168 v = xmlSchemaNewValue(XML_SCHEMAS_ANYSIMPLETYPE); | 2172 v = xmlSchemaNewValue(XML_SCHEMAS_ANYSIMPLETYPE); |
2169 if (v != NULL) { | 2173 if (v != NULL) { |
2170 v->value.str = xmlStrdup(value); | 2174 v->value.str = xmlStrdup(value); |
2171 *val = v; | 2175 *val = v; |
2172 } else { | 2176 } else { |
2173 goto error; | 2177 goto error; |
2174 » » }» » | 2178 » » } |
2175 } | 2179 } |
2176 goto return0; | 2180 goto return0; |
2177 case XML_SCHEMAS_STRING:» » | 2181 case XML_SCHEMAS_STRING: |
2178 if (! normOnTheFly) { | 2182 if (! normOnTheFly) { |
2179 const xmlChar *cur = value; | 2183 const xmlChar *cur = value; |
2180 | 2184 |
2181 if (ws == XML_SCHEMA_WHITESPACE_REPLACE) { | 2185 if (ws == XML_SCHEMA_WHITESPACE_REPLACE) { |
2182 while (*cur != 0) { | 2186 while (*cur != 0) { |
2183 if ((*cur == 0xd) || (*cur == 0xa) || (*cur == 0x9)) { | 2187 if ((*cur == 0xd) || (*cur == 0xa) || (*cur == 0x9)) { |
2184 goto return1; | 2188 goto return1; |
2185 } else { | 2189 } else { |
2186 cur++; | 2190 cur++; |
2187 } | 2191 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2246 } else { | 2250 } else { |
2247 goto error; | 2251 goto error; |
2248 } | 2252 } |
2249 } | 2253 } |
2250 goto return0; | 2254 goto return0; |
2251 } | 2255 } |
2252 case XML_SCHEMAS_DECIMAL:{ | 2256 case XML_SCHEMAS_DECIMAL:{ |
2253 const xmlChar *cur = value; | 2257 const xmlChar *cur = value; |
2254 unsigned int len, neg, integ, hasLeadingZeroes; | 2258 unsigned int len, neg, integ, hasLeadingZeroes; |
2255 xmlChar cval[25]; | 2259 xmlChar cval[25]; |
2256 » » xmlChar *cptr = cval;» » | 2260 » » xmlChar *cptr = cval; |
2257 | 2261 |
2258 if ((cur == NULL) || (*cur == 0)) | 2262 if ((cur == NULL) || (*cur == 0)) |
2259 goto return1; | 2263 goto return1; |
2260 | 2264 |
2261 /* | 2265 /* |
2262 * xs:decimal has a whitespace-facet value of 'collapse'. | 2266 * xs:decimal has a whitespace-facet value of 'collapse'. |
2263 */ | 2267 */ |
2264 if (normOnTheFly) | 2268 if (normOnTheFly) |
2265 while IS_WSP_BLANK_CH(*cur) cur++; | 2269 while IS_WSP_BLANK_CH(*cur) cur++; |
2266 | 2270 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 } while (len < 24); | 2324 } while (len < 24); |
2321 } | 2325 } |
2322 if (normOnTheFly) | 2326 if (normOnTheFly) |
2323 while IS_WSP_BLANK_CH(*cur) cur++; | 2327 while IS_WSP_BLANK_CH(*cur) cur++; |
2324 if (*cur != 0) | 2328 if (*cur != 0) |
2325 goto return1; /* error if any extraneous chars */ | 2329 goto return1; /* error if any extraneous chars */ |
2326 if (val != NULL) { | 2330 if (val != NULL) { |
2327 v = xmlSchemaNewValue(XML_SCHEMAS_DECIMAL); | 2331 v = xmlSchemaNewValue(XML_SCHEMAS_DECIMAL); |
2328 if (v != NULL) { | 2332 if (v != NULL) { |
2329 /* | 2333 /* |
2330 » » » * Now evaluate the significant digits of the number | 2334 » » » * Now evaluate the significant digits of the number |
2331 » » » */ | 2335 » » » */ |
2332 if (len != 0) { | 2336 if (len != 0) { |
2333 » » » | 2337 |
2334 if (integ != ~0u) { | 2338 if (integ != ~0u) { |
2335 /* | 2339 /* |
2336 * Get rid of trailing zeroes in the | 2340 * Get rid of trailing zeroes in the |
2337 * fractional part. | 2341 * fractional part. |
2338 */ | 2342 */ |
2339 while ((len != integ) && (*(cptr-1) == '0')) { | 2343 while ((len != integ) && (*(cptr-1) == '0')) { |
2340 cptr--; | 2344 cptr--; |
2341 len--; | 2345 len--; |
2342 } | 2346 } |
2343 } | 2347 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2382 case XML_SCHEMAS_DATE: | 2386 case XML_SCHEMAS_DATE: |
2383 case XML_SCHEMAS_DATETIME: | 2387 case XML_SCHEMAS_DATETIME: |
2384 ret = xmlSchemaValidateDates(type->builtInType, value, val, | 2388 ret = xmlSchemaValidateDates(type->builtInType, value, val, |
2385 normOnTheFly); | 2389 normOnTheFly); |
2386 break; | 2390 break; |
2387 case XML_SCHEMAS_DURATION: | 2391 case XML_SCHEMAS_DURATION: |
2388 ret = xmlSchemaValidateDuration(type, value, val, | 2392 ret = xmlSchemaValidateDuration(type, value, val, |
2389 normOnTheFly); | 2393 normOnTheFly); |
2390 break; | 2394 break; |
2391 case XML_SCHEMAS_FLOAT: | 2395 case XML_SCHEMAS_FLOAT: |
2392 case XML_SCHEMAS_DOUBLE:{ | 2396 case XML_SCHEMAS_DOUBLE: { |
2393 const xmlChar *cur = value; | 2397 const xmlChar *cur = value; |
2394 int neg = 0; | 2398 int neg = 0; |
| 2399 int digits_before = 0; |
| 2400 int digits_after = 0; |
2395 | 2401 |
2396 if (normOnTheFly) | 2402 if (normOnTheFly) |
2397 while IS_WSP_BLANK_CH(*cur) cur++; | 2403 while IS_WSP_BLANK_CH(*cur) cur++; |
2398 | 2404 |
2399 if ((cur[0] == 'N') && (cur[1] == 'a') && (cur[2] == 'N')) { | 2405 if ((cur[0] == 'N') && (cur[1] == 'a') && (cur[2] == 'N')) { |
2400 cur += 3; | 2406 cur += 3; |
2401 if (*cur != 0) | 2407 if (*cur != 0) |
2402 goto return1; | 2408 goto return1; |
2403 if (val != NULL) { | 2409 if (val != NULL) { |
2404 if (type == xmlSchemaTypeFloatDef) { | 2410 if (type == xmlSchemaTypeFloatDef) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2457 *val = v; | 2463 *val = v; |
2458 } | 2464 } |
2459 goto return0; | 2465 goto return0; |
2460 } | 2466 } |
2461 if ((neg == 0) && (*cur == '+')) | 2467 if ((neg == 0) && (*cur == '+')) |
2462 cur++; | 2468 cur++; |
2463 if ((cur[0] == 0) || (cur[0] == '+') || (cur[0] == '-')) | 2469 if ((cur[0] == 0) || (cur[0] == '+') || (cur[0] == '-')) |
2464 goto return1; | 2470 goto return1; |
2465 while ((*cur >= '0') && (*cur <= '9')) { | 2471 while ((*cur >= '0') && (*cur <= '9')) { |
2466 cur++; | 2472 cur++; |
| 2473 digits_before++; |
2467 } | 2474 } |
2468 if (*cur == '.') { | 2475 if (*cur == '.') { |
2469 cur++; | 2476 cur++; |
2470 while ((*cur >= '0') && (*cur <= '9')) | 2477 while ((*cur >= '0') && (*cur <= '9')) { |
2471 cur++; | 2478 cur++; |
| 2479 digits_after++; |
| 2480 } |
2472 } | 2481 } |
| 2482 if ((digits_before == 0) && (digits_after == 0)) |
| 2483 goto return1; |
2473 if ((*cur == 'e') || (*cur == 'E')) { | 2484 if ((*cur == 'e') || (*cur == 'E')) { |
2474 cur++; | 2485 cur++; |
2475 if ((*cur == '-') || (*cur == '+')) | 2486 if ((*cur == '-') || (*cur == '+')) |
2476 cur++; | 2487 cur++; |
2477 while ((*cur >= '0') && (*cur <= '9')) | 2488 while ((*cur >= '0') && (*cur <= '9')) |
2478 cur++; | 2489 cur++; |
2479 } | 2490 } |
2480 if (normOnTheFly) | 2491 if (normOnTheFly) |
2481 while IS_WSP_BLANK_CH(*cur) cur++; | 2492 while IS_WSP_BLANK_CH(*cur) cur++; |
2482 | 2493 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2590 goto return1; | 2601 goto return1; |
2591 } else if (*cur == ' ') { | 2602 } else if (*cur == ' ') { |
2592 cur++; | 2603 cur++; |
2593 if (*cur == 0) | 2604 if (*cur == 0) |
2594 goto return1; | 2605 goto return1; |
2595 if (*cur == ' ') | 2606 if (*cur == ' ') |
2596 goto return1; | 2607 goto return1; |
2597 } else { | 2608 } else { |
2598 cur++; | 2609 cur++; |
2599 } | 2610 } |
2600 » » }» » | 2611 » » } |
2601 » » } | 2612 » » } |
2602 if (val != NULL) { | 2613 if (val != NULL) { |
2603 v = xmlSchemaNewValue(XML_SCHEMAS_TOKEN); | 2614 v = xmlSchemaNewValue(XML_SCHEMAS_TOKEN); |
2604 if (v != NULL) { | 2615 if (v != NULL) { |
2605 v->value.str = xmlStrdup(value); | 2616 v->value.str = xmlStrdup(value); |
2606 *val = v; | 2617 *val = v; |
2607 } else { | 2618 } else { |
2608 goto error; | 2619 goto error; |
2609 } | 2620 } |
2610 } | 2621 } |
2611 goto return0; | 2622 goto return0; |
2612 } | 2623 } |
2613 case XML_SCHEMAS_LANGUAGE: | 2624 case XML_SCHEMAS_LANGUAGE: |
2614 » if (normOnTheFly) {»» | 2625 » if (normOnTheFly) { |
2615 norm = xmlSchemaCollapseString(value); | 2626 norm = xmlSchemaCollapseString(value); |
2616 if (norm != NULL) | 2627 if (norm != NULL) |
2617 value = norm; | 2628 value = norm; |
2618 } | 2629 } |
2619 if (xmlCheckLanguageID(value) == 1) { | 2630 if (xmlCheckLanguageID(value) == 1) { |
2620 if (val != NULL) { | 2631 if (val != NULL) { |
2621 v = xmlSchemaNewValue(XML_SCHEMAS_LANGUAGE); | 2632 v = xmlSchemaNewValue(XML_SCHEMAS_LANGUAGE); |
2622 if (v != NULL) { | 2633 if (v != NULL) { |
2623 v->value.str = xmlStrdup(value); | 2634 v->value.str = xmlStrdup(value); |
2624 *val = v; | 2635 *val = v; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2889 } else { | 2900 } else { |
2890 if (local != NULL) | 2901 if (local != NULL) |
2891 xmlFree(local); | 2902 xmlFree(local); |
2892 if (uri != NULL) | 2903 if (uri != NULL) |
2893 xmlFree(uri); | 2904 xmlFree(uri); |
2894 goto error; | 2905 goto error; |
2895 } | 2906 } |
2896 } | 2907 } |
2897 goto done; | 2908 goto done; |
2898 } | 2909 } |
2899 case XML_SCHEMAS_ANYURI:{» » | 2910 case XML_SCHEMAS_ANYURI:{ |
2900 if (*value != 0) { | 2911 if (*value != 0) { |
2901 xmlURIPtr uri; | 2912 xmlURIPtr uri; |
2902 xmlChar *tmpval, *cur; | 2913 xmlChar *tmpval, *cur; |
2903 » » if (normOnTheFly) {»» | 2914 » » if (normOnTheFly) { |
2904 norm = xmlSchemaCollapseString(value); | 2915 norm = xmlSchemaCollapseString(value); |
2905 if (norm != NULL) | 2916 if (norm != NULL) |
2906 value = norm; | 2917 value = norm; |
2907 } | 2918 } |
2908 tmpval = xmlStrdup(value); | 2919 tmpval = xmlStrdup(value); |
2909 for (cur = tmpval; *cur; ++cur) { | 2920 for (cur = tmpval; *cur; ++cur) { |
2910 if (*cur < 32 || *cur >= 127 || *cur == ' ' || | 2921 if (*cur < 32 || *cur >= 127 || *cur == ' ' || |
2911 *cur == '<' || *cur == '>' || *cur == '"' || | 2922 *cur == '<' || *cur == '>' || *cur == '"' || |
2912 *cur == '{' || *cur == '}' || *cur == '|' || | 2923 *cur == '{' || *cur == '}' || *cur == '|' || |
2913 *cur == '\\' || *cur == '^' || *cur == '`' || | 2924 *cur == '\\' || *cur == '^' || *cur == '`' || |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2982 } | 2993 } |
2983 | 2994 |
2984 v->value.hex.str = (xmlChar *) cur; | 2995 v->value.hex.str = (xmlChar *) cur; |
2985 v->value.hex.total = total; | 2996 v->value.hex.total = total; |
2986 *val = v; | 2997 *val = v; |
2987 } | 2998 } |
2988 goto return0; | 2999 goto return0; |
2989 } | 3000 } |
2990 case XML_SCHEMAS_BASE64BINARY:{ | 3001 case XML_SCHEMAS_BASE64BINARY:{ |
2991 /* ISSUE: | 3002 /* ISSUE: |
2992 * | 3003 * |
2993 * Ignore all stray characters? (yes, currently) | 3004 * Ignore all stray characters? (yes, currently) |
2994 * Worry about long lines? (no, currently) | 3005 * Worry about long lines? (no, currently) |
2995 * | 3006 * |
2996 * rfc2045.txt: | 3007 * rfc2045.txt: |
2997 * | 3008 * |
2998 * "The encoded output stream must be represented in lines of | 3009 * "The encoded output stream must be represented in lines of |
2999 * no more than 76 characters each. All line breaks or other | 3010 * no more than 76 characters each. All line breaks or other |
3000 * characters not found in Table 1 must be ignored by decoding | 3011 * characters not found in Table 1 must be ignored by decoding |
3001 * software. In base64 data, characters other than those in | 3012 * software. In base64 data, characters other than those in |
3002 * Table 1, line breaks, and other white space probably | 3013 * Table 1, line breaks, and other white space probably |
3003 * indicate a transmission error, about which a warning | 3014 * indicate a transmission error, about which a warning |
3004 * message or even a message rejection might be appropriate | 3015 * message or even a message rejection might be appropriate |
3005 * under some circumstances." */ | 3016 * under some circumstances." */ |
3006 const xmlChar *cur = value; | 3017 const xmlChar *cur = value; |
3007 xmlChar *base; | 3018 xmlChar *base; |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3398 static int | 3409 static int |
3399 xmlSchemaCompareDecimals(xmlSchemaValPtr x, xmlSchemaValPtr y) | 3410 xmlSchemaCompareDecimals(xmlSchemaValPtr x, xmlSchemaValPtr y) |
3400 { | 3411 { |
3401 xmlSchemaValPtr swp; | 3412 xmlSchemaValPtr swp; |
3402 int order = 1, integx, integy, dlen; | 3413 int order = 1, integx, integy, dlen; |
3403 unsigned long hi, mi, lo; | 3414 unsigned long hi, mi, lo; |
3404 | 3415 |
3405 /* | 3416 /* |
3406 * First test: If x is -ve and not zero | 3417 * First test: If x is -ve and not zero |
3407 */ | 3418 */ |
3408 if ((x->value.decimal.sign) && | 3419 if ((x->value.decimal.sign) && |
3409 ((x->value.decimal.lo != 0) || | 3420 ((x->value.decimal.lo != 0) || |
3410 (x->value.decimal.mi != 0) || | 3421 (x->value.decimal.mi != 0) || |
3411 (x->value.decimal.hi != 0))) { | 3422 (x->value.decimal.hi != 0))) { |
3412 /* | 3423 /* |
3413 * Then if y is -ve and not zero reverse the compare | 3424 * Then if y is -ve and not zero reverse the compare |
3414 */ | 3425 */ |
3415 if ((y->value.decimal.sign) && | 3426 if ((y->value.decimal.sign) && |
3416 ((y->value.decimal.lo != 0) || | 3427 ((y->value.decimal.lo != 0) || |
3417 (y->value.decimal.mi != 0) || | 3428 (y->value.decimal.mi != 0) || |
3418 (y->value.decimal.hi != 0))) | 3429 (y->value.decimal.hi != 0))) |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3555 { 0, 31, 62, 92, 123, 153, 184, 215, 245, 276, 306, 337} }; | 3566 { 0, 31, 62, 92, 123, 153, 184, 215, 245, 276, 306, 337} }; |
3556 | 3567 |
3557 if ((x == NULL) || (y == NULL)) | 3568 if ((x == NULL) || (y == NULL)) |
3558 return -2; | 3569 return -2; |
3559 | 3570 |
3560 /* months */ | 3571 /* months */ |
3561 mon = x->value.dur.mon - y->value.dur.mon; | 3572 mon = x->value.dur.mon - y->value.dur.mon; |
3562 | 3573 |
3563 /* seconds */ | 3574 /* seconds */ |
3564 sec = x->value.dur.sec - y->value.dur.sec; | 3575 sec = x->value.dur.sec - y->value.dur.sec; |
3565 carry = (long)sec / SECS_PER_DAY; | 3576 carry = (long)(sec / SECS_PER_DAY); |
3566 sec -= (double)(carry * SECS_PER_DAY); | 3577 sec -= ((double)carry) * SECS_PER_DAY; |
3567 | 3578 |
3568 /* days */ | 3579 /* days */ |
3569 day = x->value.dur.day - y->value.dur.day + carry; | 3580 day = x->value.dur.day - y->value.dur.day + carry; |
3570 | 3581 |
3571 /* easy test */ | 3582 /* easy test */ |
3572 if (mon == 0) { | 3583 if (mon == 0) { |
3573 if (day == 0) | 3584 if (day == 0) |
3574 if (sec == 0.0) | 3585 if (sec == 0.0) |
3575 return 0; | 3586 return 0; |
3576 else if (sec < 0.0) | 3587 else if (sec < 0.0) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3639 * the returned value. | 3650 * the returned value. |
3640 * | 3651 * |
3641 * returns a pointer to a duplicated #xmlSchemaValPtr or NULL if error. | 3652 * returns a pointer to a duplicated #xmlSchemaValPtr or NULL if error. |
3642 */ | 3653 */ |
3643 static xmlSchemaValPtr | 3654 static xmlSchemaValPtr |
3644 xmlSchemaDupVal (xmlSchemaValPtr v) | 3655 xmlSchemaDupVal (xmlSchemaValPtr v) |
3645 { | 3656 { |
3646 xmlSchemaValPtr ret = xmlSchemaNewValue(v->type); | 3657 xmlSchemaValPtr ret = xmlSchemaNewValue(v->type); |
3647 if (ret == NULL) | 3658 if (ret == NULL) |
3648 return NULL; | 3659 return NULL; |
3649 | 3660 |
3650 memcpy(ret, v, sizeof(xmlSchemaVal)); | 3661 memcpy(ret, v, sizeof(xmlSchemaVal)); |
3651 ret->next = NULL; | 3662 ret->next = NULL; |
3652 return ret; | 3663 return ret; |
3653 } | 3664 } |
3654 | 3665 |
3655 /** | 3666 /** |
3656 * xmlSchemaCopyValue: | 3667 * xmlSchemaCopyValue: |
3657 * @val: the precomputed value to be copied | 3668 * @val: the precomputed value to be copied |
3658 * | 3669 * |
3659 * Copies the precomputed value. This duplicates any string within. | 3670 * Copies the precomputed value. This duplicates any string within. |
(...skipping 25 matching lines...) Expand all Loading... |
3685 case XML_SCHEMAS_NCNAME: | 3696 case XML_SCHEMAS_NCNAME: |
3686 case XML_SCHEMAS_ID: | 3697 case XML_SCHEMAS_ID: |
3687 case XML_SCHEMAS_IDREF: | 3698 case XML_SCHEMAS_IDREF: |
3688 case XML_SCHEMAS_ENTITY: | 3699 case XML_SCHEMAS_ENTITY: |
3689 case XML_SCHEMAS_NMTOKEN: | 3700 case XML_SCHEMAS_NMTOKEN: |
3690 case XML_SCHEMAS_ANYURI: | 3701 case XML_SCHEMAS_ANYURI: |
3691 cur = xmlSchemaDupVal(val); | 3702 cur = xmlSchemaDupVal(val); |
3692 if (val->value.str != NULL) | 3703 if (val->value.str != NULL) |
3693 cur->value.str = xmlStrdup(BAD_CAST val->value.str); | 3704 cur->value.str = xmlStrdup(BAD_CAST val->value.str); |
3694 break; | 3705 break; |
3695 » case XML_SCHEMAS_QNAME: | 3706 » case XML_SCHEMAS_QNAME: |
3696 case XML_SCHEMAS_NOTATION: | 3707 case XML_SCHEMAS_NOTATION: |
3697 cur = xmlSchemaDupVal(val); | 3708 cur = xmlSchemaDupVal(val); |
3698 if (val->value.qname.name != NULL) | 3709 if (val->value.qname.name != NULL) |
3699 cur->value.qname.name = | 3710 cur->value.qname.name = |
3700 xmlStrdup(BAD_CAST val->value.qname.name); | 3711 xmlStrdup(BAD_CAST val->value.qname.name); |
3701 if (val->value.qname.uri != NULL) | 3712 if (val->value.qname.uri != NULL) |
3702 cur->value.qname.uri = | 3713 cur->value.qname.uri = |
3703 xmlStrdup(BAD_CAST val->value.qname.uri); | 3714 xmlStrdup(BAD_CAST val->value.qname.uri); |
3704 break; | 3715 break; |
3705 case XML_SCHEMAS_HEXBINARY: | 3716 case XML_SCHEMAS_HEXBINARY: |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3827 | 3838 |
3828 tempdays += u->day + carry; | 3839 tempdays += u->day + carry; |
3829 | 3840 |
3830 while (1) { | 3841 while (1) { |
3831 if (tempdays < 1) { | 3842 if (tempdays < 1) { |
3832 long tmon = (long) MODULO_RANGE((int)r->mon-1, 1, 13); | 3843 long tmon = (long) MODULO_RANGE((int)r->mon-1, 1, 13); |
3833 long tyr = r->year + (long)FQUOTIENT_RANGE((int)r->mon-1, 1, 13); | 3844 long tyr = r->year + (long)FQUOTIENT_RANGE((int)r->mon-1, 1, 13); |
3834 if (tyr == 0) | 3845 if (tyr == 0) |
3835 tyr--; | 3846 tyr--; |
3836 /* | 3847 /* |
3837 » * Coverity detected an overrun in daysInMonth | 3848 » * Coverity detected an overrun in daysInMonth |
3838 * of size 12 at position 12 with index variable "((r)->mon - 1)" | 3849 * of size 12 at position 12 with index variable "((r)->mon - 1)" |
3839 */ | 3850 */ |
3840 » if (tmon < 0) | 3851 » if (tmon < 1) |
3841 » tmon = 0; | 3852 » tmon = 1; |
3842 if (tmon > 12) | 3853 if (tmon > 12) |
3843 tmon = 12; | 3854 tmon = 12; |
3844 tempdays += MAX_DAYINMONTH(tyr, tmon); | 3855 tempdays += MAX_DAYINMONTH(tyr, tmon); |
3845 carry = -1; | 3856 carry = -1; |
3846 } else if (tempdays > (long) MAX_DAYINMONTH(r->year, r->mon)) { | 3857 } else if (VALID_YEAR(r->year) && VALID_MONTH(r->mon) && |
| 3858 tempdays > (long) MAX_DAYINMONTH(r->year, r->mon)) { |
3847 tempdays = tempdays - MAX_DAYINMONTH(r->year, r->mon); | 3859 tempdays = tempdays - MAX_DAYINMONTH(r->year, r->mon); |
3848 carry = 1; | 3860 carry = 1; |
3849 } else | 3861 } else |
3850 break; | 3862 break; |
3851 | 3863 |
3852 temp = r->mon + carry; | 3864 temp = r->mon + carry; |
3853 r->mon = (unsigned int) MODULO_RANGE(temp, 1, 13); | 3865 r->mon = (unsigned int) MODULO_RANGE(temp, 1, 13); |
3854 r->year = r->year + (unsigned int) FQUOTIENT_RANGE(temp, 1, 13); | 3866 r->year = r->year + (unsigned int) FQUOTIENT_RANGE(temp, 1, 13); |
3855 if (r->year == 0) { | 3867 if (r->year == 0) { |
3856 if (temp < 1) | 3868 if (temp < 1) |
3857 r->year--; | 3869 r->year--; |
3858 else | 3870 else |
3859 r->year++; | 3871 r->year++; |
3860 } | 3872 } |
3861 } | 3873 } |
3862 | 3874 |
3863 r->day = tempdays; | 3875 r->day = tempdays; |
3864 | 3876 |
3865 /* | 3877 /* |
3866 * adjust the date/time type to the date values | 3878 * adjust the date/time type to the date values |
3867 */ | 3879 */ |
3868 if (ret->type != XML_SCHEMAS_DATETIME) { | 3880 if (ret->type != XML_SCHEMAS_DATETIME) { |
3869 if ((r->hour) || (r->min) || (r->sec)) | 3881 if ((r->hour) || (r->min) || (r->sec)) |
3870 ret->type = XML_SCHEMAS_DATETIME; | 3882 ret->type = XML_SCHEMAS_DATETIME; |
3871 else if (ret->type != XML_SCHEMAS_DATE) { | 3883 else if (ret->type != XML_SCHEMAS_DATE) { |
3872 if ((r->mon != 1) && (r->day != 1)) | 3884 if ((r->mon != 1) && (r->day != 1)) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3917 xmlSchemaFreeValue(dur); | 3929 xmlSchemaFreeValue(dur); |
3918 | 3930 |
3919 /* ret->value.date.tzo = 0; */ | 3931 /* ret->value.date.tzo = 0; */ |
3920 return ret; | 3932 return ret; |
3921 } | 3933 } |
3922 | 3934 |
3923 /** | 3935 /** |
3924 * _xmlSchemaDateCastYMToDays: | 3936 * _xmlSchemaDateCastYMToDays: |
3925 * @dt: an #xmlSchemaValPtr | 3937 * @dt: an #xmlSchemaValPtr |
3926 * | 3938 * |
3927 * Convert mon and year of @dt to total number of days. Take the | 3939 * Convert mon and year of @dt to total number of days. Take the |
3928 * number of years since (or before) 1 AD and add the number of leap | 3940 * number of years since (or before) 1 AD and add the number of leap |
3929 * years. This is a function because negative | 3941 * years. This is a function because negative |
3930 * years must be handled a little differently and there is no zero year. | 3942 * years must be handled a little differently and there is no zero year. |
3931 * | 3943 * |
3932 * Returns number of days. | 3944 * Returns number of days. |
3933 */ | 3945 */ |
3934 static long | 3946 static long |
3935 _xmlSchemaDateCastYMToDays (const xmlSchemaValPtr dt) | 3947 _xmlSchemaDateCastYMToDays (const xmlSchemaValPtr dt) |
3936 { | 3948 { |
3937 long ret; | 3949 long ret; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4097 } else if (p1d > q1d) { | 4109 } else if (p1d > q1d) { |
4098 ret = 1; | 4110 ret = 1; |
4099 } else { | 4111 } else { |
4100 double sec; | 4112 double sec; |
4101 | 4113 |
4102 sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q1); | 4114 sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q1); |
4103 if (sec < 0.0) | 4115 if (sec < 0.0) |
4104 ret = -1; | 4116 ret = -1; |
4105 else if (sec > 0.0) | 4117 else if (sec > 0.0) |
4106 ret = 1; | 4118 ret = 1; |
4107 | 4119 |
4108 } | 4120 } |
4109 xmlSchemaFreeValue(p1); | 4121 xmlSchemaFreeValue(p1); |
4110 xmlSchemaFreeValue(q1); | 4122 xmlSchemaFreeValue(q1); |
4111 return(ret); | 4123 return(ret); |
4112 } | 4124 } |
4113 | 4125 |
4114 switch (x->type) { | 4126 switch (x->type) { |
4115 case XML_SCHEMAS_DATETIME: | 4127 case XML_SCHEMAS_DATETIME: |
4116 xmask = 0xf; | 4128 xmask = 0xf; |
4117 break; | 4129 break; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4238 * | 4250 * |
4239 * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in | 4251 * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in |
4240 * case of error | 4252 * case of error |
4241 */ | 4253 */ |
4242 static int | 4254 static int |
4243 xmlSchemaComparePreserveReplaceStrings(const xmlChar *x, | 4255 xmlSchemaComparePreserveReplaceStrings(const xmlChar *x, |
4244 const xmlChar *y, | 4256 const xmlChar *y, |
4245 int invert) | 4257 int invert) |
4246 { | 4258 { |
4247 int tmp; | 4259 int tmp; |
4248 | 4260 |
4249 while ((*x != 0) && (*y != 0)) { | 4261 while ((*x != 0) && (*y != 0)) { |
4250 if (IS_WSP_REPLACE_CH(*y)) { | 4262 if (IS_WSP_REPLACE_CH(*y)) { |
4251 if (! IS_WSP_SPACE_CH(*x)) { | 4263 if (! IS_WSP_SPACE_CH(*x)) { |
4252 if ((*x - 0x20) < 0) { | 4264 if ((*x - 0x20) < 0) { |
4253 if (invert) | 4265 if (invert) |
4254 return(1); | 4266 return(1); |
4255 else | 4267 else |
4256 return(-1); | 4268 return(-1); |
4257 } else { | 4269 } else { |
4258 if (invert) | 4270 if (invert) |
4259 return(-1); | 4271 return(-1); |
4260 else | 4272 else |
4261 return(1); | 4273 return(1); |
4262 } | 4274 } |
4263 » }» | 4275 » } |
4264 } else { | 4276 } else { |
4265 tmp = *x - *y; | 4277 tmp = *x - *y; |
4266 if (tmp < 0) { | 4278 if (tmp < 0) { |
4267 if (invert) | 4279 if (invert) |
4268 return(1); | 4280 return(1); |
4269 else | 4281 else |
4270 return(-1); | 4282 return(-1); |
4271 } | 4283 } |
4272 if (tmp > 0) { | 4284 if (tmp > 0) { |
4273 if (invert) | 4285 if (invert) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4307 * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in | 4319 * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in |
4308 * case of error | 4320 * case of error |
4309 */ | 4321 */ |
4310 static int | 4322 static int |
4311 xmlSchemaComparePreserveCollapseStrings(const xmlChar *x, | 4323 xmlSchemaComparePreserveCollapseStrings(const xmlChar *x, |
4312 const xmlChar *y, | 4324 const xmlChar *y, |
4313 int invert) | 4325 int invert) |
4314 { | 4326 { |
4315 int tmp; | 4327 int tmp; |
4316 | 4328 |
4317 /* | 4329 /* |
4318 * Skip leading blank chars of the collapsed string. | 4330 * Skip leading blank chars of the collapsed string. |
4319 */ | 4331 */ |
4320 while IS_WSP_BLANK_CH(*y) | 4332 while IS_WSP_BLANK_CH(*y) |
4321 y++; | 4333 y++; |
4322 | 4334 |
4323 while ((*x != 0) && (*y != 0)) { | 4335 while ((*x != 0) && (*y != 0)) { |
4324 if IS_WSP_BLANK_CH(*y) { | 4336 if IS_WSP_BLANK_CH(*y) { |
4325 if (! IS_WSP_SPACE_CH(*x)) { | 4337 if (! IS_WSP_SPACE_CH(*x)) { |
4326 /* | 4338 /* |
4327 * The yv character would have been replaced to 0x20. | 4339 * The yv character would have been replaced to 0x20. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4396 * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in | 4408 * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in |
4397 * case of error | 4409 * case of error |
4398 */ | 4410 */ |
4399 static int | 4411 static int |
4400 xmlSchemaCompareReplaceCollapseStrings(const xmlChar *x, | 4412 xmlSchemaCompareReplaceCollapseStrings(const xmlChar *x, |
4401 const xmlChar *y, | 4413 const xmlChar *y, |
4402 int invert) | 4414 int invert) |
4403 { | 4415 { |
4404 int tmp; | 4416 int tmp; |
4405 | 4417 |
4406 /* | 4418 /* |
4407 * Skip leading blank chars of the collapsed string. | 4419 * Skip leading blank chars of the collapsed string. |
4408 */ | 4420 */ |
4409 while IS_WSP_BLANK_CH(*y) | 4421 while IS_WSP_BLANK_CH(*y) |
4410 y++; | 4422 y++; |
4411 | 4423 |
4412 while ((*x != 0) && (*y != 0)) { | 4424 while ((*x != 0) && (*y != 0)) { |
4413 if IS_WSP_BLANK_CH(*y) { | 4425 if IS_WSP_BLANK_CH(*y) { |
4414 if (! IS_WSP_BLANK_CH(*x)) { | 4426 if (! IS_WSP_BLANK_CH(*x)) { |
4415 /* | 4427 /* |
4416 * The yv character would have been replaced to 0x20. | 4428 * The yv character would have been replaced to 0x20. |
4417 */ | 4429 */ |
4418 if ((*x - 0x20) < 0) { | 4430 if ((*x - 0x20) < 0) { |
4419 if (invert) | 4431 if (invert) |
4420 return(1); | 4432 return(1); |
4421 else | 4433 else |
4422 return(-1); | 4434 return(-1); |
4423 } else { | 4435 } else { |
4424 if (invert) | 4436 if (invert) |
4425 return(-1); | 4437 return(-1); |
4426 else | 4438 else |
4427 return(1); | 4439 return(1); |
4428 } | 4440 } |
4429 } | 4441 } |
4430 x++; | 4442 x++; |
4431 » y++;» | 4443 » y++; |
4432 » /* | 4444 » /* |
4433 * Skip contiguous blank chars of the collapsed string. | 4445 * Skip contiguous blank chars of the collapsed string. |
4434 */ | 4446 */ |
4435 while IS_WSP_BLANK_CH(*y) | 4447 while IS_WSP_BLANK_CH(*y) |
4436 y++; | 4448 y++; |
4437 } else { | 4449 } else { |
4438 if IS_WSP_BLANK_CH(*x) { | 4450 if IS_WSP_BLANK_CH(*x) { |
4439 /* | 4451 /* |
4440 * The xv character would have been replaced to 0x20. | 4452 * The xv character would have been replaced to 0x20. |
4441 */ | 4453 */ |
4442 if ((0x20 - *y) < 0) { | 4454 if ((0x20 - *y) < 0) { |
(...skipping 13 matching lines...) Expand all Loading... |
4456 return(-1); | 4468 return(-1); |
4457 if (tmp > 0) | 4469 if (tmp > 0) |
4458 return(1); | 4470 return(1); |
4459 } | 4471 } |
4460 } | 4472 } |
4461 if (*x != 0) { | 4473 if (*x != 0) { |
4462 if (invert) | 4474 if (invert) |
4463 return(-1); | 4475 return(-1); |
4464 else | 4476 else |
4465 return(1); | 4477 return(1); |
4466 } | 4478 } |
4467 if (*y != 0) { | 4479 if (*y != 0) { |
4468 /* | 4480 /* |
4469 * Skip trailing blank chars of the collapsed string. | 4481 * Skip trailing blank chars of the collapsed string. |
4470 */ | 4482 */ |
4471 while IS_WSP_BLANK_CH(*y) | 4483 while IS_WSP_BLANK_CH(*y) |
4472 y++; | 4484 y++; |
4473 if (*y != 0) { | 4485 if (*y != 0) { |
4474 if (invert) | 4486 if (invert) |
4475 return(1); | 4487 return(1); |
4476 else | 4488 else |
(...skipping 12 matching lines...) Expand all Loading... |
4489 * Compare 2 string for their normalized values. | 4501 * Compare 2 string for their normalized values. |
4490 * | 4502 * |
4491 * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in | 4503 * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in |
4492 * case of error | 4504 * case of error |
4493 */ | 4505 */ |
4494 static int | 4506 static int |
4495 xmlSchemaCompareReplacedStrings(const xmlChar *x, | 4507 xmlSchemaCompareReplacedStrings(const xmlChar *x, |
4496 const xmlChar *y) | 4508 const xmlChar *y) |
4497 { | 4509 { |
4498 int tmp; | 4510 int tmp; |
4499 | 4511 |
4500 while ((*x != 0) && (*y != 0)) { | 4512 while ((*x != 0) && (*y != 0)) { |
4501 if IS_WSP_BLANK_CH(*y) { | 4513 if IS_WSP_BLANK_CH(*y) { |
4502 if (! IS_WSP_BLANK_CH(*x)) { | 4514 if (! IS_WSP_BLANK_CH(*x)) { |
4503 if ((*x - 0x20) < 0) | 4515 if ((*x - 0x20) < 0) |
4504 » » return(-1); | 4516 » » return(-1); |
4505 else | 4517 else |
4506 return(1); | 4518 return(1); |
4507 » }» | 4519 » } |
4508 } else { | 4520 } else { |
4509 if IS_WSP_BLANK_CH(*x) { | 4521 if IS_WSP_BLANK_CH(*x) { |
4510 if ((0x20 - *y) < 0) | 4522 if ((0x20 - *y) < 0) |
4511 » » return(-1); | 4523 » » return(-1); |
4512 else | 4524 else |
4513 return(1); | 4525 return(1); |
4514 } | 4526 } |
4515 tmp = *x - *y; | 4527 tmp = *x - *y; |
4516 if (tmp < 0) | 4528 if (tmp < 0) |
4517 » » return(-1); | 4529 » » return(-1); |
4518 if (tmp > 0) | 4530 if (tmp > 0) |
4519 » » return(1); | 4531 » » return(1); |
4520 } | 4532 } |
4521 x++; | 4533 x++; |
4522 y++; | 4534 y++; |
4523 } | 4535 } |
4524 if (*x != 0) | 4536 if (*x != 0) |
4525 return(1); | 4537 return(1); |
4526 if (*y != 0) | 4538 if (*y != 0) |
4527 return(-1); | 4539 return(-1); |
4528 return(0); | 4540 return(0); |
4529 } | 4541 } |
4530 | 4542 |
4531 /** | 4543 /** |
4532 * xmlSchemaCompareNormStrings: | 4544 * xmlSchemaCompareNormStrings: |
4533 * @x: a first string value | 4545 * @x: a first string value |
4534 * @y: a second string value | 4546 * @y: a second string value |
4535 * | 4547 * |
4536 * Compare 2 string for their normalized values. | 4548 * Compare 2 string for their normalized values. |
4537 * | 4549 * |
4538 * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in | 4550 * Returns -1 if x < y, 0 if x == y, 1 if x > y, and -2 in |
4539 * case of error | 4551 * case of error |
4540 */ | 4552 */ |
4541 static int | 4553 static int |
4542 xmlSchemaCompareNormStrings(const xmlChar *x, | 4554 xmlSchemaCompareNormStrings(const xmlChar *x, |
4543 const xmlChar *y) { | 4555 const xmlChar *y) { |
4544 int tmp; | 4556 int tmp; |
4545 | 4557 |
4546 while (IS_BLANK_CH(*x)) x++; | 4558 while (IS_BLANK_CH(*x)) x++; |
4547 while (IS_BLANK_CH(*y)) y++; | 4559 while (IS_BLANK_CH(*y)) y++; |
4548 while ((*x != 0) && (*y != 0)) { | 4560 while ((*x != 0) && (*y != 0)) { |
4549 if (IS_BLANK_CH(*x)) { | 4561 if (IS_BLANK_CH(*x)) { |
4550 if (!IS_BLANK_CH(*y)) { | 4562 if (!IS_BLANK_CH(*y)) { |
4551 tmp = *x - *y; | 4563 tmp = *x - *y; |
4552 return(tmp); | 4564 return(tmp); |
4553 } | 4565 } |
4554 while (IS_BLANK_CH(*x)) x++; | 4566 while (IS_BLANK_CH(*x)) x++; |
4555 while (IS_BLANK_CH(*y)) y++; | 4567 while (IS_BLANK_CH(*y)) y++; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4728 if ((ytype == XML_SCHEMAS_DATETIME) || | 4740 if ((ytype == XML_SCHEMAS_DATETIME) || |
4729 (ytype == XML_SCHEMAS_TIME) || | 4741 (ytype == XML_SCHEMAS_TIME) || |
4730 (ytype == XML_SCHEMAS_GDAY) || | 4742 (ytype == XML_SCHEMAS_GDAY) || |
4731 (ytype == XML_SCHEMAS_GMONTH) || | 4743 (ytype == XML_SCHEMAS_GMONTH) || |
4732 (ytype == XML_SCHEMAS_GMONTHDAY) || | 4744 (ytype == XML_SCHEMAS_GMONTHDAY) || |
4733 (ytype == XML_SCHEMAS_GYEAR) || | 4745 (ytype == XML_SCHEMAS_GYEAR) || |
4734 (ytype == XML_SCHEMAS_DATE) || | 4746 (ytype == XML_SCHEMAS_DATE) || |
4735 (ytype == XML_SCHEMAS_GYEARMONTH)) | 4747 (ytype == XML_SCHEMAS_GYEARMONTH)) |
4736 return (xmlSchemaCompareDates(x, y)); | 4748 return (xmlSchemaCompareDates(x, y)); |
4737 return (-2); | 4749 return (-2); |
4738 » /* | 4750 » /* |
4739 * Note that we will support comparison of string types against | 4751 * Note that we will support comparison of string types against |
4740 * anySimpleType as well. | 4752 * anySimpleType as well. |
4741 */ | 4753 */ |
4742 case XML_SCHEMAS_ANYSIMPLETYPE: | 4754 case XML_SCHEMAS_ANYSIMPLETYPE: |
4743 case XML_SCHEMAS_STRING: | 4755 case XML_SCHEMAS_STRING: |
4744 case XML_SCHEMAS_NORMSTRING:» » | 4756 case XML_SCHEMAS_NORMSTRING: |
4745 case XML_SCHEMAS_TOKEN: | 4757 case XML_SCHEMAS_TOKEN: |
4746 case XML_SCHEMAS_LANGUAGE: | 4758 case XML_SCHEMAS_LANGUAGE: |
4747 case XML_SCHEMAS_NMTOKEN: | 4759 case XML_SCHEMAS_NMTOKEN: |
4748 case XML_SCHEMAS_NAME: | 4760 case XML_SCHEMAS_NAME: |
4749 case XML_SCHEMAS_NCNAME: | 4761 case XML_SCHEMAS_NCNAME: |
4750 case XML_SCHEMAS_ID: | 4762 case XML_SCHEMAS_ID: |
4751 case XML_SCHEMAS_IDREF: | 4763 case XML_SCHEMAS_IDREF: |
4752 case XML_SCHEMAS_ENTITY: | 4764 case XML_SCHEMAS_ENTITY: |
4753 case XML_SCHEMAS_ANYURI: | 4765 case XML_SCHEMAS_ANYURI: |
4754 { | 4766 { |
4755 const xmlChar *xv, *yv; | 4767 const xmlChar *xv, *yv; |
4756 | 4768 |
4757 if (x == NULL) | 4769 if (x == NULL) |
4758 xv = xvalue; | 4770 xv = xvalue; |
4759 else | 4771 else |
4760 xv = x->value.str; | 4772 xv = x->value.str; |
4761 if (y == NULL) | 4773 if (y == NULL) |
4762 yv = yvalue; | 4774 yv = yvalue; |
4763 else | 4775 else |
4764 yv = y->value.str; | 4776 yv = y->value.str; |
4765 /* | 4777 /* |
4766 * TODO: Compare those against QName. | 4778 * TODO: Compare those against QName. |
4767 */ | 4779 */ |
4768 » if (ytype == XML_SCHEMAS_QNAME) {» » | 4780 » if (ytype == XML_SCHEMAS_QNAME) { |
4769 TODO | 4781 TODO |
4770 if (y == NULL) | 4782 if (y == NULL) |
4771 » » return(-2); | 4783 » » return(-2); |
4772 return (-2); | 4784 return (-2); |
4773 } | 4785 } |
4774 if ((ytype == XML_SCHEMAS_ANYSIMPLETYPE) || | 4786 if ((ytype == XML_SCHEMAS_ANYSIMPLETYPE) || |
4775 (ytype == XML_SCHEMAS_STRING) || | 4787 (ytype == XML_SCHEMAS_STRING) || |
4776 (ytype == XML_SCHEMAS_NORMSTRING) || | 4788 (ytype == XML_SCHEMAS_NORMSTRING) || |
4777 (ytype == XML_SCHEMAS_TOKEN) || | 4789 (ytype == XML_SCHEMAS_TOKEN) || |
4778 (ytype == XML_SCHEMAS_LANGUAGE) || | 4790 (ytype == XML_SCHEMAS_LANGUAGE) || |
4779 (ytype == XML_SCHEMAS_NMTOKEN) || | 4791 (ytype == XML_SCHEMAS_NMTOKEN) || |
4780 (ytype == XML_SCHEMAS_NAME) || | 4792 (ytype == XML_SCHEMAS_NAME) || |
4781 (ytype == XML_SCHEMAS_NCNAME) || | 4793 (ytype == XML_SCHEMAS_NCNAME) || |
4782 (ytype == XML_SCHEMAS_ID) || | 4794 (ytype == XML_SCHEMAS_ID) || |
4783 (ytype == XML_SCHEMAS_IDREF) || | 4795 (ytype == XML_SCHEMAS_IDREF) || |
4784 (ytype == XML_SCHEMAS_ENTITY) || | 4796 (ytype == XML_SCHEMAS_ENTITY) || |
4785 (ytype == XML_SCHEMAS_ANYURI)) { | 4797 (ytype == XML_SCHEMAS_ANYURI)) { |
4786 | 4798 |
4787 if (xws == XML_SCHEMA_WHITESPACE_PRESERVE) { | 4799 if (xws == XML_SCHEMA_WHITESPACE_PRESERVE) { |
4788 | 4800 |
4789 if (yws == XML_SCHEMA_WHITESPACE_PRESERVE) { | 4801 if (yws == XML_SCHEMA_WHITESPACE_PRESERVE) { |
4790 /* TODO: What about x < y or x > y. */ | 4802 /* TODO: What about x < y or x > y. */ |
4791 if (xmlStrEqual(xv, yv)) | 4803 if (xmlStrEqual(xv, yv)) |
4792 return (0); | 4804 return (0); |
4793 » » » else | 4805 » » » else |
4794 return (2); | 4806 return (2); |
4795 } else if (yws == XML_SCHEMA_WHITESPACE_REPLACE) | 4807 } else if (yws == XML_SCHEMA_WHITESPACE_REPLACE) |
4796 return (xmlSchemaComparePreserveReplaceStrings(xv, yv, 0
)); | 4808 return (xmlSchemaComparePreserveReplaceStrings(xv, yv, 0
)); |
4797 else if (yws == XML_SCHEMA_WHITESPACE_COLLAPSE) | 4809 else if (yws == XML_SCHEMA_WHITESPACE_COLLAPSE) |
4798 return (xmlSchemaComparePreserveCollapseStrings(xv, yv,
0)); | 4810 return (xmlSchemaComparePreserveCollapseStrings(xv, yv,
0)); |
4799 | 4811 |
4800 } else if (xws == XML_SCHEMA_WHITESPACE_REPLACE) { | 4812 } else if (xws == XML_SCHEMA_WHITESPACE_REPLACE) { |
4801 | 4813 |
4802 if (yws == XML_SCHEMA_WHITESPACE_PRESERVE) | 4814 if (yws == XML_SCHEMA_WHITESPACE_PRESERVE) |
4803 return (xmlSchemaComparePreserveReplaceStrings(yv, xv, 1
)); | 4815 return (xmlSchemaComparePreserveReplaceStrings(yv, xv, 1
)); |
4804 if (yws == XML_SCHEMA_WHITESPACE_REPLACE) | 4816 if (yws == XML_SCHEMA_WHITESPACE_REPLACE) |
4805 return (xmlSchemaCompareReplacedStrings(xv, yv)); | 4817 return (xmlSchemaCompareReplacedStrings(xv, yv)); |
4806 if (yws == XML_SCHEMA_WHITESPACE_COLLAPSE) | 4818 if (yws == XML_SCHEMA_WHITESPACE_COLLAPSE) |
4807 return (xmlSchemaCompareReplaceCollapseStrings(xv, yv, 0
)); | 4819 return (xmlSchemaCompareReplaceCollapseStrings(xv, yv, 0
)); |
4808 | 4820 |
4809 } else if (xws == XML_SCHEMA_WHITESPACE_COLLAPSE) { | 4821 } else if (xws == XML_SCHEMA_WHITESPACE_COLLAPSE) { |
4810 | 4822 |
4811 if (yws == XML_SCHEMA_WHITESPACE_PRESERVE) | 4823 if (yws == XML_SCHEMA_WHITESPACE_PRESERVE) |
4812 return (xmlSchemaComparePreserveCollapseStrings(yv, xv,
1)); | 4824 return (xmlSchemaComparePreserveCollapseStrings(yv, xv,
1)); |
4813 if (yws == XML_SCHEMA_WHITESPACE_REPLACE) | 4825 if (yws == XML_SCHEMA_WHITESPACE_REPLACE) |
4814 return (xmlSchemaCompareReplaceCollapseStrings(yv, xv, 1
)); | 4826 return (xmlSchemaCompareReplaceCollapseStrings(yv, xv, 1
)); |
4815 if (yws == XML_SCHEMA_WHITESPACE_COLLAPSE) | 4827 if (yws == XML_SCHEMA_WHITESPACE_COLLAPSE) |
4816 return (xmlSchemaCompareNormStrings(xv, yv)); | 4828 return (xmlSchemaCompareNormStrings(xv, yv)); |
4817 } else | 4829 } else |
4818 return (-2); | 4830 return (-2); |
4819 | 4831 |
4820 } | 4832 } |
4821 return (-2); | 4833 return (-2); |
4822 } | 4834 } |
4823 case XML_SCHEMAS_QNAME: | 4835 case XML_SCHEMAS_QNAME: |
4824 case XML_SCHEMAS_NOTATION: | 4836 case XML_SCHEMAS_NOTATION: |
4825 if ((x == NULL) || (y == NULL)) | 4837 if ((x == NULL) || (y == NULL)) |
4826 return(-2); | 4838 return(-2); |
4827 if ((ytype == XML_SCHEMAS_QNAME) || | 4839 if ((ytype == XML_SCHEMAS_QNAME) || |
4828 (ytype == XML_SCHEMAS_NOTATION)) { | 4840 (ytype == XML_SCHEMAS_NOTATION)) { |
4829 if ((xmlStrEqual(x->value.qname.name, y->value.qname.name)) && | 4841 if ((xmlStrEqual(x->value.qname.name, y->value.qname.name)) && |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4880 else if (ret == 0) | 4892 else if (ret == 0) |
4881 return(0); | 4893 return(0); |
4882 else | 4894 else |
4883 return(-1); | 4895 return(-1); |
4884 } | 4896 } |
4885 else if (x->value.base64.total > y->value.base64.total) | 4897 else if (x->value.base64.total > y->value.base64.total) |
4886 return(1); | 4898 return(1); |
4887 else | 4899 else |
4888 return(-1); | 4900 return(-1); |
4889 } | 4901 } |
4890 return (-2); | 4902 return (-2); |
4891 case XML_SCHEMAS_IDREFS: | 4903 case XML_SCHEMAS_IDREFS: |
4892 case XML_SCHEMAS_ENTITIES: | 4904 case XML_SCHEMAS_ENTITIES: |
4893 case XML_SCHEMAS_NMTOKENS: | 4905 case XML_SCHEMAS_NMTOKENS: |
4894 TODO | 4906 TODO |
4895 break; | 4907 break; |
4896 } | 4908 } |
4897 return -2; | 4909 return -2; |
4898 } | 4910 } |
4899 | 4911 |
4900 /** | 4912 /** |
(...skipping 14 matching lines...) Expand all Loading... |
4915 return(-2); | 4927 return(-2); |
4916 if (x->type == XML_SCHEMAS_STRING) | 4928 if (x->type == XML_SCHEMAS_STRING) |
4917 xws = XML_SCHEMA_WHITESPACE_PRESERVE; | 4929 xws = XML_SCHEMA_WHITESPACE_PRESERVE; |
4918 else if (x->type == XML_SCHEMAS_NORMSTRING) | 4930 else if (x->type == XML_SCHEMAS_NORMSTRING) |
4919 xws = XML_SCHEMA_WHITESPACE_REPLACE; | 4931 xws = XML_SCHEMA_WHITESPACE_REPLACE; |
4920 else | 4932 else |
4921 xws = XML_SCHEMA_WHITESPACE_COLLAPSE; | 4933 xws = XML_SCHEMA_WHITESPACE_COLLAPSE; |
4922 | 4934 |
4923 if (y->type == XML_SCHEMAS_STRING) | 4935 if (y->type == XML_SCHEMAS_STRING) |
4924 yws = XML_SCHEMA_WHITESPACE_PRESERVE; | 4936 yws = XML_SCHEMA_WHITESPACE_PRESERVE; |
4925 else if (x->type == XML_SCHEMAS_NORMSTRING) | 4937 else if (y->type == XML_SCHEMAS_NORMSTRING) |
4926 yws = XML_SCHEMA_WHITESPACE_REPLACE; | 4938 yws = XML_SCHEMA_WHITESPACE_REPLACE; |
4927 else | 4939 else |
4928 yws = XML_SCHEMA_WHITESPACE_COLLAPSE; | 4940 yws = XML_SCHEMA_WHITESPACE_COLLAPSE; |
4929 | 4941 |
4930 return(xmlSchemaCompareValuesInternal(x->type, x, NULL, xws, y->type, | 4942 return(xmlSchemaCompareValuesInternal(x->type, x, NULL, xws, y->type, |
4931 y, NULL, yws)); | 4943 y, NULL, yws)); |
4932 } | 4944 } |
4933 | 4945 |
4934 /** | 4946 /** |
4935 * xmlSchemaCompareValuesWhtsp: | 4947 * xmlSchemaCompareValuesWhtsp: |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5068 return(-1); | 5080 return(-1); |
5069 /* | 5081 /* |
5070 * TODO: Check if this will work with large numbers. | 5082 * TODO: Check if this will work with large numbers. |
5071 * (compare value.decimal.mi and value.decimal.hi as well?). | 5083 * (compare value.decimal.mi and value.decimal.hi as well?). |
5072 */ | 5084 */ |
5073 if (facet->type == XML_SCHEMA_FACET_LENGTH) { | 5085 if (facet->type == XML_SCHEMA_FACET_LENGTH) { |
5074 if (actualLen != facet->val->value.decimal.lo) { | 5086 if (actualLen != facet->val->value.decimal.lo) { |
5075 if (expectedLen != NULL) | 5087 if (expectedLen != NULL) |
5076 *expectedLen = facet->val->value.decimal.lo; | 5088 *expectedLen = facet->val->value.decimal.lo; |
5077 return (XML_SCHEMAV_CVC_LENGTH_VALID); | 5089 return (XML_SCHEMAV_CVC_LENGTH_VALID); |
5078 » }» | 5090 » } |
5079 } else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) { | 5091 } else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) { |
5080 if (actualLen < facet->val->value.decimal.lo) { | 5092 if (actualLen < facet->val->value.decimal.lo) { |
5081 if (expectedLen != NULL) | 5093 if (expectedLen != NULL) |
5082 *expectedLen = facet->val->value.decimal.lo; | 5094 *expectedLen = facet->val->value.decimal.lo; |
5083 return (XML_SCHEMAV_CVC_MINLENGTH_VALID); | 5095 return (XML_SCHEMAV_CVC_MINLENGTH_VALID); |
5084 } | 5096 } |
5085 } else if (facet->type == XML_SCHEMA_FACET_MAXLENGTH) { | 5097 } else if (facet->type == XML_SCHEMA_FACET_MAXLENGTH) { |
5086 if (actualLen > facet->val->value.decimal.lo) { | 5098 if (actualLen > facet->val->value.decimal.lo) { |
5087 if (expectedLen != NULL) | 5099 if (expectedLen != NULL) |
5088 *expectedLen = facet->val->value.decimal.lo; | 5100 *expectedLen = facet->val->value.decimal.lo; |
5089 return (XML_SCHEMAV_CVC_MAXLENGTH_VALID); | 5101 return (XML_SCHEMAV_CVC_MAXLENGTH_VALID); |
5090 } | 5102 } |
5091 } else | 5103 } else |
5092 » /* | 5104 » /* |
5093 » * NOTE: That we can pass NULL as xmlSchemaValPtr to | 5105 » * NOTE: That we can pass NULL as xmlSchemaValPtr to |
5094 * xmlSchemaValidateFacet, since the remaining facet types | 5106 * xmlSchemaValidateFacet, since the remaining facet types |
5095 » * are: XML_SCHEMA_FACET_PATTERN, XML_SCHEMA_FACET_ENUMERATION. | 5107 » * are: XML_SCHEMA_FACET_PATTERN, XML_SCHEMA_FACET_ENUMERATION. |
5096 */ | 5108 */ |
5097 » return(xmlSchemaValidateFacet(NULL, facet, value, NULL)); | 5109 » return(xmlSchemaValidateFacet(NULL, facet, value, NULL)); |
5098 return (0); | 5110 return (0); |
5099 } | 5111 } |
5100 | 5112 |
5101 /** | 5113 /** |
5102 * xmlSchemaValidateLengthFacet: | 5114 * xmlSchemaValidateLengthFacet: |
5103 * @type: the built-in type | 5115 * @type: the built-in type |
5104 * @facet: the facet to check | 5116 * @facet: the facet to check |
5105 * @value: the lexical repr. of the value to be validated | 5117 * @value: the lexical repr. of the value to be validated |
5106 * @val: the precomputed value | 5118 * @val: the precomputed value |
5107 * @ws: the whitespace type of the value | 5119 * @ws: the whitespace type of the value |
5108 * @length: the actual length of the value | 5120 * @length: the actual length of the value |
5109 * | 5121 * |
5110 * Checka a value against a "length", "minLength" and "maxLength" | 5122 * Checka a value against a "length", "minLength" and "maxLength" |
5111 * facet; sets @length to the computed length of @value. | 5123 * facet; sets @length to the computed length of @value. |
5112 * | 5124 * |
5113 * Returns 0 if the value is valid, a positive error code | 5125 * Returns 0 if the value is valid, a positive error code |
5114 * otherwise and -1 in case of an internal or API error. | 5126 * otherwise and -1 in case of an internal or API error. |
5115 */ | 5127 */ |
5116 static int | 5128 static int |
5117 xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet, | 5129 xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet, |
5118 xmlSchemaValType valType, | 5130 xmlSchemaValType valType, |
5119 const xmlChar *value, | 5131 const xmlChar *value, |
5120 xmlSchemaValPtr val, | 5132 xmlSchemaValPtr val, |
5121 unsigned long *length, | 5133 unsigned long *length, |
5122 » » » » xmlSchemaWhitespaceValueType ws) | 5134 » » » » xmlSchemaWhitespaceValueType ws) |
5123 { | 5135 { |
5124 unsigned int len = 0; | 5136 unsigned int len = 0; |
5125 | 5137 |
5126 if ((length == NULL) || (facet == NULL)) | 5138 if ((length == NULL) || (facet == NULL)) |
5127 return (-1); | 5139 return (-1); |
5128 *length = 0; | 5140 *length = 0; |
5129 if ((facet->type != XML_SCHEMA_FACET_LENGTH) && | 5141 if ((facet->type != XML_SCHEMA_FACET_LENGTH) && |
5130 (facet->type != XML_SCHEMA_FACET_MAXLENGTH) && | 5142 (facet->type != XML_SCHEMA_FACET_MAXLENGTH) && |
5131 (facet->type != XML_SCHEMA_FACET_MINLENGTH)) | 5143 (facet->type != XML_SCHEMA_FACET_MINLENGTH)) |
5132 return (-1); | 5144 return (-1); |
5133 » | 5145 |
5134 /* | 5146 /* |
5135 * TODO: length, maxLength and minLength must be of type | 5147 * TODO: length, maxLength and minLength must be of type |
5136 * nonNegativeInteger only. Check if decimal is used somehow. | 5148 * nonNegativeInteger only. Check if decimal is used somehow. |
5137 */ | 5149 */ |
5138 if ((facet->val == NULL) || | 5150 if ((facet->val == NULL) || |
5139 ((facet->val->type != XML_SCHEMAS_DECIMAL) && | 5151 ((facet->val->type != XML_SCHEMAS_DECIMAL) && |
5140 (facet->val->type != XML_SCHEMAS_NNINTEGER)) || | 5152 (facet->val->type != XML_SCHEMAS_NNINTEGER)) || |
5141 (facet->val->value.decimal.frac != 0)) { | 5153 (facet->val->value.decimal.frac != 0)) { |
5142 return(-1); | 5154 return(-1); |
5143 } | 5155 } |
(...skipping 13 matching lines...) Expand all Loading... |
5157 * TODO: Get rid of this case somehow. | 5169 * TODO: Get rid of this case somehow. |
5158 */ | 5170 */ |
5159 if (valType == XML_SCHEMAS_STRING) | 5171 if (valType == XML_SCHEMAS_STRING) |
5160 len = xmlUTF8Strlen(value); | 5172 len = xmlUTF8Strlen(value); |
5161 else | 5173 else |
5162 len = xmlSchemaNormLen(value); | 5174 len = xmlSchemaNormLen(value); |
5163 } else if (value != NULL) { | 5175 } else if (value != NULL) { |
5164 if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) | 5176 if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) |
5165 len = xmlSchemaNormLen(value); | 5177 len = xmlSchemaNormLen(value); |
5166 else | 5178 else |
5167 » » /* | 5179 » » /* |
5168 * Should be OK for "preserve" as well. | 5180 * Should be OK for "preserve" as well. |
5169 */ | 5181 */ |
5170 len = xmlUTF8Strlen(value); | 5182 len = xmlUTF8Strlen(value); |
5171 } | 5183 } |
5172 break; | 5184 break; |
5173 case XML_SCHEMAS_IDREF: | 5185 case XML_SCHEMAS_IDREF: |
5174 case XML_SCHEMAS_TOKEN: | 5186 case XML_SCHEMAS_TOKEN: |
5175 case XML_SCHEMAS_LANGUAGE: | 5187 case XML_SCHEMAS_LANGUAGE: |
5176 case XML_SCHEMAS_NMTOKEN: | 5188 case XML_SCHEMAS_NMTOKEN: |
5177 case XML_SCHEMAS_NAME: | 5189 case XML_SCHEMAS_NAME: |
5178 case XML_SCHEMAS_NCNAME: | 5190 case XML_SCHEMAS_NCNAME: |
5179 » case XML_SCHEMAS_ID:» » | 5191 » case XML_SCHEMAS_ID: |
5180 /* | 5192 /* |
5181 * FIXME: What exactly to do with anyURI? | 5193 * FIXME: What exactly to do with anyURI? |
5182 */ | 5194 */ |
5183 case XML_SCHEMAS_ANYURI: | 5195 case XML_SCHEMAS_ANYURI: |
5184 if (value != NULL) | 5196 if (value != NULL) |
5185 len = xmlSchemaNormLen(value); | 5197 len = xmlSchemaNormLen(value); |
5186 break; | 5198 break; |
5187 case XML_SCHEMAS_QNAME: | 5199 case XML_SCHEMAS_QNAME: |
5188 » case XML_SCHEMAS_NOTATION: | 5200 » case XML_SCHEMAS_NOTATION: |
5189 » » /* | 5201 » » /* |
5190 * For QName and NOTATION, those facets are | 5202 * For QName and NOTATION, those facets are |
5191 * deprecated and should be ignored. | 5203 * deprecated and should be ignored. |
5192 » » */ | 5204 » » */ |
5193 return (0); | 5205 return (0); |
5194 default: | 5206 default: |
5195 TODO | 5207 TODO |
5196 } | 5208 } |
5197 } | 5209 } |
5198 *length = (unsigned long) len; | 5210 *length = (unsigned long) len; |
5199 /* | 5211 /* |
5200 * TODO: Return the whole expected value, i.e. "lo", "mi" and "hi". | 5212 * TODO: Return the whole expected value, i.e. "lo", "mi" and "hi". |
5201 */ | 5213 */ |
5202 if (facet->type == XML_SCHEMA_FACET_LENGTH) { | 5214 if (facet->type == XML_SCHEMA_FACET_LENGTH) { |
5203 if (len != facet->val->value.decimal.lo) | 5215 if (len != facet->val->value.decimal.lo) |
5204 return(XML_SCHEMAV_CVC_LENGTH_VALID); | 5216 return(XML_SCHEMAV_CVC_LENGTH_VALID); |
5205 } else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) { | 5217 } else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) { |
5206 if (len < facet->val->value.decimal.lo) | 5218 if (len < facet->val->value.decimal.lo) |
5207 return(XML_SCHEMAV_CVC_MINLENGTH_VALID); | 5219 return(XML_SCHEMAV_CVC_MINLENGTH_VALID); |
5208 } else { | 5220 } else { |
5209 if (len > facet->val->value.decimal.lo) | 5221 if (len > facet->val->value.decimal.lo) |
5210 return(XML_SCHEMAV_CVC_MAXLENGTH_VALID); | 5222 return(XML_SCHEMAV_CVC_MAXLENGTH_VALID); |
5211 } | 5223 } |
5212 | 5224 |
5213 return (0); | 5225 return (0); |
5214 } | 5226 } |
5215 | 5227 |
5216 /** | 5228 /** |
5217 * xmlSchemaValidateLengthFacet: | 5229 * xmlSchemaValidateLengthFacet: |
5218 * @type: the built-in type | 5230 * @type: the built-in type |
5219 * @facet: the facet to check | 5231 * @facet: the facet to check |
5220 * @value: the lexical repr. of the value to be validated | 5232 * @value: the lexical repr. of the value to be validated |
5221 * @val: the precomputed value | 5233 * @val: the precomputed value |
5222 * @length: the actual length of the value | 5234 * @length: the actual length of the value |
5223 * | 5235 * |
5224 * Checka a value against a "length", "minLength" and "maxLength" | 5236 * Checka a value against a "length", "minLength" and "maxLength" |
5225 * facet; sets @length to the computed length of @value. | 5237 * facet; sets @length to the computed length of @value. |
5226 * | 5238 * |
5227 * Returns 0 if the value is valid, a positive error code | 5239 * Returns 0 if the value is valid, a positive error code |
5228 * otherwise and -1 in case of an internal or API error. | 5240 * otherwise and -1 in case of an internal or API error. |
5229 */ | 5241 */ |
5230 int | 5242 int |
5231 xmlSchemaValidateLengthFacet(xmlSchemaTypePtr type, | 5243 xmlSchemaValidateLengthFacet(xmlSchemaTypePtr type, |
5232 xmlSchemaFacetPtr facet, | 5244 xmlSchemaFacetPtr facet, |
5233 const xmlChar *value, | 5245 const xmlChar *value, |
5234 xmlSchemaValPtr val, | 5246 xmlSchemaValPtr val, |
5235 » » » unsigned long *length) | 5247 » » » unsigned long *length) |
5236 { | 5248 { |
5237 if (type == NULL) | 5249 if (type == NULL) |
5238 return(-1); | 5250 return(-1); |
5239 return (xmlSchemaValidateLengthFacetInternal(facet, | 5251 return (xmlSchemaValidateLengthFacetInternal(facet, |
5240 type->builtInType, value, val, length, | 5252 type->builtInType, value, val, length, |
5241 XML_SCHEMA_WHITESPACE_UNKNOWN)); | 5253 XML_SCHEMA_WHITESPACE_UNKNOWN)); |
5242 } | 5254 } |
5243 | 5255 |
5244 /** | 5256 /** |
5245 * xmlSchemaValidateLengthFacetWhtsp: | 5257 * xmlSchemaValidateLengthFacetWhtsp: |
5246 * @facet: the facet to check | 5258 * @facet: the facet to check |
5247 * @valType: the built-in type | 5259 * @valType: the built-in type |
5248 * @value: the lexical repr. of the value to be validated | 5260 * @value: the lexical repr. of the value to be validated |
5249 * @val: the precomputed value | 5261 * @val: the precomputed value |
5250 * @ws: the whitespace type of the value | 5262 * @ws: the whitespace type of the value |
5251 * @length: the actual length of the value | 5263 * @length: the actual length of the value |
5252 * | 5264 * |
5253 * Checka a value against a "length", "minLength" and "maxLength" | 5265 * Checka a value against a "length", "minLength" and "maxLength" |
5254 * facet; sets @length to the computed length of @value. | 5266 * facet; sets @length to the computed length of @value. |
5255 * | 5267 * |
5256 * Returns 0 if the value is valid, a positive error code | 5268 * Returns 0 if the value is valid, a positive error code |
5257 * otherwise and -1 in case of an internal or API error. | 5269 * otherwise and -1 in case of an internal or API error. |
5258 */ | 5270 */ |
5259 int | 5271 int |
5260 xmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet, | 5272 xmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet, |
5261 xmlSchemaValType valType, | 5273 xmlSchemaValType valType, |
5262 const xmlChar *value, | 5274 const xmlChar *value, |
5263 xmlSchemaValPtr val, | 5275 xmlSchemaValPtr val, |
(...skipping 14 matching lines...) Expand all Loading... |
5278 * @ws: the whitespace type of the value | 5290 * @ws: the whitespace type of the value |
5279 * | 5291 * |
5280 * Check a value against a facet condition | 5292 * Check a value against a facet condition |
5281 * | 5293 * |
5282 * Returns 0 if the element is schemas valid, a positive error code | 5294 * Returns 0 if the element is schemas valid, a positive error code |
5283 * number otherwise and -1 in case of internal or API error. | 5295 * number otherwise and -1 in case of internal or API error. |
5284 */ | 5296 */ |
5285 static int | 5297 static int |
5286 xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet, | 5298 xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet, |
5287 xmlSchemaWhitespaceValueType fws, | 5299 xmlSchemaWhitespaceValueType fws, |
5288 » » » xmlSchemaValType valType,» » »
| 5300 » » » xmlSchemaValType valType, |
5289 const xmlChar *value, | 5301 const xmlChar *value, |
5290 xmlSchemaValPtr val, | 5302 xmlSchemaValPtr val, |
5291 xmlSchemaWhitespaceValueType ws) | 5303 xmlSchemaWhitespaceValueType ws) |
5292 { | 5304 { |
5293 int ret; | 5305 int ret; |
5294 | 5306 |
5295 if (facet == NULL) | 5307 if (facet == NULL) |
5296 return(-1); | 5308 return(-1); |
5297 | 5309 |
5298 switch (facet->type) { | 5310 switch (facet->type) { |
5299 case XML_SCHEMA_FACET_PATTERN: | 5311 case XML_SCHEMA_FACET_PATTERN: |
5300 » /* | 5312 » /* |
5301 * NOTE that for patterns, the @value needs to be the normalized | 5313 * NOTE that for patterns, the @value needs to be the normalized |
5302 * value, *not* the lexical initial value or the canonical value. | 5314 * value, *not* the lexical initial value or the canonical value. |
5303 */ | 5315 */ |
5304 if (value == NULL) | 5316 if (value == NULL) |
5305 return(-1); | 5317 return(-1); |
5306 ret = xmlRegexpExec(facet->regexp, value); | 5318 ret = xmlRegexpExec(facet->regexp, value); |
5307 if (ret == 1) | 5319 if (ret == 1) |
5308 return(0); | 5320 return(0); |
5309 if (ret == 0) | 5321 if (ret == 0) |
5310 return(XML_SCHEMAV_CVC_PATTERN_VALID); | 5322 return(XML_SCHEMAV_CVC_PATTERN_VALID); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5391 (facet->val->value.decimal.frac != 0)) { | 5403 (facet->val->value.decimal.frac != 0)) { |
5392 return(-1); | 5404 return(-1); |
5393 } | 5405 } |
5394 if ((val != NULL) && (val->type == XML_SCHEMAS_HEXBINARY)) | 5406 if ((val != NULL) && (val->type == XML_SCHEMAS_HEXBINARY)) |
5395 len = val->value.hex.total; | 5407 len = val->value.hex.total; |
5396 else if ((val != NULL) && (val->type == XML_SCHEMAS_BASE64BINARY)) | 5408 else if ((val != NULL) && (val->type == XML_SCHEMAS_BASE64BINARY)) |
5397 len = val->value.base64.total; | 5409 len = val->value.base64.total; |
5398 else { | 5410 else { |
5399 switch (valType) { | 5411 switch (valType) { |
5400 case XML_SCHEMAS_STRING: | 5412 case XML_SCHEMAS_STRING: |
5401 » » case XML_SCHEMAS_NORMSTRING:» » » | 5413 » » case XML_SCHEMAS_NORMSTRING: |
5402 if (ws == XML_SCHEMA_WHITESPACE_UNKNOWN) { | 5414 if (ws == XML_SCHEMA_WHITESPACE_UNKNOWN) { |
5403 /* | 5415 /* |
5404 * This is to ensure API compatibility with the old | 5416 * This is to ensure API compatibility with the old |
5405 * xmlSchemaValidateFacet(). Anyway, this was and | 5417 * xmlSchemaValidateFacet(). Anyway, this was and |
5406 * is not the correct handling. | 5418 * is not the correct handling. |
5407 * TODO: Get rid of this case somehow. | 5419 * TODO: Get rid of this case somehow. |
5408 */ | 5420 */ |
5409 if (valType == XML_SCHEMAS_STRING) | 5421 if (valType == XML_SCHEMAS_STRING) |
5410 len = xmlUTF8Strlen(value); | 5422 len = xmlUTF8Strlen(value); |
5411 else | 5423 else |
5412 len = xmlSchemaNormLen(value); | 5424 len = xmlSchemaNormLen(value); |
5413 } else if (value != NULL) { | 5425 } else if (value != NULL) { |
5414 if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) | 5426 if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) |
5415 len = xmlSchemaNormLen(value); | 5427 len = xmlSchemaNormLen(value); |
5416 else | 5428 else |
5417 » » » » /* | 5429 » » » » /* |
5418 * Should be OK for "preserve" as well. | 5430 * Should be OK for "preserve" as well. |
5419 */ | 5431 */ |
5420 len = xmlUTF8Strlen(value); | 5432 len = xmlUTF8Strlen(value); |
5421 } | 5433 } |
5422 break; | 5434 break; |
5423 » » case XML_SCHEMAS_IDREF:» » | 5435 » » case XML_SCHEMAS_IDREF: |
5424 case XML_SCHEMAS_TOKEN: | 5436 case XML_SCHEMAS_TOKEN: |
5425 case XML_SCHEMAS_LANGUAGE: | 5437 case XML_SCHEMAS_LANGUAGE: |
5426 case XML_SCHEMAS_NMTOKEN: | 5438 case XML_SCHEMAS_NMTOKEN: |
5427 case XML_SCHEMAS_NAME: | 5439 case XML_SCHEMAS_NAME: |
5428 case XML_SCHEMAS_NCNAME: | 5440 case XML_SCHEMAS_NCNAME: |
5429 case XML_SCHEMAS_ID: | 5441 case XML_SCHEMAS_ID: |
5430 case XML_SCHEMAS_ANYURI: | 5442 case XML_SCHEMAS_ANYURI: |
5431 if (value != NULL) | 5443 if (value != NULL) |
5432 » » » len = xmlSchemaNormLen(value); | 5444 » » » len = xmlSchemaNormLen(value); |
5433 » » » break;» » | 5445 » » » break; |
5434 default: | 5446 default: |
5435 TODO | 5447 TODO |
5436 » » } | 5448 » » } |
5437 } | 5449 } |
5438 if (facet->type == XML_SCHEMA_FACET_LENGTH) { | 5450 if (facet->type == XML_SCHEMA_FACET_LENGTH) { |
5439 if (len != facet->val->value.decimal.lo) | 5451 if (len != facet->val->value.decimal.lo) |
5440 return(XML_SCHEMAV_CVC_LENGTH_VALID); | 5452 return(XML_SCHEMAV_CVC_LENGTH_VALID); |
5441 } else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) { | 5453 } else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) { |
5442 if (len < facet->val->value.decimal.lo) | 5454 if (len < facet->val->value.decimal.lo) |
5443 return(XML_SCHEMAV_CVC_MINLENGTH_VALID); | 5455 return(XML_SCHEMAV_CVC_MINLENGTH_VALID); |
5444 } else { | 5456 } else { |
5445 if (len > facet->val->value.decimal.lo) | 5457 if (len > facet->val->value.decimal.lo) |
5446 return(XML_SCHEMAV_CVC_MAXLENGTH_VALID); | 5458 return(XML_SCHEMAV_CVC_MAXLENGTH_VALID); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5536 * according to the specified whitespace types into account. | 5548 * according to the specified whitespace types into account. |
5537 * Note that @value needs to be the *normalized* value if the facet | 5549 * Note that @value needs to be the *normalized* value if the facet |
5538 * is of type "pattern". | 5550 * is of type "pattern". |
5539 * | 5551 * |
5540 * Returns 0 if the element is schemas valid, a positive error code | 5552 * Returns 0 if the element is schemas valid, a positive error code |
5541 * number otherwise and -1 in case of internal or API error. | 5553 * number otherwise and -1 in case of internal or API error. |
5542 */ | 5554 */ |
5543 int | 5555 int |
5544 xmlSchemaValidateFacetWhtsp(xmlSchemaFacetPtr facet, | 5556 xmlSchemaValidateFacetWhtsp(xmlSchemaFacetPtr facet, |
5545 xmlSchemaWhitespaceValueType fws, | 5557 xmlSchemaWhitespaceValueType fws, |
5546 » » » xmlSchemaValType valType,» » » | 5558 » » » xmlSchemaValType valType, |
5547 const xmlChar *value, | 5559 const xmlChar *value, |
5548 xmlSchemaValPtr val, | 5560 xmlSchemaValPtr val, |
5549 xmlSchemaWhitespaceValueType ws) | 5561 xmlSchemaWhitespaceValueType ws) |
5550 { | 5562 { |
5551 return(xmlSchemaValidateFacetInternal(facet, fws, valType, | 5563 return(xmlSchemaValidateFacetInternal(facet, fws, valType, |
5552 value, val, ws)); | 5564 value, val, ws)); |
5553 } | 5565 } |
5554 | 5566 |
5555 #if 0 | 5567 #if 0 |
5556 #ifndef DBL_DIG | 5568 #ifndef DBL_DIG |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5597 char *ptr; | 5609 char *ptr; |
5598 char *after_fraction; | 5610 char *after_fraction; |
5599 double absolute_value; | 5611 double absolute_value; |
5600 int size; | 5612 int size; |
5601 | 5613 |
5602 absolute_value = fabs(number); | 5614 absolute_value = fabs(number); |
5603 | 5615 |
5604 /* | 5616 /* |
5605 * Result is in work, and after_fraction points | 5617 * Result is in work, and after_fraction points |
5606 * just past the fractional part. | 5618 * just past the fractional part. |
5607 » * Use scientific notation | 5619 » * Use scientific notation |
5608 */ | 5620 */ |
5609 integer_place = DBL_DIG + EXPONENT_DIGITS + 1; | 5621 integer_place = DBL_DIG + EXPONENT_DIGITS + 1; |
5610 fraction_place = DBL_DIG - 1; | 5622 fraction_place = DBL_DIG - 1; |
5611 snprintf(work, sizeof(work),"%*.*e", | 5623 snprintf(work, sizeof(work),"%*.*e", |
5612 integer_place, fraction_place, number); | 5624 integer_place, fraction_place, number); |
5613 » after_fraction = strchr(work + DBL_DIG, 'e');» | 5625 » after_fraction = strchr(work + DBL_DIG, 'e'); |
5614 /* Remove fractional trailing zeroes */ | 5626 /* Remove fractional trailing zeroes */ |
5615 ptr = after_fraction; | 5627 ptr = after_fraction; |
5616 while (*(--ptr) == '0') | 5628 while (*(--ptr) == '0') |
5617 ; | 5629 ; |
5618 if (*ptr != '.') | 5630 if (*ptr != '.') |
5619 ptr++; | 5631 ptr++; |
5620 while ((*ptr++ = *after_fraction++) != 0); | 5632 while ((*ptr++ = *after_fraction++) != 0); |
5621 | 5633 |
5622 /* Finally copy result back to caller */ | 5634 /* Finally copy result back to caller */ |
5623 size = strlen(work) + 1; | 5635 size = strlen(work) + 1; |
5624 if (size > buffersize) { | 5636 if (size > buffersize) { |
5625 work[buffersize - 1] = 0; | 5637 work[buffersize - 1] = 0; |
5626 size = buffersize; | 5638 size = buffersize; |
5627 } | 5639 } |
5628 memmove(buffer, work, size); | 5640 memmove(buffer, work, size); |
5629 } | 5641 } |
5630 break; | 5642 break; |
5631 } | 5643 } |
5632 } | 5644 } |
5633 #endif | 5645 #endif |
5634 | 5646 |
5635 /** | 5647 /** |
5636 * xmlSchemaGetCanonValue: | 5648 * xmlSchemaGetCanonValue: |
5637 * @val: the precomputed value | 5649 * @val: the precomputed value |
5638 * @retValue: the returned value | 5650 * @retValue: the returned value |
5639 * | 5651 * |
5640 * Get a the cononical lexical representation of the value. | 5652 * Get the canonical lexical representation of the value. |
5641 * The caller has to FREE the returned retValue. | 5653 * The caller has to FREE the returned retValue. |
5642 * | 5654 * |
5643 * WARNING: Some value types are not supported yet, resulting | 5655 * WARNING: Some value types are not supported yet, resulting |
5644 * in a @retValue of "???". | 5656 * in a @retValue of "???". |
5645 * | 5657 * |
5646 * TODO: XML Schema 1.0 does not define canonical representations | 5658 * TODO: XML Schema 1.0 does not define canonical representations |
5647 * for: duration, gYearMonth, gYear, gMonthDay, gMonth, gDay, | 5659 * for: duration, gYearMonth, gYear, gMonthDay, gMonth, gDay, |
5648 * anyURI, QName, NOTATION. This will be fixed in XML Schema 1.1. | 5660 * anyURI, QName, NOTATION. This will be fixed in XML Schema 1.1. |
5649 * | 5661 * |
5650 * | 5662 * |
5651 * Returns 0 if the value could be built, 1 if the value type is | 5663 * Returns 0 if the value could be built, 1 if the value type is |
5652 * not supported yet and -1 in case of API errors. | 5664 * not supported yet and -1 in case of API errors. |
5653 */ | 5665 */ |
5654 int | 5666 int |
5655 xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue) | 5667 xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue) |
5656 { | 5668 { |
5657 if ((retValue == NULL) || (val == NULL)) | 5669 if ((retValue == NULL) || (val == NULL)) |
5658 return (-1); | 5670 return (-1); |
5659 *retValue = NULL; | 5671 *retValue = NULL; |
5660 switch (val->type) { | 5672 switch (val->type) { |
5661 case XML_SCHEMAS_STRING: | 5673 case XML_SCHEMAS_STRING: |
5662 if (val->value.str == NULL) | 5674 if (val->value.str == NULL) |
5663 *retValue = BAD_CAST xmlStrdup(BAD_CAST ""); | 5675 *retValue = BAD_CAST xmlStrdup(BAD_CAST ""); |
5664 else | 5676 else |
5665 » » *retValue = | 5677 » » *retValue = |
5666 BAD_CAST xmlStrdup((const xmlChar *) val->value.str); | 5678 BAD_CAST xmlStrdup((const xmlChar *) val->value.str); |
5667 break; | 5679 break; |
5668 case XML_SCHEMAS_NORMSTRING: | 5680 case XML_SCHEMAS_NORMSTRING: |
5669 if (val->value.str == NULL) | 5681 if (val->value.str == NULL) |
5670 *retValue = BAD_CAST xmlStrdup(BAD_CAST ""); | 5682 *retValue = BAD_CAST xmlStrdup(BAD_CAST ""); |
5671 else { | 5683 else { |
5672 *retValue = xmlSchemaWhiteSpaceReplace( | 5684 *retValue = xmlSchemaWhiteSpaceReplace( |
5673 (const xmlChar *) val->value.str); | 5685 (const xmlChar *) val->value.str); |
5674 if ((*retValue) == NULL) | 5686 if ((*retValue) == NULL) |
5675 *retValue = BAD_CAST xmlStrdup( | 5687 *retValue = BAD_CAST xmlStrdup( |
5676 (const xmlChar *) val->value.str); | 5688 (const xmlChar *) val->value.str); |
5677 } | 5689 } |
5678 break; | 5690 break; |
5679 case XML_SCHEMAS_TOKEN: | 5691 case XML_SCHEMAS_TOKEN: |
5680 case XML_SCHEMAS_LANGUAGE: | 5692 case XML_SCHEMAS_LANGUAGE: |
5681 case XML_SCHEMAS_NMTOKEN: | 5693 case XML_SCHEMAS_NMTOKEN: |
5682 » case XML_SCHEMAS_NAME:» | 5694 » case XML_SCHEMAS_NAME: |
5683 case XML_SCHEMAS_NCNAME: | 5695 case XML_SCHEMAS_NCNAME: |
5684 case XML_SCHEMAS_ID: | 5696 case XML_SCHEMAS_ID: |
5685 case XML_SCHEMAS_IDREF: | 5697 case XML_SCHEMAS_IDREF: |
5686 case XML_SCHEMAS_ENTITY: | 5698 case XML_SCHEMAS_ENTITY: |
5687 case XML_SCHEMAS_NOTATION: /* Unclear */ | 5699 case XML_SCHEMAS_NOTATION: /* Unclear */ |
5688 case XML_SCHEMAS_ANYURI: /* Unclear */ | 5700 case XML_SCHEMAS_ANYURI: /* Unclear */ |
5689 if (val->value.str == NULL) | 5701 if (val->value.str == NULL) |
5690 return (-1); | 5702 return (-1); |
5691 » *retValue = | 5703 » *retValue = |
5692 BAD_CAST xmlSchemaCollapseString(BAD_CAST val->value.str); | 5704 BAD_CAST xmlSchemaCollapseString(BAD_CAST val->value.str); |
5693 if (*retValue == NULL) | 5705 if (*retValue == NULL) |
5694 » » *retValue = | 5706 » » *retValue = |
5695 BAD_CAST xmlStrdup((const xmlChar *) val->value.str); | 5707 BAD_CAST xmlStrdup((const xmlChar *) val->value.str); |
5696 break; | 5708 break; |
5697 case XML_SCHEMAS_QNAME: | 5709 case XML_SCHEMAS_QNAME: |
5698 /* TODO: Unclear in XML Schema 1.0. */ | 5710 /* TODO: Unclear in XML Schema 1.0. */ |
5699 if (val->value.qname.uri == NULL) { | 5711 if (val->value.qname.uri == NULL) { |
5700 *retValue = BAD_CAST xmlStrdup(BAD_CAST val->value.qname.name); | 5712 *retValue = BAD_CAST xmlStrdup(BAD_CAST val->value.qname.name); |
5701 return (0); | 5713 return (0); |
5702 } else { | 5714 } else { |
5703 *retValue = BAD_CAST xmlStrdup(BAD_CAST "{"); | 5715 *retValue = BAD_CAST xmlStrdup(BAD_CAST "{"); |
5704 *retValue = BAD_CAST xmlStrcat((xmlChar *) (*retValue), | 5716 *retValue = BAD_CAST xmlStrcat((xmlChar *) (*retValue), |
5705 BAD_CAST val->value.qname.uri); | 5717 BAD_CAST val->value.qname.uri); |
5706 *retValue = BAD_CAST xmlStrcat((xmlChar *) (*retValue), | 5718 *retValue = BAD_CAST xmlStrcat((xmlChar *) (*retValue), |
5707 BAD_CAST "}"); | 5719 BAD_CAST "}"); |
5708 *retValue = BAD_CAST xmlStrcat((xmlChar *) (*retValue), | 5720 *retValue = BAD_CAST xmlStrcat((xmlChar *) (*retValue), |
5709 BAD_CAST val->value.qname.uri); | 5721 BAD_CAST val->value.qname.uri); |
5710 } | 5722 } |
5711 break; | 5723 break; |
5712 case XML_SCHEMAS_DECIMAL: | 5724 case XML_SCHEMAS_DECIMAL: |
5713 /* | 5725 /* |
5714 * TODO: Lookout for a more simple implementation. | 5726 * TODO: Lookout for a more simple implementation. |
5715 */ | 5727 */ |
5716 » if ((val->value.decimal.total == 1) && | 5728 » if ((val->value.decimal.total == 1) && |
5717 (val->value.decimal.lo == 0)) { | 5729 (val->value.decimal.lo == 0)) { |
5718 *retValue = xmlStrdup(BAD_CAST "0.0"); | 5730 *retValue = xmlStrdup(BAD_CAST "0.0"); |
5719 } else { | 5731 } else { |
5720 xmlSchemaValDecimal dec = val->value.decimal; | 5732 xmlSchemaValDecimal dec = val->value.decimal; |
5721 int bufsize; | 5733 int bufsize; |
5722 char *buf = NULL, *offs; | 5734 char *buf = NULL, *offs; |
5723 | 5735 |
5724 /* Add room for the decimal point as well. */ | 5736 /* Add room for the decimal point as well. */ |
5725 bufsize = dec.total + 2; | 5737 bufsize = dec.total + 2; |
5726 if (dec.sign) | 5738 if (dec.sign) |
(...skipping 13 matching lines...) Expand all Loading... |
5740 } | 5752 } |
5741 if (dec.hi != 0) | 5753 if (dec.hi != 0) |
5742 snprintf(offs, bufsize - (offs - buf), | 5754 snprintf(offs, bufsize - (offs - buf), |
5743 "%lu%lu%lu", dec.hi, dec.mi, dec.lo); | 5755 "%lu%lu%lu", dec.hi, dec.mi, dec.lo); |
5744 else if (dec.mi != 0) | 5756 else if (dec.mi != 0) |
5745 snprintf(offs, bufsize - (offs - buf), | 5757 snprintf(offs, bufsize - (offs - buf), |
5746 "%lu%lu", dec.mi, dec.lo); | 5758 "%lu%lu", dec.mi, dec.lo); |
5747 else | 5759 else |
5748 snprintf(offs, bufsize - (offs - buf), | 5760 snprintf(offs, bufsize - (offs - buf), |
5749 "%lu", dec.lo); | 5761 "%lu", dec.lo); |
5750 » » » | 5762 |
5751 if (dec.frac != 0) { | 5763 if (dec.frac != 0) { |
5752 if (dec.frac != dec.total) { | 5764 if (dec.frac != dec.total) { |
5753 int diff = dec.total - dec.frac; | 5765 int diff = dec.total - dec.frac; |
5754 /* | 5766 /* |
5755 * Insert the decimal point. | 5767 * Insert the decimal point. |
5756 */ | 5768 */ |
5757 memmove(offs + diff + 1, offs + diff, dec.frac +1); | 5769 memmove(offs + diff + 1, offs + diff, dec.frac +1); |
5758 offs[diff] = '.'; | 5770 offs[diff] = '.'; |
5759 } else { | 5771 } else { |
5760 unsigned int i = 0; | 5772 unsigned int i = 0; |
5761 /* | 5773 /* |
5762 * Insert missing zeroes behind the decimal point. | 5774 * Insert missing zeroes behind the decimal point. |
5763 » » » */» » » | 5775 » » » */ |
5764 while (*(offs + i) != 0) | 5776 while (*(offs + i) != 0) |
5765 i++; | 5777 i++; |
5766 if (i < dec.total) { | 5778 if (i < dec.total) { |
5767 memmove(offs + (dec.total - i), offs, i +1); | 5779 memmove(offs + (dec.total - i), offs, i +1); |
5768 memset(offs, '0', dec.total - i); | 5780 memset(offs, '0', dec.total - i); |
5769 } | 5781 } |
5770 } | 5782 } |
5771 } else { | 5783 } else { |
5772 /* | 5784 /* |
5773 * Append decimal point and zero. | 5785 * Append decimal point and zero. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5890 break; | 5902 break; |
5891 case XML_SCHEMAS_GDAY: { | 5903 case XML_SCHEMAS_GDAY: { |
5892 /* TODO: Unclear in XML Schema 1.0 */ | 5904 /* TODO: Unclear in XML Schema 1.0 */ |
5893 /* TODO: What to do with the timezone? */ | 5905 /* TODO: What to do with the timezone? */ |
5894 *retValue = xmlMalloc(6); | 5906 *retValue = xmlMalloc(6); |
5895 if (*retValue == NULL) | 5907 if (*retValue == NULL) |
5896 return(-1); | 5908 return(-1); |
5897 snprintf((char *) *retValue, 6, "---%02u", | 5909 snprintf((char *) *retValue, 6, "---%02u", |
5898 val->value.date.day); | 5910 val->value.date.day); |
5899 } | 5911 } |
5900 » break; | 5912 » break; |
5901 case XML_SCHEMAS_GMONTHDAY: { | 5913 case XML_SCHEMAS_GMONTHDAY: { |
5902 /* TODO: Unclear in XML Schema 1.0 */ | 5914 /* TODO: Unclear in XML Schema 1.0 */ |
5903 /* TODO: What to do with the timezone? */ | 5915 /* TODO: What to do with the timezone? */ |
5904 *retValue = xmlMalloc(8); | 5916 *retValue = xmlMalloc(8); |
5905 if (*retValue == NULL) | 5917 if (*retValue == NULL) |
5906 return(-1); | 5918 return(-1); |
5907 snprintf((char *) *retValue, 8, "--%02u-%02u", | 5919 snprintf((char *) *retValue, 8, "--%02u-%02u", |
5908 val->value.date.mon, val->value.date.day); | 5920 val->value.date.mon, val->value.date.day); |
5909 } | 5921 } |
5910 break; | 5922 break; |
5911 case XML_SCHEMAS_GYEARMONTH: { | 5923 case XML_SCHEMAS_GYEARMONTH: { |
5912 char buf[35]; | 5924 char buf[35]; |
5913 /* TODO: Unclear in XML Schema 1.0 */ | 5925 /* TODO: Unclear in XML Schema 1.0 */ |
5914 /* TODO: What to do with the timezone? */ | 5926 /* TODO: What to do with the timezone? */ |
5915 if (val->value.date.year < 0) | 5927 if (val->value.date.year < 0) |
5916 snprintf(buf, 35, "-%04ld-%02u", | 5928 snprintf(buf, 35, "-%04ld-%02u", |
5917 » » » labs(val->value.date.year), | 5929 » » » labs(val->value.date.year), |
5918 val->value.date.mon); | 5930 val->value.date.mon); |
5919 else | 5931 else |
5920 snprintf(buf, 35, "%04ld-%02u", | 5932 snprintf(buf, 35, "%04ld-%02u", |
5921 val->value.date.year, val->value.date.mon); | 5933 val->value.date.year, val->value.date.mon); |
5922 *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); | 5934 *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); |
5923 } | 5935 } |
5924 » break;» » | 5936 » break; |
5925 case XML_SCHEMAS_TIME: | 5937 case XML_SCHEMAS_TIME: |
5926 { | 5938 { |
5927 char buf[30]; | 5939 char buf[30]; |
5928 | 5940 |
5929 if (val->value.date.tz_flag) { | 5941 if (val->value.date.tz_flag) { |
5930 xmlSchemaValPtr norm; | 5942 xmlSchemaValPtr norm; |
5931 | 5943 |
5932 norm = xmlSchemaDateNormalize(val, 0); | 5944 norm = xmlSchemaDateNormalize(val, 0); |
5933 if (norm == NULL) | 5945 if (norm == NULL) |
5934 return (-1); | 5946 return (-1); |
5935 » » /* | 5947 » » /* |
5936 » » * TODO: Check if "%.14g" is portable.» » | 5948 » » * TODO: Check if "%.14g" is portable. |
5937 */ | 5949 */ |
5938 snprintf(buf, 30, | 5950 snprintf(buf, 30, |
5939 "%02u:%02u:%02.14gZ", | 5951 "%02u:%02u:%02.14gZ", |
5940 norm->value.date.hour, | 5952 norm->value.date.hour, |
5941 norm->value.date.min, | 5953 norm->value.date.min, |
5942 norm->value.date.sec); | 5954 norm->value.date.sec); |
5943 xmlSchemaFreeValue(norm); | 5955 xmlSchemaFreeValue(norm); |
5944 } else { | 5956 } else { |
5945 snprintf(buf, 30, | 5957 snprintf(buf, 30, |
5946 "%02u:%02u:%02.14g", | 5958 "%02u:%02u:%02.14g", |
5947 val->value.date.hour, | 5959 val->value.date.hour, |
5948 val->value.date.min, | 5960 val->value.date.min, |
5949 val->value.date.sec); | 5961 val->value.date.sec); |
5950 } | 5962 } |
5951 *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); | 5963 *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); |
5952 » }» | 5964 » } |
5953 break; | 5965 break; |
5954 case XML_SCHEMAS_DATE: | 5966 case XML_SCHEMAS_DATE: |
5955 { | 5967 { |
5956 char buf[30]; | 5968 char buf[30]; |
5957 | 5969 |
5958 if (val->value.date.tz_flag) { | 5970 if (val->value.date.tz_flag) { |
5959 xmlSchemaValPtr norm; | 5971 xmlSchemaValPtr norm; |
5960 | 5972 |
5961 norm = xmlSchemaDateNormalize(val, 0); | 5973 norm = xmlSchemaDateNormalize(val, 0); |
5962 if (norm == NULL) | 5974 if (norm == NULL) |
5963 return (-1); | 5975 return (-1); |
5964 /* | 5976 /* |
5965 * TODO: Append the canonical value of the | 5977 * TODO: Append the canonical value of the |
5966 * recoverable timezone and not "Z". | 5978 * recoverable timezone and not "Z". |
5967 */ | 5979 */ |
5968 snprintf(buf, 30, | 5980 snprintf(buf, 30, |
5969 "%04ld:%02u:%02uZ", | 5981 "%04ld:%02u:%02uZ", |
5970 norm->value.date.year, norm->value.date.mon, | 5982 norm->value.date.year, norm->value.date.mon, |
5971 norm->value.date.day); | 5983 norm->value.date.day); |
5972 xmlSchemaFreeValue(norm); | 5984 xmlSchemaFreeValue(norm); |
5973 } else { | 5985 } else { |
5974 snprintf(buf, 30, | 5986 snprintf(buf, 30, |
5975 "%04ld:%02u:%02u", | 5987 "%04ld:%02u:%02u", |
5976 val->value.date.year, val->value.date.mon, | 5988 val->value.date.year, val->value.date.mon, |
5977 val->value.date.day); | 5989 val->value.date.day); |
5978 } | 5990 } |
5979 *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); | 5991 *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); |
5980 » }» | 5992 » } |
5981 break; | 5993 break; |
5982 case XML_SCHEMAS_DATETIME: | 5994 case XML_SCHEMAS_DATETIME: |
5983 { | 5995 { |
5984 char buf[50]; | 5996 char buf[50]; |
5985 | 5997 |
5986 if (val->value.date.tz_flag) { | 5998 if (val->value.date.tz_flag) { |
5987 xmlSchemaValPtr norm; | 5999 xmlSchemaValPtr norm; |
5988 | 6000 |
5989 norm = xmlSchemaDateNormalize(val, 0); | 6001 norm = xmlSchemaDateNormalize(val, 0); |
5990 if (norm == NULL) | 6002 if (norm == NULL) |
(...skipping 23 matching lines...) Expand all Loading... |
6014 case XML_SCHEMAS_BASE64BINARY: | 6026 case XML_SCHEMAS_BASE64BINARY: |
6015 /* | 6027 /* |
6016 * TODO: Is the following spec piece implemented?: | 6028 * TODO: Is the following spec piece implemented?: |
6017 * SPEC: "Note: For some values the canonical form defined | 6029 * SPEC: "Note: For some values the canonical form defined |
6018 * above does not conform to [RFC 2045], which requires breaking | 6030 * above does not conform to [RFC 2045], which requires breaking |
6019 * with linefeeds at appropriate intervals." | 6031 * with linefeeds at appropriate intervals." |
6020 */ | 6032 */ |
6021 *retValue = BAD_CAST xmlStrdup(BAD_CAST val->value.base64.str); | 6033 *retValue = BAD_CAST xmlStrdup(BAD_CAST val->value.base64.str); |
6022 break; | 6034 break; |
6023 case XML_SCHEMAS_FLOAT: { | 6035 case XML_SCHEMAS_FLOAT: { |
6024 » » char buf[30];» » | 6036 » » char buf[30]; |
6025 » » /* | 6037 » » /* |
6026 * |m| < 16777216, -149 <= e <= 104. | 6038 * |m| < 16777216, -149 <= e <= 104. |
6027 * TODO: Handle, NaN, INF, -INF. The format is not | 6039 * TODO: Handle, NaN, INF, -INF. The format is not |
6028 * yet conformant. The c type float does not cover | 6040 * yet conformant. The c type float does not cover |
6029 * the whole range. | 6041 * the whole range. |
6030 */ | 6042 */ |
6031 snprintf(buf, 30, "%01.14e", val->value.f); | 6043 snprintf(buf, 30, "%01.14e", val->value.f); |
6032 *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); | 6044 *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); |
6033 } | 6045 } |
6034 break; | 6046 break; |
6035 case XML_SCHEMAS_DOUBLE: { | 6047 case XML_SCHEMAS_DOUBLE: { |
6036 char buf[40]; | 6048 char buf[40]; |
6037 /* |m| < 9007199254740992, -1075 <= e <= 970 */ | 6049 /* |m| < 9007199254740992, -1075 <= e <= 970 */ |
6038 /* | 6050 /* |
6039 * TODO: Handle, NaN, INF, -INF. The format is not | 6051 * TODO: Handle, NaN, INF, -INF. The format is not |
6040 * yet conformant. The c type float does not cover | 6052 * yet conformant. The c type float does not cover |
6041 * the whole range. | 6053 * the whole range. |
6042 */ | 6054 */ |
6043 snprintf(buf, 40, "%01.14e", val->value.d); | 6055 snprintf(buf, 40, "%01.14e", val->value.d); |
6044 *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); | 6056 *retValue = BAD_CAST xmlStrdup(BAD_CAST buf); |
6045 } | 6057 } |
6046 » break;» | 6058 » break; |
6047 default: | 6059 default: |
6048 *retValue = BAD_CAST xmlStrdup(BAD_CAST "???"); | 6060 *retValue = BAD_CAST xmlStrdup(BAD_CAST "???"); |
6049 return (1); | 6061 return (1); |
6050 } | 6062 } |
6051 if (*retValue == NULL) | 6063 if (*retValue == NULL) |
6052 return(-1); | 6064 return(-1); |
6053 return (0); | 6065 return (0); |
6054 } | 6066 } |
6055 | 6067 |
6056 /** | 6068 /** |
6057 * xmlSchemaGetCanonValueWhtsp: | 6069 * xmlSchemaGetCanonValueWhtsp: |
6058 * @val: the precomputed value | 6070 * @val: the precomputed value |
6059 * @retValue: the returned value | 6071 * @retValue: the returned value |
6060 * @ws: the whitespace type of the value | 6072 * @ws: the whitespace type of the value |
6061 * | 6073 * |
6062 * Get a the cononical representation of the value. | 6074 * Get the canonical representation of the value. |
6063 * The caller has to free the returned @retValue. | 6075 * The caller has to free the returned @retValue. |
6064 * | 6076 * |
6065 * Returns 0 if the value could be built, 1 if the value type is | 6077 * Returns 0 if the value could be built, 1 if the value type is |
6066 * not supported yet and -1 in case of API errors. | 6078 * not supported yet and -1 in case of API errors. |
6067 */ | 6079 */ |
6068 int | 6080 int |
6069 xmlSchemaGetCanonValueWhtsp(xmlSchemaValPtr val, | 6081 xmlSchemaGetCanonValueWhtsp(xmlSchemaValPtr val, |
6070 const xmlChar **retValue, | 6082 const xmlChar **retValue, |
6071 xmlSchemaWhitespaceValueType ws) | 6083 xmlSchemaWhitespaceValueType ws) |
6072 { | 6084 { |
(...skipping 22 matching lines...) Expand all Loading... |
6095 if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) | 6107 if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) |
6096 *retValue = xmlSchemaCollapseString(val->value.str); | 6108 *retValue = xmlSchemaCollapseString(val->value.str); |
6097 else | 6109 else |
6098 *retValue = xmlSchemaWhiteSpaceReplace(val->value.str); | 6110 *retValue = xmlSchemaWhiteSpaceReplace(val->value.str); |
6099 if ((*retValue) == NULL) | 6111 if ((*retValue) == NULL) |
6100 *retValue = BAD_CAST xmlStrdup(val->value.str); | 6112 *retValue = BAD_CAST xmlStrdup(val->value.str); |
6101 } | 6113 } |
6102 break; | 6114 break; |
6103 default: | 6115 default: |
6104 return (xmlSchemaGetCanonValue(val, retValue)); | 6116 return (xmlSchemaGetCanonValue(val, retValue)); |
6105 } | 6117 } |
6106 return (0); | 6118 return (0); |
6107 } | 6119 } |
6108 | 6120 |
6109 /** | 6121 /** |
6110 * xmlSchemaGetValType: | 6122 * xmlSchemaGetValType: |
6111 * @val: a schemas value | 6123 * @val: a schemas value |
6112 * | 6124 * |
6113 * Accessor for the type of a value | 6125 * Accessor for the type of a value |
6114 * | 6126 * |
6115 * Returns the xmlSchemaValType of the value | 6127 * Returns the xmlSchemaValType of the value |
6116 */ | 6128 */ |
6117 xmlSchemaValType | 6129 xmlSchemaValType |
6118 xmlSchemaGetValType(xmlSchemaValPtr val) | 6130 xmlSchemaGetValType(xmlSchemaValPtr val) |
6119 { | 6131 { |
6120 if (val == NULL) | 6132 if (val == NULL) |
6121 return(XML_SCHEMAS_UNKNOWN); | 6133 return(XML_SCHEMAS_UNKNOWN); |
6122 return (val->type); | 6134 return (val->type); |
6123 } | 6135 } |
6124 | 6136 |
6125 #define bottom_xmlschemastypes | 6137 #define bottom_xmlschemastypes |
6126 #include "elfgcchack.h" | 6138 #include "elfgcchack.h" |
6127 #endif /* LIBXML_SCHEMAS_ENABLED */ | 6139 #endif /* LIBXML_SCHEMAS_ENABLED */ |
OLD | NEW |