12#pragma convert("ISO8859-1")
18#ifdef LIBXML_SCHEMAS_ENABLED
38#ifndef LIBXML_XPATH_ENABLED
39extern double xmlXPathNAN;
40extern double xmlXPathPINF;
41extern double xmlXPathNINF;
45 xmlGenericError(xmlGenericErrorContext, \
46 "Unimplemented block at %s:%d\n", \
49#define XML_SCHEMAS_NAMESPACE_NAME \
50 (const xmlChar *)"http://www.w3.org/2001/XMLSchema"
52#define IS_WSP_REPLACE_CH(c) ((((c) == 0x9) || ((c) == 0xa)) || \
55#define IS_WSP_SPACE_CH(c) ((c) == 0x20)
57#define IS_WSP_BLANK_CH(c) IS_BLANK_CH(c)
60typedef struct _xmlSchemaValDate xmlSchemaValDate;
61typedef xmlSchemaValDate *xmlSchemaValDatePtr;
62struct _xmlSchemaValDate {
69 unsigned int tz_flag :1;
75typedef struct _xmlSchemaValDuration xmlSchemaValDuration;
76typedef xmlSchemaValDuration *xmlSchemaValDurationPtr;
77struct _xmlSchemaValDuration {
83typedef struct _xmlSchemaValDecimal xmlSchemaValDecimal;
84typedef xmlSchemaValDecimal *xmlSchemaValDecimalPtr;
85struct _xmlSchemaValDecimal {
96typedef struct _xmlSchemaValQName xmlSchemaValQName;
97typedef xmlSchemaValQName *xmlSchemaValQNamePtr;
98struct _xmlSchemaValQName {
103typedef struct _xmlSchemaValHex xmlSchemaValHex;
104typedef xmlSchemaValHex *xmlSchemaValHexPtr;
105struct _xmlSchemaValHex {
110typedef struct _xmlSchemaValBase64 xmlSchemaValBase64;
111typedef xmlSchemaValBase64 *xmlSchemaValBase64Ptr;
112struct _xmlSchemaValBase64 {
117struct _xmlSchemaVal {
118 xmlSchemaValType
type;
119 struct _xmlSchemaVal *
next;
121 xmlSchemaValDecimal decimal;
122 xmlSchemaValDate
date;
123 xmlSchemaValDuration dur;
124 xmlSchemaValQName qname;
126 xmlSchemaValBase64 base64;
134static int xmlSchemaTypesInitialized = 0;
140static xmlSchemaTypePtr xmlSchemaTypeStringDef =
NULL;
141static xmlSchemaTypePtr xmlSchemaTypeAnyTypeDef =
NULL;
142static xmlSchemaTypePtr xmlSchemaTypeAnySimpleTypeDef =
NULL;
143static xmlSchemaTypePtr xmlSchemaTypeDecimalDef =
NULL;
144static xmlSchemaTypePtr xmlSchemaTypeDatetimeDef =
NULL;
145static xmlSchemaTypePtr xmlSchemaTypeDateDef =
NULL;
146static xmlSchemaTypePtr xmlSchemaTypeTimeDef =
NULL;
147static xmlSchemaTypePtr xmlSchemaTypeGYearDef =
NULL;
148static xmlSchemaTypePtr xmlSchemaTypeGYearMonthDef =
NULL;
149static xmlSchemaTypePtr xmlSchemaTypeGDayDef =
NULL;
150static xmlSchemaTypePtr xmlSchemaTypeGMonthDayDef =
NULL;
151static xmlSchemaTypePtr xmlSchemaTypeGMonthDef =
NULL;
152static xmlSchemaTypePtr xmlSchemaTypeDurationDef =
NULL;
153static xmlSchemaTypePtr xmlSchemaTypeFloatDef =
NULL;
154static xmlSchemaTypePtr xmlSchemaTypeBooleanDef =
NULL;
155static xmlSchemaTypePtr xmlSchemaTypeDoubleDef =
NULL;
156static xmlSchemaTypePtr xmlSchemaTypeHexBinaryDef =
NULL;
157static xmlSchemaTypePtr xmlSchemaTypeBase64BinaryDef =
NULL;
158static xmlSchemaTypePtr xmlSchemaTypeAnyURIDef =
NULL;
163static xmlSchemaTypePtr xmlSchemaTypePositiveIntegerDef =
NULL;
164static xmlSchemaTypePtr xmlSchemaTypeNonPositiveIntegerDef =
NULL;
165static xmlSchemaTypePtr xmlSchemaTypeNegativeIntegerDef =
NULL;
166static xmlSchemaTypePtr xmlSchemaTypeNonNegativeIntegerDef =
NULL;
167static xmlSchemaTypePtr xmlSchemaTypeIntegerDef =
NULL;
168static xmlSchemaTypePtr xmlSchemaTypeLongDef =
NULL;
169static xmlSchemaTypePtr xmlSchemaTypeIntDef =
NULL;
170static xmlSchemaTypePtr xmlSchemaTypeShortDef =
NULL;
171static xmlSchemaTypePtr xmlSchemaTypeByteDef =
NULL;
172static xmlSchemaTypePtr xmlSchemaTypeUnsignedLongDef =
NULL;
173static xmlSchemaTypePtr xmlSchemaTypeUnsignedIntDef =
NULL;
174static xmlSchemaTypePtr xmlSchemaTypeUnsignedShortDef =
NULL;
175static xmlSchemaTypePtr xmlSchemaTypeUnsignedByteDef =
NULL;
176static xmlSchemaTypePtr xmlSchemaTypeNormStringDef =
NULL;
177static xmlSchemaTypePtr xmlSchemaTypeTokenDef =
NULL;
178static xmlSchemaTypePtr xmlSchemaTypeLanguageDef =
NULL;
179static xmlSchemaTypePtr xmlSchemaTypeNameDef =
NULL;
180static xmlSchemaTypePtr xmlSchemaTypeQNameDef =
NULL;
181static xmlSchemaTypePtr xmlSchemaTypeNCNameDef =
NULL;
182static xmlSchemaTypePtr xmlSchemaTypeIdDef =
NULL;
183static xmlSchemaTypePtr xmlSchemaTypeIdrefDef =
NULL;
184static xmlSchemaTypePtr xmlSchemaTypeIdrefsDef =
NULL;
185static xmlSchemaTypePtr xmlSchemaTypeEntityDef =
NULL;
186static xmlSchemaTypePtr xmlSchemaTypeEntitiesDef =
NULL;
187static xmlSchemaTypePtr xmlSchemaTypeNotationDef =
NULL;
188static xmlSchemaTypePtr xmlSchemaTypeNmtokenDef =
NULL;
189static xmlSchemaTypePtr xmlSchemaTypeNmtokensDef =
NULL;
222static xmlSchemaValPtr
223xmlSchemaNewValue(xmlSchemaValType
type) {
224 xmlSchemaValPtr
value;
235static xmlSchemaFacetPtr
236xmlSchemaNewMinLengthFacet(
int value)
238 xmlSchemaFacetPtr
ret;
240 ret = xmlSchemaNewFacet();
244 ret->type = XML_SCHEMA_FACET_MINLENGTH;
245 ret->val = xmlSchemaNewValue(XML_SCHEMAS_NNINTEGER);
261static xmlSchemaTypePtr
262xmlSchemaInitBasicType(
const char *
name, xmlSchemaValType
type,
263 xmlSchemaTypePtr baseType) {
264 xmlSchemaTypePtr
ret;
266 ret = (xmlSchemaTypePtr)
xmlMalloc(
sizeof(xmlSchemaType));
268 xmlSchemaTypeErrMemory(
NULL,
"could not initialize basic types");
273 ret->targetNamespace = XML_SCHEMAS_NAMESPACE_NAME;
274 ret->type = XML_SCHEMA_TYPE_BASIC;
275 ret->baseType = baseType;
276 ret->contentType = XML_SCHEMA_CONTENT_BASIC;
281 case XML_SCHEMAS_STRING:
282 case XML_SCHEMAS_DECIMAL:
283 case XML_SCHEMAS_DATE:
284 case XML_SCHEMAS_DATETIME:
285 case XML_SCHEMAS_TIME:
286 case XML_SCHEMAS_GYEAR:
287 case XML_SCHEMAS_GYEARMONTH:
288 case XML_SCHEMAS_GMONTH:
289 case XML_SCHEMAS_GMONTHDAY:
290 case XML_SCHEMAS_GDAY:
291 case XML_SCHEMAS_DURATION:
292 case XML_SCHEMAS_FLOAT:
293 case XML_SCHEMAS_DOUBLE:
294 case XML_SCHEMAS_BOOLEAN:
295 case XML_SCHEMAS_ANYURI:
296 case XML_SCHEMAS_HEXBINARY:
297 case XML_SCHEMAS_BASE64BINARY:
298 case XML_SCHEMAS_QNAME:
299 case XML_SCHEMAS_NOTATION:
300 ret->flags |= XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE;
309 case XML_SCHEMAS_ANYTYPE:
310 case XML_SCHEMAS_ANYSIMPLETYPE:
312 case XML_SCHEMAS_IDREFS:
313 case XML_SCHEMAS_NMTOKENS:
314 case XML_SCHEMAS_ENTITIES:
315 ret->flags |= XML_SCHEMAS_TYPE_VARIETY_LIST;
316 ret->facets = xmlSchemaNewMinLengthFacet(1);
317 ret->flags |= XML_SCHEMAS_TYPE_HAS_FACETS;
320 ret->flags |= XML_SCHEMAS_TYPE_VARIETY_ATOMIC;
324 XML_SCHEMAS_NAMESPACE_NAME,
ret);
335#define UNBOUNDED (1 << 30)
337typedef struct _xmlSchemaTreeItem xmlSchemaTreeItem;
338typedef xmlSchemaTreeItem *xmlSchemaTreeItemPtr;
339struct _xmlSchemaTreeItem {
340 xmlSchemaTypeType
type;
341 xmlSchemaAnnotPtr annot;
342 xmlSchemaTreeItemPtr
next;
343 xmlSchemaTreeItemPtr children;
346typedef struct _xmlSchemaParticle xmlSchemaParticle;
347typedef xmlSchemaParticle *xmlSchemaParticlePtr;
348struct _xmlSchemaParticle {
349 xmlSchemaTypeType
type;
350 xmlSchemaAnnotPtr annot;
351 xmlSchemaTreeItemPtr
next;
352 xmlSchemaTreeItemPtr children;
358typedef struct _xmlSchemaModelGroup xmlSchemaModelGroup;
359typedef xmlSchemaModelGroup *xmlSchemaModelGroupPtr;
360struct _xmlSchemaModelGroup {
361 xmlSchemaTypeType
type;
362 xmlSchemaAnnotPtr annot;
363 xmlSchemaTreeItemPtr
next;
364 xmlSchemaTreeItemPtr children;
368static xmlSchemaParticlePtr
369xmlSchemaAddParticle(
void)
371 xmlSchemaParticlePtr
ret =
NULL;
373 ret = (xmlSchemaParticlePtr)
376 xmlSchemaTypeErrMemory(
NULL,
"allocating particle component");
379 memset(
ret, 0,
sizeof(xmlSchemaParticle));
380 ret->type = XML_SCHEMA_TYPE_PARTICLE;
392xmlSchemaInitTypes(
void)
394 if (xmlSchemaTypesInitialized != 0)
402 xmlSchemaTypeAnyTypeDef = xmlSchemaInitBasicType(
"anyType",
405 xmlSchemaTypeAnyTypeDef->baseType = xmlSchemaTypeAnyTypeDef;
406 xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED;
410 xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED;
412 xmlSchemaParticlePtr particle;
414 xmlSchemaWildcardPtr wild;
416 particle = xmlSchemaAddParticle();
417 if (particle ==
NULL)
419 xmlSchemaTypeAnyTypeDef->subtypes = (xmlSchemaTypePtr) particle;
424 xmlSchemaTypeErrMemory(
NULL,
"allocating model group component");
428 sequence->type = XML_SCHEMA_TYPE_SEQUENCE;
429 particle->children = (xmlSchemaTreeItemPtr)
sequence;
431 particle = xmlSchemaAddParticle();
432 if (particle ==
NULL)
434 particle->minOccurs = 0;
435 particle->maxOccurs = UNBOUNDED;
436 sequence->children = (xmlSchemaTreeItemPtr) particle;
438 wild = (xmlSchemaWildcardPtr)
xmlMalloc(
sizeof(xmlSchemaWildcard));
440 xmlSchemaTypeErrMemory(
NULL,
"allocating wildcard component");
443 memset(wild, 0,
sizeof(xmlSchemaWildcard));
444 wild->type = XML_SCHEMA_TYPE_ANY;
446 wild->processContents = XML_SCHEMAS_ANY_LAX;
447 particle->children = (xmlSchemaTreeItemPtr) wild;
451 wild = (xmlSchemaWildcardPtr)
xmlMalloc(
sizeof(xmlSchemaWildcard));
453 xmlSchemaTypeErrMemory(
NULL,
"could not create an attribute "
454 "wildcard on anyType");
457 memset(wild, 0,
sizeof(xmlSchemaWildcard));
459 wild->processContents = XML_SCHEMAS_ANY_LAX;
460 xmlSchemaTypeAnyTypeDef->attributeWildcard = wild;
462 xmlSchemaTypeAnySimpleTypeDef = xmlSchemaInitBasicType(
"anySimpleType",
463 XML_SCHEMAS_ANYSIMPLETYPE,
464 xmlSchemaTypeAnyTypeDef);
468 xmlSchemaTypeStringDef = xmlSchemaInitBasicType(
"string",
470 xmlSchemaTypeAnySimpleTypeDef);
471 xmlSchemaTypeDecimalDef = xmlSchemaInitBasicType(
"decimal",
473 xmlSchemaTypeAnySimpleTypeDef);
474 xmlSchemaTypeDateDef = xmlSchemaInitBasicType(
"date",
476 xmlSchemaTypeAnySimpleTypeDef);
477 xmlSchemaTypeDatetimeDef = xmlSchemaInitBasicType(
"dateTime",
478 XML_SCHEMAS_DATETIME,
479 xmlSchemaTypeAnySimpleTypeDef);
480 xmlSchemaTypeTimeDef = xmlSchemaInitBasicType(
"time",
482 xmlSchemaTypeAnySimpleTypeDef);
483 xmlSchemaTypeGYearDef = xmlSchemaInitBasicType(
"gYear",
485 xmlSchemaTypeAnySimpleTypeDef);
486 xmlSchemaTypeGYearMonthDef = xmlSchemaInitBasicType(
"gYearMonth",
487 XML_SCHEMAS_GYEARMONTH,
488 xmlSchemaTypeAnySimpleTypeDef);
489 xmlSchemaTypeGMonthDef = xmlSchemaInitBasicType(
"gMonth",
491 xmlSchemaTypeAnySimpleTypeDef);
492 xmlSchemaTypeGMonthDayDef = xmlSchemaInitBasicType(
"gMonthDay",
493 XML_SCHEMAS_GMONTHDAY,
494 xmlSchemaTypeAnySimpleTypeDef);
495 xmlSchemaTypeGDayDef = xmlSchemaInitBasicType(
"gDay",
497 xmlSchemaTypeAnySimpleTypeDef);
498 xmlSchemaTypeDurationDef = xmlSchemaInitBasicType(
"duration",
499 XML_SCHEMAS_DURATION,
500 xmlSchemaTypeAnySimpleTypeDef);
501 xmlSchemaTypeFloatDef = xmlSchemaInitBasicType(
"float",
503 xmlSchemaTypeAnySimpleTypeDef);
504 xmlSchemaTypeDoubleDef = xmlSchemaInitBasicType(
"double",
506 xmlSchemaTypeAnySimpleTypeDef);
507 xmlSchemaTypeBooleanDef = xmlSchemaInitBasicType(
"boolean",
509 xmlSchemaTypeAnySimpleTypeDef);
510 xmlSchemaTypeAnyURIDef = xmlSchemaInitBasicType(
"anyURI",
512 xmlSchemaTypeAnySimpleTypeDef);
513 xmlSchemaTypeHexBinaryDef = xmlSchemaInitBasicType(
"hexBinary",
514 XML_SCHEMAS_HEXBINARY,
515 xmlSchemaTypeAnySimpleTypeDef);
516 xmlSchemaTypeBase64BinaryDef
517 = xmlSchemaInitBasicType(
"base64Binary", XML_SCHEMAS_BASE64BINARY,
518 xmlSchemaTypeAnySimpleTypeDef);
519 xmlSchemaTypeNotationDef = xmlSchemaInitBasicType(
"NOTATION",
520 XML_SCHEMAS_NOTATION,
521 xmlSchemaTypeAnySimpleTypeDef);
522 xmlSchemaTypeQNameDef = xmlSchemaInitBasicType(
"QName",
524 xmlSchemaTypeAnySimpleTypeDef);
529 xmlSchemaTypeIntegerDef = xmlSchemaInitBasicType(
"integer",
531 xmlSchemaTypeDecimalDef);
532 xmlSchemaTypeNonPositiveIntegerDef =
533 xmlSchemaInitBasicType(
"nonPositiveInteger",
534 XML_SCHEMAS_NPINTEGER,
535 xmlSchemaTypeIntegerDef);
536 xmlSchemaTypeNegativeIntegerDef =
537 xmlSchemaInitBasicType(
"negativeInteger", XML_SCHEMAS_NINTEGER,
538 xmlSchemaTypeNonPositiveIntegerDef);
539 xmlSchemaTypeLongDef =
540 xmlSchemaInitBasicType(
"long", XML_SCHEMAS_LONG,
541 xmlSchemaTypeIntegerDef);
542 xmlSchemaTypeIntDef = xmlSchemaInitBasicType(
"int", XML_SCHEMAS_INT,
543 xmlSchemaTypeLongDef);
544 xmlSchemaTypeShortDef = xmlSchemaInitBasicType(
"short",
546 xmlSchemaTypeIntDef);
547 xmlSchemaTypeByteDef = xmlSchemaInitBasicType(
"byte",
549 xmlSchemaTypeShortDef);
550 xmlSchemaTypeNonNegativeIntegerDef =
551 xmlSchemaInitBasicType(
"nonNegativeInteger",
552 XML_SCHEMAS_NNINTEGER,
553 xmlSchemaTypeIntegerDef);
554 xmlSchemaTypeUnsignedLongDef =
555 xmlSchemaInitBasicType(
"unsignedLong", XML_SCHEMAS_ULONG,
556 xmlSchemaTypeNonNegativeIntegerDef);
557 xmlSchemaTypeUnsignedIntDef =
558 xmlSchemaInitBasicType(
"unsignedInt", XML_SCHEMAS_UINT,
559 xmlSchemaTypeUnsignedLongDef);
560 xmlSchemaTypeUnsignedShortDef =
561 xmlSchemaInitBasicType(
"unsignedShort", XML_SCHEMAS_USHORT,
562 xmlSchemaTypeUnsignedIntDef);
563 xmlSchemaTypeUnsignedByteDef =
564 xmlSchemaInitBasicType(
"unsignedByte", XML_SCHEMAS_UBYTE,
565 xmlSchemaTypeUnsignedShortDef);
566 xmlSchemaTypePositiveIntegerDef =
567 xmlSchemaInitBasicType(
"positiveInteger", XML_SCHEMAS_PINTEGER,
568 xmlSchemaTypeNonNegativeIntegerDef);
569 xmlSchemaTypeNormStringDef = xmlSchemaInitBasicType(
"normalizedString",
570 XML_SCHEMAS_NORMSTRING,
571 xmlSchemaTypeStringDef);
572 xmlSchemaTypeTokenDef = xmlSchemaInitBasicType(
"token",
574 xmlSchemaTypeNormStringDef);
575 xmlSchemaTypeLanguageDef = xmlSchemaInitBasicType(
"language",
576 XML_SCHEMAS_LANGUAGE,
577 xmlSchemaTypeTokenDef);
578 xmlSchemaTypeNameDef = xmlSchemaInitBasicType(
"Name",
580 xmlSchemaTypeTokenDef);
581 xmlSchemaTypeNmtokenDef = xmlSchemaInitBasicType(
"NMTOKEN",
583 xmlSchemaTypeTokenDef);
584 xmlSchemaTypeNCNameDef = xmlSchemaInitBasicType(
"NCName",
586 xmlSchemaTypeNameDef);
587 xmlSchemaTypeIdDef = xmlSchemaInitBasicType(
"ID", XML_SCHEMAS_ID,
588 xmlSchemaTypeNCNameDef);
589 xmlSchemaTypeIdrefDef = xmlSchemaInitBasicType(
"IDREF",
591 xmlSchemaTypeNCNameDef);
592 xmlSchemaTypeEntityDef = xmlSchemaInitBasicType(
"ENTITY",
594 xmlSchemaTypeNCNameDef);
599 xmlSchemaTypeEntitiesDef = xmlSchemaInitBasicType(
"ENTITIES",
600 XML_SCHEMAS_ENTITIES,
601 xmlSchemaTypeAnySimpleTypeDef);
602 xmlSchemaTypeEntitiesDef->subtypes = xmlSchemaTypeEntityDef;
604 xmlSchemaTypeIdrefsDef = xmlSchemaInitBasicType(
"IDREFS",
606 xmlSchemaTypeAnySimpleTypeDef);
607 xmlSchemaTypeIdrefsDef->subtypes = xmlSchemaTypeIdrefDef;
610 xmlSchemaTypeNmtokensDef = xmlSchemaInitBasicType(
"NMTOKENS",
611 XML_SCHEMAS_NMTOKENS,
612 xmlSchemaTypeAnySimpleTypeDef);
613 xmlSchemaTypeNmtokensDef->subtypes = xmlSchemaTypeNmtokenDef;
615 xmlSchemaTypesInitialized = 1;
620 xmlSchemaFreeType((xmlSchemaTypePtr)
type);
634xmlSchemaCleanupTypes(
void) {
635 if (xmlSchemaTypesInitialized == 0)
641 xmlSchemaParticlePtr particle;
643 xmlSchemaFreeWildcard(xmlSchemaTypeAnyTypeDef->attributeWildcard);
645 particle = (xmlSchemaParticlePtr) xmlSchemaTypeAnyTypeDef->subtypes;
647 xmlSchemaFreeWildcard((xmlSchemaWildcardPtr)
648 particle->children->children->children);
649 xmlFree((xmlSchemaParticlePtr) particle->children->children);
651 xmlFree((xmlSchemaModelGroupPtr) particle->children);
652 xmlFree((xmlSchemaParticlePtr) particle);
653 xmlSchemaTypeAnyTypeDef->subtypes =
NULL;
655 xmlHashFree(xmlSchemaTypesBank, xmlSchemaFreeTypeEntry);
656 xmlSchemaTypesInitialized = 0;
671xmlSchemaIsBuiltInTypeFacet(xmlSchemaTypePtr
type,
int facetType)
675 if (
type->type != XML_SCHEMA_TYPE_BASIC)
677 switch (
type->builtInType) {
678 case XML_SCHEMAS_BOOLEAN:
679 if ((facetType == XML_SCHEMA_FACET_PATTERN) ||
680 (facetType == XML_SCHEMA_FACET_WHITESPACE))
684 case XML_SCHEMAS_STRING:
685 case XML_SCHEMAS_NOTATION:
686 case XML_SCHEMAS_QNAME:
687 case XML_SCHEMAS_ANYURI:
688 case XML_SCHEMAS_BASE64BINARY:
689 case XML_SCHEMAS_HEXBINARY:
690 if ((facetType == XML_SCHEMA_FACET_LENGTH) ||
691 (facetType == XML_SCHEMA_FACET_MINLENGTH) ||
692 (facetType == XML_SCHEMA_FACET_MAXLENGTH) ||
693 (facetType == XML_SCHEMA_FACET_PATTERN) ||
694 (facetType == XML_SCHEMA_FACET_ENUMERATION) ||
695 (facetType == XML_SCHEMA_FACET_WHITESPACE))
699 case XML_SCHEMAS_DECIMAL:
700 if ((facetType == XML_SCHEMA_FACET_TOTALDIGITS) ||
701 (facetType == XML_SCHEMA_FACET_FRACTIONDIGITS) ||
702 (facetType == XML_SCHEMA_FACET_PATTERN) ||
703 (facetType == XML_SCHEMA_FACET_WHITESPACE) ||
704 (facetType == XML_SCHEMA_FACET_ENUMERATION) ||
705 (facetType == XML_SCHEMA_FACET_MAXINCLUSIVE) ||
706 (facetType == XML_SCHEMA_FACET_MAXEXCLUSIVE) ||
707 (facetType == XML_SCHEMA_FACET_MININCLUSIVE) ||
708 (facetType == XML_SCHEMA_FACET_MINEXCLUSIVE))
712 case XML_SCHEMAS_TIME:
713 case XML_SCHEMAS_GDAY:
714 case XML_SCHEMAS_GMONTH:
715 case XML_SCHEMAS_GMONTHDAY:
716 case XML_SCHEMAS_GYEAR:
717 case XML_SCHEMAS_GYEARMONTH:
718 case XML_SCHEMAS_DATE:
719 case XML_SCHEMAS_DATETIME:
720 case XML_SCHEMAS_DURATION:
721 case XML_SCHEMAS_FLOAT:
722 case XML_SCHEMAS_DOUBLE:
723 if ((facetType == XML_SCHEMA_FACET_PATTERN) ||
724 (facetType == XML_SCHEMA_FACET_ENUMERATION) ||
725 (facetType == XML_SCHEMA_FACET_WHITESPACE) ||
726 (facetType == XML_SCHEMA_FACET_MAXINCLUSIVE) ||
727 (facetType == XML_SCHEMA_FACET_MAXEXCLUSIVE) ||
728 (facetType == XML_SCHEMA_FACET_MININCLUSIVE) ||
729 (facetType == XML_SCHEMA_FACET_MINEXCLUSIVE))
749xmlSchemaGetBuiltInType(xmlSchemaValType
type)
751 if (xmlSchemaTypesInitialized == 0)
752 xmlSchemaInitTypes();
755 case XML_SCHEMAS_ANYSIMPLETYPE:
756 return (xmlSchemaTypeAnySimpleTypeDef);
757 case XML_SCHEMAS_STRING:
758 return (xmlSchemaTypeStringDef);
759 case XML_SCHEMAS_NORMSTRING:
760 return (xmlSchemaTypeNormStringDef);
761 case XML_SCHEMAS_DECIMAL:
762 return (xmlSchemaTypeDecimalDef);
763 case XML_SCHEMAS_TIME:
764 return (xmlSchemaTypeTimeDef);
765 case XML_SCHEMAS_GDAY:
766 return (xmlSchemaTypeGDayDef);
767 case XML_SCHEMAS_GMONTH:
768 return (xmlSchemaTypeGMonthDef);
769 case XML_SCHEMAS_GMONTHDAY:
770 return (xmlSchemaTypeGMonthDayDef);
771 case XML_SCHEMAS_GYEAR:
772 return (xmlSchemaTypeGYearDef);
773 case XML_SCHEMAS_GYEARMONTH:
774 return (xmlSchemaTypeGYearMonthDef);
775 case XML_SCHEMAS_DATE:
776 return (xmlSchemaTypeDateDef);
777 case XML_SCHEMAS_DATETIME:
778 return (xmlSchemaTypeDatetimeDef);
779 case XML_SCHEMAS_DURATION:
780 return (xmlSchemaTypeDurationDef);
781 case XML_SCHEMAS_FLOAT:
782 return (xmlSchemaTypeFloatDef);
783 case XML_SCHEMAS_DOUBLE:
784 return (xmlSchemaTypeDoubleDef);
785 case XML_SCHEMAS_BOOLEAN:
786 return (xmlSchemaTypeBooleanDef);
787 case XML_SCHEMAS_TOKEN:
788 return (xmlSchemaTypeTokenDef);
789 case XML_SCHEMAS_LANGUAGE:
790 return (xmlSchemaTypeLanguageDef);
791 case XML_SCHEMAS_NMTOKEN:
792 return (xmlSchemaTypeNmtokenDef);
793 case XML_SCHEMAS_NMTOKENS:
794 return (xmlSchemaTypeNmtokensDef);
795 case XML_SCHEMAS_NAME:
796 return (xmlSchemaTypeNameDef);
797 case XML_SCHEMAS_QNAME:
798 return (xmlSchemaTypeQNameDef);
799 case XML_SCHEMAS_NCNAME:
800 return (xmlSchemaTypeNCNameDef);
802 return (xmlSchemaTypeIdDef);
803 case XML_SCHEMAS_IDREF:
804 return (xmlSchemaTypeIdrefDef);
805 case XML_SCHEMAS_IDREFS:
806 return (xmlSchemaTypeIdrefsDef);
807 case XML_SCHEMAS_ENTITY:
808 return (xmlSchemaTypeEntityDef);
809 case XML_SCHEMAS_ENTITIES:
810 return (xmlSchemaTypeEntitiesDef);
811 case XML_SCHEMAS_NOTATION:
812 return (xmlSchemaTypeNotationDef);
813 case XML_SCHEMAS_ANYURI:
814 return (xmlSchemaTypeAnyURIDef);
815 case XML_SCHEMAS_INTEGER:
816 return (xmlSchemaTypeIntegerDef);
817 case XML_SCHEMAS_NPINTEGER:
818 return (xmlSchemaTypeNonPositiveIntegerDef);
819 case XML_SCHEMAS_NINTEGER:
820 return (xmlSchemaTypeNegativeIntegerDef);
821 case XML_SCHEMAS_NNINTEGER:
822 return (xmlSchemaTypeNonNegativeIntegerDef);
823 case XML_SCHEMAS_PINTEGER:
824 return (xmlSchemaTypePositiveIntegerDef);
825 case XML_SCHEMAS_INT:
826 return (xmlSchemaTypeIntDef);
827 case XML_SCHEMAS_UINT:
828 return (xmlSchemaTypeUnsignedIntDef);
829 case XML_SCHEMAS_LONG:
830 return (xmlSchemaTypeLongDef);
831 case XML_SCHEMAS_ULONG:
832 return (xmlSchemaTypeUnsignedLongDef);
833 case XML_SCHEMAS_SHORT:
834 return (xmlSchemaTypeShortDef);
835 case XML_SCHEMAS_USHORT:
836 return (xmlSchemaTypeUnsignedShortDef);
837 case XML_SCHEMAS_BYTE:
838 return (xmlSchemaTypeByteDef);
839 case XML_SCHEMAS_UBYTE:
840 return (xmlSchemaTypeUnsignedByteDef);
841 case XML_SCHEMAS_HEXBINARY:
842 return (xmlSchemaTypeHexBinaryDef);
843 case XML_SCHEMAS_BASE64BINARY:
844 return (xmlSchemaTypeBase64BinaryDef);
845 case XML_SCHEMAS_ANYTYPE:
846 return (xmlSchemaTypeAnyTypeDef);
862xmlSchemaValueAppend(xmlSchemaValPtr prev, xmlSchemaValPtr
cur) {
880xmlSchemaValueGetNext(xmlSchemaValPtr
cur) {
897xmlSchemaValueGetAsString(xmlSchemaValPtr
val)
902 case XML_SCHEMAS_STRING:
903 case XML_SCHEMAS_NORMSTRING:
904 case XML_SCHEMAS_ANYSIMPLETYPE:
905 case XML_SCHEMAS_TOKEN:
906 case XML_SCHEMAS_LANGUAGE:
907 case XML_SCHEMAS_NMTOKEN:
908 case XML_SCHEMAS_NAME:
909 case XML_SCHEMAS_NCNAME:
911 case XML_SCHEMAS_IDREF:
912 case XML_SCHEMAS_ENTITY:
913 case XML_SCHEMAS_ANYURI:
930xmlSchemaValueGetAsBoolean(xmlSchemaValPtr
val)
932 if ((
val ==
NULL) || (
val->type != XML_SCHEMAS_BOOLEAN))
934 return (
val->value.b);
951xmlSchemaNewStringValue(xmlSchemaValType
type,
956 if (
type != XML_SCHEMAS_STRING)
958 val = (xmlSchemaValPtr)
xmlMalloc(
sizeof(xmlSchemaVal));
984 val = xmlSchemaNewValue(XML_SCHEMAS_NOTATION);
1005xmlSchemaNewQNameValue(
const xmlChar *namespaceName,
1008 xmlSchemaValPtr
val;
1010 val = xmlSchemaNewValue(XML_SCHEMAS_QNAME);
1014 val->value.qname.name = (
xmlChar *) localName;
1015 val->value.qname.uri = (
xmlChar *) namespaceName;
1026xmlSchemaFreeValue(xmlSchemaValPtr
value) {
1027 xmlSchemaValPtr prev;
1030 switch (
value->type) {
1031 case XML_SCHEMAS_STRING:
1032 case XML_SCHEMAS_NORMSTRING:
1033 case XML_SCHEMAS_TOKEN:
1034 case XML_SCHEMAS_LANGUAGE:
1035 case XML_SCHEMAS_NMTOKEN:
1036 case XML_SCHEMAS_NMTOKENS:
1037 case XML_SCHEMAS_NAME:
1038 case XML_SCHEMAS_NCNAME:
1039 case XML_SCHEMAS_ID:
1040 case XML_SCHEMAS_IDREF:
1041 case XML_SCHEMAS_IDREFS:
1042 case XML_SCHEMAS_ENTITY:
1043 case XML_SCHEMAS_ENTITIES:
1044 case XML_SCHEMAS_ANYURI:
1045 case XML_SCHEMAS_ANYSIMPLETYPE:
1049 case XML_SCHEMAS_NOTATION:
1050 case XML_SCHEMAS_QNAME:
1056 case XML_SCHEMAS_HEXBINARY:
1060 case XML_SCHEMAS_BASE64BINARY:
1084 if (xmlSchemaTypesInitialized == 0)
1085 xmlSchemaInitTypes();
1101xmlSchemaGetBuiltInListSimpleTypeItemType(xmlSchemaTypePtr
type)
1103 if ((
type ==
NULL) || (
type->type != XML_SCHEMA_TYPE_BASIC))
1105 switch (
type->builtInType) {
1106 case XML_SCHEMAS_NMTOKENS:
1107 return (xmlSchemaTypeNmtokenDef );
1108 case XML_SCHEMAS_IDREFS:
1109 return (xmlSchemaTypeIdrefDef);
1110 case XML_SCHEMAS_ENTITIES:
1111 return (xmlSchemaTypeEntityDef);
1123#define IS_TZO_CHAR(c) \
1124 ((c == 0) || (c == 'Z') || (c == '+') || (c == '-'))
1126#define VALID_YEAR(yr) (yr != 0)
1127#define VALID_MONTH(mon) ((mon >= 1) && (mon <= 12))
1129#define VALID_DAY(day) ((day >= 1) && (day <= 31))
1130#define VALID_HOUR(hr) ((hr >= 0) && (hr <= 23))
1131#define VALID_MIN(min) ((min >= 0) && (min <= 59))
1132#define VALID_SEC(sec) ((sec >= 0) && (sec < 60))
1133#define VALID_TZO(tzo) ((tzo >= -840) && (tzo <= 840))
1135 (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0))
1137static const unsigned int daysInMonth[12] =
1138 { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
1139static const unsigned int daysInMonthLeap[12] =
1140 { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
1142#define MAX_DAYINMONTH(yr,mon) \
1143 (IS_LEAP(yr) ? daysInMonthLeap[mon - 1] : daysInMonth[mon - 1])
1145#define VALID_MDAY(dt) \
1146 (IS_LEAP(dt->year) ? \
1147 (dt->day <= daysInMonthLeap[dt->mon - 1]) : \
1148 (dt->day <= daysInMonth[dt->mon - 1]))
1150#define VALID_DATE(dt) \
1151 (VALID_YEAR(dt->year) && VALID_MONTH(dt->mon) && VALID_MDAY(dt))
1153#define VALID_END_OF_DAY(dt) \
1154 ((dt)->hour == 24 && (dt)->min == 0 && (dt)->sec == 0)
1156#define VALID_TIME(dt) \
1157 (((VALID_HOUR(dt->hour) && VALID_MIN(dt->min) && \
1158 VALID_SEC(dt->sec)) || VALID_END_OF_DAY(dt)) && \
1161#define VALID_DATETIME(dt) \
1162 (VALID_DATE(dt) && VALID_TIME(dt))
1164#define SECS_PER_MIN 60
1165#define MINS_PER_HOUR 60
1166#define HOURS_PER_DAY 24
1167#define SECS_PER_HOUR (MINS_PER_HOUR * SECS_PER_MIN)
1168#define SECS_PER_DAY (HOURS_PER_DAY * SECS_PER_HOUR)
1169#define MINS_PER_DAY (HOURS_PER_DAY * MINS_PER_HOUR)
1171static const long dayInYearByMonth[12] =
1172 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
1173static const long dayInLeapYearByMonth[12] =
1174 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 };
1176#define DAY_IN_YEAR(day, month, year) \
1178 dayInLeapYearByMonth[month - 1] : \
1179 dayInYearByMonth[month - 1]) + day)
1182#define DEBUG_DATE(dt) \
1183 xmlGenericError(xmlGenericErrorContext, \
1184 "type=%o %04ld-%02u-%02uT%02u:%02u:%03f", \
1185 dt->type,dt->value.date.year,dt->value.date.mon, \
1186 dt->value.date.day,dt->value.date.hour,dt->value.date.min, \
1187 dt->value.date.sec); \
1188 if (dt->value.date.tz_flag) \
1189 if (dt->value.date.tzo != 0) \
1190 xmlGenericError(xmlGenericErrorContext, \
1191 "%+05d\n",dt->value.date.tzo); \
1193 xmlGenericError(xmlGenericErrorContext, "Z\n"); \
1195 xmlGenericError(xmlGenericErrorContext,"\n")
1197#define DEBUG_DATE(dt)
1213_xmlSchemaParseGYear (xmlSchemaValDatePtr dt,
const xmlChar **
str) {
1215 int isneg = 0, digcnt = 0;
1217 if (((*
cur <
'0') || (*
cur >
'9')) &&
1218 (*
cur !=
'-') && (*
cur !=
'+'))
1228 while ((*
cur >=
'0') && (*
cur <=
'9')) {
1229 int digit = *
cur -
'0';
1243 if ((digcnt < 4) || ((digcnt > 4) && (*firstChar ==
'0')))
1247 dt->year = - dt->year;
1249 if (!VALID_YEAR(dt->year))
1267#define PARSE_2_DIGITS(num, cur, invalid) \
1268 if ((cur[0] < '0') || (cur[0] > '9') || \
1269 (cur[1] < '0') || (cur[1] > '9')) \
1272 num = (cur[0] - '0') * 10 + (cur[1] - '0'); \
1287#define PARSE_FLOAT(num, cur, invalid) \
1288 PARSE_2_DIGITS(num, cur, invalid); \
1289 if (!invalid && (*cur == '.')) { \
1292 if ((*cur < '0') || (*cur > '9')) \
1294 while ((*cur >= '0') && (*cur <= '9')) { \
1296 num += (*cur - '0') * mult; \
1313_xmlSchemaParseGMonth (xmlSchemaValDatePtr dt,
const xmlChar **
str) {
1316 unsigned int value = 0;
1322 if (!VALID_MONTH(
value))
1343_xmlSchemaParseGDay (xmlSchemaValDatePtr dt,
const xmlChar **
str) {
1346 unsigned int value = 0;
1352 if (!VALID_DAY(
value))
1373_xmlSchemaParseTime (xmlSchemaValDatePtr dt,
const xmlChar **
str) {
1393 if (!VALID_MIN(
value))
1401 PARSE_FLOAT(dt->sec,
cur,
ret);
1405 if (!VALID_TIME(dt))
1424_xmlSchemaParseTimeZone (xmlSchemaValDatePtr dt,
const xmlChar **
str) {
1446 int isneg = 0, tmp = 0;
1447 isneg = (*
cur ==
'-');
1451 PARSE_2_DIGITS(tmp,
cur,
ret);
1454 if (!VALID_HOUR(tmp))
1463 PARSE_2_DIGITS(tmp,
cur,
ret);
1466 if (!VALID_MIN(tmp))
1471 dt->tzo = - dt->tzo;
1473 if (!VALID_TZO(dt->tzo))
1496_xmlSchemaBase64Decode (
const xmlChar ch) {
1497 if ((
'A' <= ch) && (ch <=
'Z'))
return ch -
'A';
1498 if ((
'a' <= ch) && (ch <=
'z'))
return ch -
'a' + 26;
1499 if ((
'0' <= ch) && (ch <=
'9'))
return ch -
'0' + 52;
1500 if (
'+' == ch)
return 62;
1501 if (
'/' == ch)
return 63;
1502 if (
'=' == ch)
return 64;
1523#define PARSE_DIGITS(num, cur, num_type) \
1524 if ((*cur < '0') || (*cur > '9')) \
1527 while ((*cur >= '0') && (*cur <= '9')) { \
1528 num = num * 10 + (*cur - '0'); \
1545#define PARSE_NUM(num, cur, num_type) \
1547 PARSE_DIGITS(num, cur, num_type); \
1548 if (!num_type && (*cur == '.')) { \
1551 if ((*cur < '0') || (*cur > '9')) \
1555 while ((*cur >= '0') && (*cur <= '9')) { \
1557 num += (*cur - '0') * mult; \
1575xmlSchemaValidateDates (xmlSchemaValType
type,
1576 const xmlChar *dateTime, xmlSchemaValPtr *
val,
1582#define RETURN_TYPE_IF_VALID(t) \
1583 if (IS_TZO_CHAR(*cur)) { \
1584 ret = _xmlSchemaParseTimeZone(&(dt->value.date), &cur); \
1593 if (dateTime ==
NULL)
1597 while IS_WSP_BLANK_CH(*
cur)
cur++;
1599 if ((*
cur !=
'-') && (*
cur <
'0') && (*
cur >
'9'))
1602 dt = xmlSchemaNewValue(XML_SCHEMAS_UNKNOWN);
1606 if ((
cur[0] ==
'-') && (
cur[1] ==
'-')) {
1615 if (
type == XML_SCHEMAS_GMONTH)
1618 ret = _xmlSchemaParseGDay(&(dt->value.date), &
cur);
1622 RETURN_TYPE_IF_VALID(XML_SCHEMAS_GDAY);
1630 ret = _xmlSchemaParseGMonth(&(dt->value.date), &
cur);
1646 ret = _xmlSchemaParseGDay(&(dt->value.date), &
cur);
1647 if ((
ret == 0) && ((*
cur == 0) || (*
cur !=
':'))) {
1656 if (VALID_MDAY((&(dt->value.date)))) {
1658 RETURN_TYPE_IF_VALID(XML_SCHEMAS_GMONTHDAY);
1671 RETURN_TYPE_IF_VALID(XML_SCHEMAS_GMONTH);
1680 if ((*
cur >=
'0') && (*
cur <=
'9')) {
1681 ret = _xmlSchemaParseTime(&(dt->value.date), &
cur);
1684 RETURN_TYPE_IF_VALID(XML_SCHEMAS_TIME);
1691 ret = _xmlSchemaParseGYear(&(dt->value.date), &
cur);
1696 RETURN_TYPE_IF_VALID(XML_SCHEMAS_GYEAR);
1702 ret = _xmlSchemaParseGMonth(&(dt->value.date), &
cur);
1707 RETURN_TYPE_IF_VALID(XML_SCHEMAS_GYEARMONTH);
1713 ret = _xmlSchemaParseGDay(&(dt->value.date), &
cur);
1714 if ((
ret != 0) || !VALID_DATE((&(dt->value.date))))
1718 RETURN_TYPE_IF_VALID(XML_SCHEMAS_DATE);
1725 ret = _xmlSchemaParseTime(&(dt->value.date), &
cur);
1729 ret = _xmlSchemaParseTimeZone(&(dt->value.date), &
cur);
1731 while IS_WSP_BLANK_CH(*
cur)
cur++;
1732 if ((
ret != 0) || (*
cur != 0) || (!(VALID_DATETIME((&(dt->value.date))))))
1736 dt->type = XML_SCHEMAS_DATETIME;
1740 if ((
type != XML_SCHEMAS_UNKNOWN) && (
type != dt->type))
1747 if ((
type != XML_SCHEMAS_UNKNOWN) && (
type != dt->type)) {
1750 if ((
type == XML_SCHEMAS_TIME) && (dt->type == XML_SCHEMAS_TIME))
1753 if ((
type == XML_SCHEMAS_DATETIME) &&
1754 ((dt->type != XML_SCHEMAS_DATE) ||
1755 (dt->type != XML_SCHEMAS_GYEARMONTH) ||
1756 (dt->type != XML_SCHEMAS_GYEAR)))
1759 if ((
type == XML_SCHEMAS_DATE) &&
1760 ((dt->type != XML_SCHEMAS_GYEAR) ||
1761 (dt->type != XML_SCHEMAS_GYEARMONTH)))
1764 if ((
type == XML_SCHEMAS_GYEARMONTH) && (dt->type != XML_SCHEMAS_GYEAR))
1767 if ((
type == XML_SCHEMAS_GMONTHDAY) && (dt->type != XML_SCHEMAS_GMONTH))
1775 xmlSchemaFreeValue(dt);
1781 xmlSchemaFreeValue(dt);
1799 const xmlChar *duration, xmlSchemaValPtr *
val,
1802 xmlSchemaValPtr dur;
1804 unsigned int seq = 0;
1805 long days, secs = 0;
1806 double sec_frac = 0.0;
1808 if (duration ==
NULL)
1812 while IS_WSP_BLANK_CH(*
cur)
cur++;
1826 dur = xmlSchemaNewValue(XML_SCHEMAS_DURATION);
1832 size_t has_digits = 0;
1834 const xmlChar desig[] = {
'Y',
'M',
'D',
'H',
'M',
'S'};
1837 if (seq >=
sizeof(desig))
1846 }
else if (seq == 3)
1850 while (*
cur >=
'0' && *
cur <=
'9') {
1851 long digit = *
cur -
'0';
1869 while (*
cur >=
'0' && *
cur <=
'9') {
1871 sec_frac += (*
cur -
'0') * mult;
1877 while (*
cur != desig[seq]) {
1880 if (seq == 3 || seq ==
sizeof(desig))
1885 if (!has_digits || (has_frac && (seq != 5)))
1903 dur->value.dur.day =
num;
1908 if (dur->value.dur.day >
LONG_MAX - days)
1910 dur->
value.dur.day += days;
1915 days =
num / MINS_PER_DAY;
1916 if (dur->value.dur.day >
LONG_MAX - days)
1918 dur->
value.dur.day += days;
1919 secs += (
num % MINS_PER_DAY) * SECS_PER_MIN;
1923 days =
num / SECS_PER_DAY;
1924 if (dur->value.dur.day >
LONG_MAX - days)
1926 dur->
value.dur.day += days;
1927 secs +=
num % SECS_PER_DAY;
1934 days = secs / SECS_PER_DAY;
1935 if (dur->value.dur.day >
LONG_MAX - days)
1937 dur->
value.dur.day += days;
1938 dur->value.dur.sec = (secs % SECS_PER_DAY) + sec_frac;
1941 dur->value.dur.mon = -dur->value.dur.mon;
1942 dur->value.dur.day = -dur->value.dur.day;
1943 dur->value.dur.sec = -dur->value.dur.sec;
1949 xmlSchemaFreeValue(dur);
1955 xmlSchemaFreeValue(dur);
1999 while ((*
cur != 0) &&
2000 (((*
cur) != 0xd) && ((*
cur) != 0x9) && ((*
cur) != 0xa))) {
2009 if ( ((*mcur) == 0xd) || ((*mcur) == 0x9) || ((*mcur) == 0xa) )
2012 }
while (*mcur != 0);
2037 }
else if ((*
end == 0xa) || (*
end == 0x9) || (*
end == 0xd)) {
2114 if (nb_values == 0) {
2120 while ((*
cur == 0) && (
cur != endval))
cur++;
2121 while (
cur != endval) {
2126 while ((*
cur == 0) && (
cur != endval))
cur++;
2151xmlSchemaParseUInt(
const xmlChar **
str,
unsigned long *llo,
2152 unsigned long *lmi,
unsigned long *lhi) {
2153 unsigned long lo = 0,
mi = 0, hi = 0;
2157 if (!((*
cur >=
'0') && (*
cur <=
'9')))
2160 while (*
cur ==
'0') {
2164 while ((*tmp != 0) && (*tmp >=
'0') && (*tmp <=
'9')) {
2172 hi = hi * 10 + (*
cur++ -
'0');
2176 mi =
mi * 10 + (*
cur++ -
'0');
2180 lo = lo * 10 + (*
cur++ -
'0');
2208 while (
cur[0] != 0) {
2209 if (!( ((
cur[0] >=
'a') && (
cur[0] <=
'z')) || ((
cur[0] >=
'A') && (
cur[0] <=
'Z'))
2213 if (
cur[0] ==
'-') {
2214 if ((
len < 1) || (
len > 8))
2223 if ((
len < 1) || (
len > 8))
2247 xmlSchemaWhitespaceValueType ws,
2248 int normOnTheFly,
int applyNorm,
int createStringValue)
2254 if (xmlSchemaTypesInitialized == 0)
2255 xmlSchemaInitTypes();
2270 if ((
type->builtInType != XML_SCHEMAS_STRING) &&
2271 (
type->builtInType != XML_SCHEMAS_ANYTYPE) &&
2272 (
type->builtInType != XML_SCHEMAS_ANYSIMPLETYPE)) {
2273 if (
type->builtInType == XML_SCHEMAS_NORMSTRING)
2274 norm = xmlSchemaWhiteSpaceReplace(
value);
2282 switch (
type->builtInType) {
2283 case XML_SCHEMAS_UNKNOWN:
2285 case XML_SCHEMAS_ANYTYPE:
2286 case XML_SCHEMAS_ANYSIMPLETYPE:
2287 if ((createStringValue) && (
val !=
NULL)) {
2288 v = xmlSchemaNewValue(XML_SCHEMAS_ANYSIMPLETYPE);
2297 case XML_SCHEMAS_STRING:
2298 if (! normOnTheFly) {
2301 if (ws == XML_SCHEMA_WHITESPACE_REPLACE) {
2303 if ((*
cur == 0xd) || (*
cur == 0xa) || (*
cur == 0x9)) {
2309 }
else if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) {
2311 if ((*
cur == 0xd) || (*
cur == 0xa) || (*
cur == 0x9)) {
2313 }
else if IS_WSP_SPACE_CH(*
cur) {
2315 if IS_WSP_SPACE_CH(*
cur)
2323 if (createStringValue && (
val !=
NULL)) {
2325 if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE)
2327 else if (ws == XML_SCHEMA_WHITESPACE_REPLACE)
2328 norm = xmlSchemaWhiteSpaceReplace(
value);
2332 v = xmlSchemaNewValue(XML_SCHEMAS_STRING);
2341 case XML_SCHEMAS_NORMSTRING:{
2344 if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE)
2347 norm = xmlSchemaWhiteSpaceReplace(
value);
2354 if ((*
cur == 0xd) || (*
cur == 0xa) || (*
cur == 0x9)) {
2362 v = xmlSchemaNewValue(XML_SCHEMAS_NORMSTRING);
2372 case XML_SCHEMAS_DECIMAL:{
2374 unsigned int len, neg, integ, hasLeadingZeroes;
2385 while IS_WSP_BLANK_CH(*
cur)
cur++;
2394 }
else if (*
cur ==
'+')
2409 hasLeadingZeroes = 0;
2413 while (*
cur ==
'0') {
2415 hasLeadingZeroes = 1;
2419 if ((*
cur >=
'0') && (*
cur <=
'9')) {
2422 }
else if (*
cur ==
'.') {
2426 if ((*
cur >=
'0') && (*
cur <=
'9')) {
2435 if ((
len == 0) && (!hasLeadingZeroes))
2443 while IS_WSP_BLANK_CH(*
cur)
cur++;
2447 v = xmlSchemaNewValue(XML_SCHEMAS_DECIMAL);
2459 while ((
len != integ) && (*(cptr-1) ==
'0')) {
2471 xmlSchemaParseUInt((
const xmlChar **)&cptr,
2472 &
v->value.decimal.lo,
2473 &
v->value.decimal.mi,
2474 &
v->value.decimal.hi);
2480 v->value.decimal.sign = neg;
2483 v->value.decimal.total = 1;
2485 v->value.decimal.total =
len;
2487 v->value.decimal.frac = 0;
2489 v->value.decimal.frac =
len - integ;
2496 case XML_SCHEMAS_TIME:
2497 case XML_SCHEMAS_GDAY:
2498 case XML_SCHEMAS_GMONTH:
2499 case XML_SCHEMAS_GMONTHDAY:
2500 case XML_SCHEMAS_GYEAR:
2501 case XML_SCHEMAS_GYEARMONTH:
2502 case XML_SCHEMAS_DATE:
2503 case XML_SCHEMAS_DATETIME:
2507 case XML_SCHEMAS_DURATION:
2511 case XML_SCHEMAS_FLOAT:
2512 case XML_SCHEMAS_DOUBLE: {
2515 int digits_before = 0;
2516 int digits_after = 0;
2519 while IS_WSP_BLANK_CH(*
cur)
cur++;
2521 if ((
cur[0] ==
'N') && (
cur[1] ==
'a') && (
cur[2] ==
'N')) {
2526 if (
type == xmlSchemaTypeFloatDef) {
2527 v = xmlSchemaNewValue(XML_SCHEMAS_FLOAT);
2529 v->value.f = (
float) xmlXPathNAN;
2531 xmlSchemaFreeValue(
v);
2535 v = xmlSchemaNewValue(XML_SCHEMAS_DOUBLE);
2537 v->value.d = xmlXPathNAN;
2539 xmlSchemaFreeValue(
v);
2551 if ((
cur[0] ==
'I') && (
cur[1] ==
'N') && (
cur[2] ==
'F')) {
2556 if (
type == xmlSchemaTypeFloatDef) {
2557 v = xmlSchemaNewValue(XML_SCHEMAS_FLOAT);
2560 v->value.f = (
float) xmlXPathNINF;
2562 v->value.f = (
float) xmlXPathPINF;
2564 xmlSchemaFreeValue(
v);
2568 v = xmlSchemaNewValue(XML_SCHEMAS_DOUBLE);
2571 v->value.d = xmlXPathNINF;
2573 v->value.d = xmlXPathPINF;
2575 xmlSchemaFreeValue(
v);
2583 if ((neg == 0) && (*
cur ==
'+'))
2585 if ((
cur[0] == 0) || (
cur[0] ==
'+') || (
cur[0] ==
'-'))
2587 while ((*
cur >=
'0') && (*
cur <=
'9')) {
2593 while ((*
cur >=
'0') && (*
cur <=
'9')) {
2598 if ((digits_before == 0) && (digits_after == 0))
2600 if ((*
cur ==
'e') || (*
cur ==
'E')) {
2602 if ((*
cur ==
'-') || (*
cur ==
'+'))
2604 while ((*
cur >=
'0') && (*
cur <=
'9'))
2608 while IS_WSP_BLANK_CH(*
cur)
cur++;
2613 if (
type == xmlSchemaTypeFloatDef) {
2614 v = xmlSchemaNewValue(XML_SCHEMAS_FLOAT);
2622 &(
v->value.f)) == 1) {
2625 xmlSchemaFreeValue(
v);
2632 v = xmlSchemaNewValue(XML_SCHEMAS_DOUBLE);
2639 &(
v->value.d)) == 1) {
2642 xmlSchemaFreeValue(
v);
2652 case XML_SCHEMAS_BOOLEAN:{
2656 while IS_WSP_BLANK_CH(*
cur)
cur++;
2660 }
else if (*
cur ==
'1') {
2663 }
else if (*
cur ==
't') {
2665 if ((*
cur++ ==
'r') && (*
cur++ ==
'u') &&
2670 }
else if (*
cur ==
'f') {
2672 if ((*
cur++ ==
'a') && (*
cur++ ==
'l') &&
2673 (*
cur++ ==
's') && (*
cur++ ==
'e')) {
2680 while IS_WSP_BLANK_CH(*
cur)
cur++;
2685 if ((
cur[0] ==
'0') && (
cur[1] == 0))
2687 else if ((
cur[0] ==
'1') && (
cur[1] == 0))
2689 else if ((
cur[0] ==
't') && (
cur[1] ==
'r')
2690 && (
cur[2] ==
'u') && (
cur[3] ==
'e')
2693 else if ((
cur[0] ==
'f') && (
cur[1] ==
'a')
2694 && (
cur[2] ==
'l') && (
cur[3] ==
's')
2695 && (
cur[4] ==
'e') && (
cur[5] == 0))
2701 v = xmlSchemaNewValue(XML_SCHEMAS_BOOLEAN);
2711 case XML_SCHEMAS_TOKEN:{
2714 if (! normOnTheFly) {
2716 if ((*
cur == 0xd) || (*
cur == 0xa) || (*
cur == 0x9)) {
2718 }
else if (*
cur ==
' ') {
2730 v = xmlSchemaNewValue(XML_SCHEMAS_TOKEN);
2740 case XML_SCHEMAS_LANGUAGE:
2741 if ((
norm ==
NULL) && (normOnTheFly)) {
2747 if (xmlSchemaCheckLanguageType(
value) == 1) {
2749 v = xmlSchemaNewValue(XML_SCHEMAS_LANGUAGE);
2760 case XML_SCHEMAS_NMTOKEN:
2761 if (xmlValidateNMToken(
value, 1) == 0) {
2763 v = xmlSchemaNewValue(XML_SCHEMAS_NMTOKEN);
2774 case XML_SCHEMAS_NMTOKENS:
2775 ret = xmlSchemaValAtomicListNode(xmlSchemaTypeNmtokenDef,
2782 case XML_SCHEMAS_NAME:
2785 v = xmlSchemaNewValue(XML_SCHEMAS_NAME);
2798 case XML_SCHEMAS_QNAME:{
2823 v = xmlSchemaNewValue(XML_SCHEMAS_QNAME);
2841 case XML_SCHEMAS_NCNAME:
2844 v = xmlSchemaNewValue(XML_SCHEMAS_NCNAME);
2853 case XML_SCHEMAS_ID:
2856 v = xmlSchemaNewValue(XML_SCHEMAS_ID);
2875 strip = xmlSchemaStrip(
value);
2876 if (strip !=
NULL) {
2889 case XML_SCHEMAS_IDREF:
2892 v = xmlSchemaNewValue(XML_SCHEMAS_IDREF);
2903 strip = xmlSchemaStrip(
value);
2904 if (strip !=
NULL) {
2912 case XML_SCHEMAS_IDREFS:
2913 ret = xmlSchemaValAtomicListNode(xmlSchemaTypeIdrefDef,
2926 case XML_SCHEMAS_ENTITY:{
2935 strip = xmlSchemaStrip(
value);
2936 if (strip !=
NULL) {
2942 if ((ent ==
NULL) ||
2958 case XML_SCHEMAS_ENTITIES:
2961 ret = xmlSchemaValAtomicListNode(xmlSchemaTypeEntityDef,
2974 case XML_SCHEMAS_NOTATION:{
2983 if (prefix !=
NULL) {
3007 v = xmlSchemaNewValue(XML_SCHEMAS_NOTATION);
3010 v->value.qname.name =
local;
3014 v->value.qname.uri =
uri;
3027 case XML_SCHEMAS_ANYURI:{
3031 if ((
norm ==
NULL) && (normOnTheFly)) {
3038 if (*cur < 32 || *cur >= 127 || *
cur ==
' ' ||
3039 *
cur ==
'<' || *
cur ==
'>' || *
cur ==
'"' ||
3040 *
cur ==
'{' || *
cur ==
'}' || *
cur ==
'|' ||
3041 *
cur ==
'\\' || *
cur ==
'^' || *
cur ==
'`' ||
3053 v = xmlSchemaNewValue(XML_SCHEMAS_ANYURI);
3061 case XML_SCHEMAS_HEXBINARY:{
3070 while IS_WSP_BLANK_CH(*
cur)
cur++;
3073 while (((*
cur >=
'0') && (*
cur <=
'9')) ||
3074 ((*
cur >=
'A') && (*
cur <=
'F')) ||
3075 ((*
cur >=
'a') && (*
cur <=
'f'))) {
3080 while IS_WSP_BLANK_CH(*
cur)
cur++;
3089 v = xmlSchemaNewValue(XML_SCHEMAS_HEXBINARY);
3098 xmlSchemaTypeErrMemory(
node,
"allocating hexbin data");
3113 v->value.hex.total =
total;
3118 case XML_SCHEMAS_BASE64BINARY:{
3136 int total,
i = 0, pad = 0;
3144 decc = _xmlSchemaBase64Decode(*
cur);
3154 decc = _xmlSchemaBase64Decode(*
cur);
3187 }
else if (pad == 1) {
3192 for (decc = _xmlSchemaBase64Decode(*
cur);
3193 (decc < 0) || (decc > 63);
3194 decc = _xmlSchemaBase64Decode(*
cur))
3201 }
else if (pad == 2) {
3206 for (decc = _xmlSchemaBase64Decode(*
cur);
3207 (decc < 0) || (decc > 63);
3208 decc = _xmlSchemaBase64Decode(*
cur))
3219 v = xmlSchemaNewValue(XML_SCHEMAS_BASE64BINARY);
3226 xmlSchemaTypeErrMemory(
node,
"allocating base64 data");
3230 v->value.base64.str =
base;
3232 if (_xmlSchemaBase64Decode(*
cur) >= 0) {
3237 v->value.base64.total =
total;
3242 case XML_SCHEMAS_INTEGER:
3243 case XML_SCHEMAS_PINTEGER:
3244 case XML_SCHEMAS_NPINTEGER:
3245 case XML_SCHEMAS_NINTEGER:
3246 case XML_SCHEMAS_NNINTEGER:{
3248 unsigned long lo,
mi, hi;
3254 while IS_WSP_BLANK_CH(*
cur)
cur++;
3258 }
else if (*
cur ==
'+')
3260 ret = xmlSchemaParseUInt(&
cur, &lo, &
mi, &hi);
3264 while IS_WSP_BLANK_CH(*
cur)
cur++;
3267 if (
type->builtInType == XML_SCHEMAS_NPINTEGER) {
3269 ((hi != 0) || (
mi != 0) || (lo != 0)))
3271 }
else if (
type->builtInType == XML_SCHEMAS_PINTEGER) {
3274 if ((hi == 0) && (
mi == 0) && (lo == 0))
3276 }
else if (
type->builtInType == XML_SCHEMAS_NINTEGER) {
3279 if ((hi == 0) && (
mi == 0) && (lo == 0))
3281 }
else if (
type->builtInType == XML_SCHEMAS_NNINTEGER) {
3283 ((hi != 0) || (
mi != 0) || (lo != 0)))
3287 v = xmlSchemaNewValue(
type->builtInType);
3291 v->value.decimal.lo = lo;
3292 v->value.decimal.mi =
mi;
3293 v->value.decimal.hi = hi;
3294 v->value.decimal.sign =
sign;
3295 v->
value.decimal.frac = 0;
3296 v->value.decimal.total =
ret;
3302 case XML_SCHEMAS_LONG:
3303 case XML_SCHEMAS_BYTE:
3304 case XML_SCHEMAS_SHORT:
3305 case XML_SCHEMAS_INT:{
3307 unsigned long lo,
mi, hi;
3313 while IS_WSP_BLANK_CH(*
cur)
cur++;
3317 }
else if (*
cur ==
'+')
3319 ret = xmlSchemaParseUInt(&
cur, &lo, &
mi, &hi);
3323 while IS_WSP_BLANK_CH(*
cur)
cur++;
3326 if (
type->builtInType == XML_SCHEMAS_LONG) {
3330 if (
mi >= 33720368) {
3333 if ((
sign == 0) && (lo > 54775807))
3335 if ((
sign == 1) && (lo > 54775808))
3339 }
else if (
type->builtInType == XML_SCHEMAS_INT) {
3345 if ((
sign == 0) && (lo > 47483647))
3347 if ((
sign == 1) && (lo > 47483648))
3350 }
else if (
type->builtInType == XML_SCHEMAS_SHORT) {
3351 if ((
mi != 0) || (hi != 0))
3353 if ((
sign == 1) && (lo > 32768))
3355 if ((
sign == 0) && (lo > 32767))
3357 }
else if (
type->builtInType == XML_SCHEMAS_BYTE) {
3358 if ((
mi != 0) || (hi != 0))
3360 if ((
sign == 1) && (lo > 128))
3362 if ((
sign == 0) && (lo > 127))
3366 v = xmlSchemaNewValue(
type->builtInType);
3368 v->value.decimal.lo = lo;
3369 v->value.decimal.mi =
mi;
3370 v->value.decimal.hi = hi;
3371 v->value.decimal.sign =
sign;
3372 v->
value.decimal.frac = 0;
3373 v->value.decimal.total =
ret;
3379 case XML_SCHEMAS_UINT:
3380 case XML_SCHEMAS_ULONG:
3381 case XML_SCHEMAS_USHORT:
3382 case XML_SCHEMAS_UBYTE:{
3384 unsigned long lo,
mi, hi;
3389 while IS_WSP_BLANK_CH(*
cur)
cur++;
3390 ret = xmlSchemaParseUInt(&
cur, &lo, &
mi, &hi);
3394 while IS_WSP_BLANK_CH(*
cur)
cur++;
3397 if (
type->builtInType == XML_SCHEMAS_ULONG) {
3401 if (
mi >= 67440737) {
3408 }
else if (
type->builtInType == XML_SCHEMAS_UINT) {
3417 }
else if (
type->builtInType == XML_SCHEMAS_USHORT) {
3418 if ((
mi != 0) || (hi != 0))
3422 }
else if (
type->builtInType == XML_SCHEMAS_UBYTE) {
3423 if ((
mi != 0) || (hi != 0))
3429 v = xmlSchemaNewValue(
type->builtInType);
3431 v->value.decimal.lo = lo;
3432 v->value.decimal.mi =
mi;
3433 v->value.decimal.hi = hi;
3434 v->value.decimal.sign = 0;
3435 v->value.decimal.frac = 0;
3436 v->value.decimal.total =
ret;
3483 XML_SCHEMA_WHITESPACE_UNKNOWN, 1, 1, 0));
3501xmlSchemaValPredefTypeNodeNoNorm(xmlSchemaTypePtr
type,
const xmlChar *
value,
3504 XML_SCHEMA_WHITESPACE_UNKNOWN, 1, 0, 1));
3520xmlSchemaValidatePredefinedType(xmlSchemaTypePtr
type,
const xmlChar *
value,
3521 xmlSchemaValPtr *
val) {
3535xmlSchemaCompareDecimals(xmlSchemaValPtr
x, xmlSchemaValPtr
y)
3537 xmlSchemaValPtr swp;
3538 int order = 1, integx, integy, dlen;
3539 unsigned long hi,
mi, lo;
3544 if ((
x->value.decimal.sign) &&
3545 ((
x->value.decimal.lo != 0) ||
3546 (
x->value.decimal.mi != 0) ||
3547 (
x->value.decimal.hi != 0))) {
3551 if ((
y->value.decimal.sign) &&
3552 ((
y->value.decimal.lo != 0) ||
3553 (
y->value.decimal.mi != 0) ||
3554 (
y->value.decimal.hi != 0)))
3564 }
else if ((
y->value.decimal.sign) &&
3565 ((
y->value.decimal.lo != 0) ||
3566 (
y->value.decimal.mi != 0) ||
3567 (
y->value.decimal.hi != 0))) {
3577 integx =
x->value.decimal.total -
x->value.decimal.frac;
3578 integy =
y->value.decimal.total -
y->value.decimal.frac;
3590 if (
x->value.decimal.lo == 0) {
3593 else if (
y->value.decimal.lo != 0)
3600 if (
y->value.decimal.lo == 0) {
3603 else if (
x->value.decimal.lo != 0)
3610 if (integx > integy)
3612 else if (integy > integx)
3623 dlen =
x->value.decimal.total -
y->value.decimal.total;
3626 hi =
y->value.decimal.hi;
3627 mi =
y->value.decimal.mi;
3628 lo =
y->value.decimal.lo;
3633 hi =
x->value.decimal.hi;
3634 mi =
x->value.decimal.mi;
3635 lo =
x->value.decimal.lo;
3644 unsigned long rem1, rem2;
3645 rem1 = (hi % 10) * 100000000L;
3647 rem2 = (
mi % 10) * 100000000L;
3648 mi = (
mi + rem1) / 10;
3649 lo = (lo + rem2) / 10;
3652 if (hi > swp->value.decimal.hi) {
3654 }
else if (hi == swp->value.decimal.hi) {
3655 if (
mi > swp->value.decimal.mi) {
3657 }
else if (
mi == swp->value.decimal.mi) {
3658 if (lo > swp->value.decimal.lo) {
3660 }
else if (lo == swp->value.decimal.lo) {
3661 if (
x->value.decimal.total ==
y->value.decimal.total) {
3683xmlSchemaCompareDurations(xmlSchemaValPtr
x, xmlSchemaValPtr
y)
3685 long carry, mon,
day;
3688 long xmon, xday, myear, minday, maxday;
3689 static const long dayRange [2][12] = {
3690 { 0, 28, 59, 89, 120, 150, 181, 212, 242, 273, 303, 334, },
3691 { 0, 31, 62, 92, 123, 153, 184, 215, 245, 276, 306, 337} };
3697 mon =
x->value.dur.mon -
y->value.dur.mon;
3700 sec =
x->value.dur.sec -
y->value.dur.sec;
3701 carry = (
long)(sec / SECS_PER_DAY);
3702 sec -= ((
double)carry) * SECS_PER_DAY;
3705 day =
x->value.dur.day -
y->value.dur.day + carry;
3723 if ((
day >= 0) && (sec >= 0.0))
3729 }
else if ((
day <= 0) && (sec <= 0.0)) {
3746 maxday = 365 * myear + (myear + 3) / 4;
3748 minday = maxday - 1;
3752 minday += dayRange[0][xmon];
3753 maxday += dayRange[1][xmon];
3755 if ((maxday == minday) && (maxday == xday))
3769#define FQUOTIENT(a,b) (floor(((double)a/(double)b)))
3770#define MODULO(a,b) (a - FQUOTIENT(a,b) * b)
3771#define FQUOTIENT_RANGE(a,low,high) (FQUOTIENT((a-low),(high-low)))
3772#define MODULO_RANGE(a,low,high) ((MODULO((a-low),(high-low)))+low)
3783static xmlSchemaValPtr
3784xmlSchemaDupVal (xmlSchemaValPtr
v)
3786 xmlSchemaValPtr
ret = xmlSchemaNewValue(
v->type);
3804xmlSchemaCopyValue(xmlSchemaValPtr
val)
3812 switch (
val->type) {
3813 case XML_SCHEMAS_ANYTYPE:
3814 case XML_SCHEMAS_IDREFS:
3815 case XML_SCHEMAS_ENTITIES:
3816 case XML_SCHEMAS_NMTOKENS:
3817 xmlSchemaFreeValue(
ret);
3819 case XML_SCHEMAS_ANYSIMPLETYPE:
3820 case XML_SCHEMAS_STRING:
3821 case XML_SCHEMAS_NORMSTRING:
3822 case XML_SCHEMAS_TOKEN:
3823 case XML_SCHEMAS_LANGUAGE:
3824 case XML_SCHEMAS_NAME:
3825 case XML_SCHEMAS_NCNAME:
3826 case XML_SCHEMAS_ID:
3827 case XML_SCHEMAS_IDREF:
3828 case XML_SCHEMAS_ENTITY:
3829 case XML_SCHEMAS_NMTOKEN:
3830 case XML_SCHEMAS_ANYURI:
3831 cur = xmlSchemaDupVal(
val);
3835 case XML_SCHEMAS_QNAME:
3836 case XML_SCHEMAS_NOTATION:
3837 cur = xmlSchemaDupVal(
val);
3838 if (
val->value.qname.name !=
NULL)
3839 cur->value.qname.name =
3841 if (
val->value.qname.uri !=
NULL)
3842 cur->value.qname.uri =
3845 case XML_SCHEMAS_HEXBINARY:
3846 cur = xmlSchemaDupVal(
val);
3847 if (
val->value.hex.str !=
NULL)
3850 case XML_SCHEMAS_BASE64BINARY:
3851 cur = xmlSchemaDupVal(
val);
3852 if (
val->value.base64.str !=
NULL)
3853 cur->value.base64.str =
3857 cur = xmlSchemaDupVal(
val);
3882static xmlSchemaValPtr
3883_xmlSchemaDateAdd (xmlSchemaValPtr dt, xmlSchemaValPtr dur)
3885 xmlSchemaValPtr
ret, tmp;
3886 long carry, tempdays,
temp;
3887 xmlSchemaValDatePtr
r,
d;
3888 xmlSchemaValDurationPtr
u;
3893 ret = xmlSchemaNewValue(dt->type);
3898 tmp = xmlSchemaDupVal(dt);
3900 xmlSchemaFreeValue(
ret);
3904 r = &(
ret->value.date);
3905 d = &(tmp->value.date);
3906 u = &(dur->value.dur);
3913 u->sec -= (
d->tzo * 60);
3921 carry =
d->mon +
u->mon;
3922 r->mon = (
unsigned int) MODULO_RANGE(carry, 1, 13);
3923 carry = (
long) FQUOTIENT_RANGE(carry, 1, 13);
3926 r->year =
d->year + carry;
3936 r->tz_flag =
d->tz_flag;
3939 r->sec =
d->sec +
u->sec;
3940 carry = (
long) FQUOTIENT((
long)
r->sec, 60);
3941 if (
r->sec != 0.0) {
3942 r->sec = MODULO(
r->sec, 60.0);
3947 r->min = (
unsigned int) MODULO(carry, 60);
3948 carry = (
long) FQUOTIENT(carry, 60);
3952 r->hour = (
unsigned int) MODULO(carry, 24);
3953 carry = (
long)FQUOTIENT(carry, 24);
3960 if ((VALID_YEAR(
r->year)) && (VALID_MONTH(
r->mon)) &&
3961 (
d->day > MAX_DAYINMONTH(
r->year,
r->mon)))
3962 tempdays = MAX_DAYINMONTH(
r->year,
r->mon);
3963 else if (
d->day < 1)
3968 tempdays +=
u->day + carry;
3972 long tmon = (
long) MODULO_RANGE((
int)
r->mon-1, 1, 13);
3973 long tyr =
r->year + (
long)FQUOTIENT_RANGE((
int)
r->mon-1, 1, 13);
3984 tempdays += MAX_DAYINMONTH(tyr, tmon);
3986 }
else if (VALID_YEAR(
r->year) && VALID_MONTH(
r->mon) &&
3987 tempdays > (
long) MAX_DAYINMONTH(
r->year,
r->mon)) {
3988 tempdays = tempdays - MAX_DAYINMONTH(
r->year,
r->mon);
3993 temp =
r->mon + carry;
3994 r->mon = (
unsigned int) MODULO_RANGE(
temp, 1, 13);
3995 r->year =
r->year + (
long) FQUOTIENT_RANGE(
temp, 1, 13);
4009 if (
ret->type != XML_SCHEMAS_DATETIME) {
4010 if ((
r->hour) || (
r->min) || (
r->sec))
4011 ret->type = XML_SCHEMAS_DATETIME;
4012 else if (
ret->type != XML_SCHEMAS_DATE) {
4013 if ((
r->mon != 1) && (
r->day != 1))
4014 ret->type = XML_SCHEMAS_DATE;
4015 else if ((
ret->type != XML_SCHEMAS_GYEARMONTH) && (
r->mon != 1))
4016 ret->type = XML_SCHEMAS_GYEARMONTH;
4020 xmlSchemaFreeValue(tmp);
4035static xmlSchemaValPtr
4036xmlSchemaDateNormalize (xmlSchemaValPtr dt,
double offset)
4038 xmlSchemaValPtr dur,
ret;
4043 if (((dt->type != XML_SCHEMAS_TIME) &&
4044 (dt->type != XML_SCHEMAS_DATETIME) &&
4045 (dt->type != XML_SCHEMAS_DATE)) || (dt->value.date.tzo == 0))
4046 return xmlSchemaDupVal(dt);
4048 dur = xmlSchemaNewValue(XML_SCHEMAS_DURATION);
4054 ret = _xmlSchemaDateAdd(dt, dur);
4058 xmlSchemaFreeValue(dur);
4076_xmlSchemaDateCastYMToDays (
const xmlSchemaValPtr dt)
4081 mon = dt->value.date.mon;
4082 if (mon <= 0) mon = 1;
4084 if (dt->value.date.year <= 0)
4085 ret = (dt->value.date.year * 365) +
4086 (((dt->value.date.year+1)/4)-((dt->value.date.year+1)/100)+
4087 ((dt->value.date.year+1)/400)) +
4088 DAY_IN_YEAR(0, mon, dt->value.date.year);
4090 ret = ((dt->value.date.year-1) * 365) +
4091 (((dt->value.date.year-1)/4)-((dt->value.date.year-1)/100)+
4092 ((dt->value.date.year-1)/400)) +
4093 DAY_IN_YEAR(0, mon, dt->value.date.year);
4106#define TIME_TO_NUMBER(dt) \
4107 ((double)((dt->value.date.hour * SECS_PER_HOUR) + \
4108 (dt->value.date.min * SECS_PER_MIN) + \
4109 (dt->value.date.tzo * SECS_PER_MIN)) + \
4123xmlSchemaCompareDates (xmlSchemaValPtr
x, xmlSchemaValPtr
y)
4125 unsigned char xmask, ymask, xor_mask, and_mask;
4126 xmlSchemaValPtr p1, p2, q1, q2;
4127 long p1d, p2d, q1d, q2d;
4132 if ((
x->value.date.year >
LONG_MAX / 366) ||
4133 (
x->value.date.year <
LONG_MIN / 366) ||
4134 (
y->value.date.year >
LONG_MAX / 366) ||
4135 (
y->value.date.year <
LONG_MIN / 366)) {
4140 if (
x->value.date.tz_flag) {
4142 if (!
y->value.date.tz_flag) {
4143 p1 = xmlSchemaDateNormalize(
x, 0);
4144 p1d = _xmlSchemaDateCastYMToDays(p1) + p1->value.date.day;
4146 q1 = xmlSchemaDateNormalize(
y, (14 * SECS_PER_HOUR));
4148 q1d = _xmlSchemaDateCastYMToDays(q1) + q1->value.date.day;
4150 xmlSchemaFreeValue(p1);
4151 xmlSchemaFreeValue(q1);
4153 }
else if (p1d == q1d) {
4156 sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q1);
4158 xmlSchemaFreeValue(p1);
4159 xmlSchemaFreeValue(q1);
4164 q2 = xmlSchemaDateNormalize(
y, -(14 * SECS_PER_HOUR));
4165 q2d = _xmlSchemaDateCastYMToDays(q2) + q2->value.date.day;
4168 else if (p1d == q2d) {
4169 sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q2);
4175 xmlSchemaFreeValue(p1);
4176 xmlSchemaFreeValue(q1);
4177 xmlSchemaFreeValue(q2);
4182 xmlSchemaFreeValue(p1);
4183 xmlSchemaFreeValue(q1);
4186 }
else if (
y->value.date.tz_flag) {
4187 q1 = xmlSchemaDateNormalize(
y, 0);
4188 q1d = _xmlSchemaDateCastYMToDays(q1) + q1->value.date.day;
4191 p1 = xmlSchemaDateNormalize(
x, -(14 * SECS_PER_HOUR));
4192 p1d = _xmlSchemaDateCastYMToDays(p1) + p1->value.date.day;
4195 xmlSchemaFreeValue(p1);
4196 xmlSchemaFreeValue(q1);
4198 }
else if (p1d == q1d) {
4201 sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q1);
4203 xmlSchemaFreeValue(p1);
4204 xmlSchemaFreeValue(q1);
4209 p2 = xmlSchemaDateNormalize(
x, (14 * SECS_PER_HOUR));
4210 p2d = _xmlSchemaDateCastYMToDays(p2) + p2->value.date.day;
4214 }
else if (p2d == q1d) {
4215 sec = TIME_TO_NUMBER(p2) - TIME_TO_NUMBER(q1);
4221 xmlSchemaFreeValue(p1);
4222 xmlSchemaFreeValue(q1);
4223 xmlSchemaFreeValue(p2);
4228 xmlSchemaFreeValue(p1);
4229 xmlSchemaFreeValue(q1);
4236 if (
x->type ==
y->type) {
4238 q1 = xmlSchemaDateNormalize(
y, 0);
4239 q1d = _xmlSchemaDateCastYMToDays(q1) + q1->value.date.day;
4241 p1 = xmlSchemaDateNormalize(
x, 0);
4242 p1d = _xmlSchemaDateCastYMToDays(p1) + p1->value.date.day;
4246 }
else if (p1d > q1d) {
4251 sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q1);
4258 xmlSchemaFreeValue(p1);
4259 xmlSchemaFreeValue(q1);
4264 case XML_SCHEMAS_DATETIME:
4267 case XML_SCHEMAS_DATE:
4270 case XML_SCHEMAS_GYEAR:
4273 case XML_SCHEMAS_GMONTH:
4276 case XML_SCHEMAS_GDAY:
4279 case XML_SCHEMAS_GYEARMONTH:
4282 case XML_SCHEMAS_GMONTHDAY:
4285 case XML_SCHEMAS_TIME:
4294 case XML_SCHEMAS_DATETIME:
4297 case XML_SCHEMAS_DATE:
4300 case XML_SCHEMAS_GYEAR:
4303 case XML_SCHEMAS_GMONTH:
4306 case XML_SCHEMAS_GDAY:
4309 case XML_SCHEMAS_GYEARMONTH:
4312 case XML_SCHEMAS_GMONTHDAY:
4315 case XML_SCHEMAS_TIME:
4323 xor_mask = xmask ^ ymask;
4324 and_mask = xmask & ymask;
4329 else if (and_mask & 1) {
4330 if (
x->value.date.year <
y->value.date.year)
4332 else if (
x->value.date.year >
y->value.date.year)
4339 else if (and_mask & 2) {
4340 if (
x->value.date.mon <
y->value.date.mon)
4342 else if (
x->value.date.mon >
y->value.date.mon)
4349 else if (and_mask & 4) {
4350 if (
x->value.date.day <
y->value.date.day)
4352 else if (
x->value.date.day >
y->value.date.day)
4359 else if (and_mask & 8) {
4360 if (
x->value.date.hour <
y->value.date.hour)
4362 else if (
x->value.date.hour >
y->value.date.hour)
4364 else if (
x->value.date.min <
y->value.date.min)
4366 else if (
x->value.date.min >
y->value.date.min)
4368 else if (
x->value.date.sec <
y->value.date.sec)
4370 else if (
x->value.date.sec >
y->value.date.sec)
4392xmlSchemaComparePreserveReplaceStrings(
const xmlChar *
x,
4398 while ((*
x != 0) && (*
y != 0)) {
4399 if (IS_WSP_REPLACE_CH(*
y)) {
4400 if (! IS_WSP_SPACE_CH(*
x)) {
4401 if ((*
x - 0x20) < 0) {
4460xmlSchemaComparePreserveCollapseStrings(
const xmlChar *
x,
4469 while IS_WSP_BLANK_CH(*
y)
4472 while ((*
x != 0) && (*
y != 0)) {
4473 if IS_WSP_BLANK_CH(*
y) {
4474 if (! IS_WSP_SPACE_CH(*
x)) {
4478 if ((*
x - 0x20) < 0) {
4495 while IS_WSP_BLANK_CH(*
y)
4523 while IS_WSP_BLANK_CH(*
y)
4549xmlSchemaCompareReplaceCollapseStrings(
const xmlChar *
x,
4558 while IS_WSP_BLANK_CH(*
y)
4561 while ((*
x != 0) && (*
y != 0)) {
4562 if IS_WSP_BLANK_CH(*
y) {
4563 if (! IS_WSP_BLANK_CH(*
x)) {
4567 if ((*
x - 0x20) < 0) {
4584 while IS_WSP_BLANK_CH(*
y)
4587 if IS_WSP_BLANK_CH(*
x) {
4591 if ((0x20 - *
y) < 0) {
4620 while IS_WSP_BLANK_CH(*
y)
4644xmlSchemaCompareReplacedStrings(
const xmlChar *
x,
4649 while ((*
x != 0) && (*
y != 0)) {
4650 if IS_WSP_BLANK_CH(*
y) {
4651 if (! IS_WSP_BLANK_CH(*
x)) {
4652 if ((*
x - 0x20) < 0)
4658 if IS_WSP_BLANK_CH(*
x) {
4659 if ((0x20 - *
y) < 0)
4691xmlSchemaCompareNormStrings(
const xmlChar *
x,
4697 while ((*
x != 0) && (*
y != 0)) {
4737xmlSchemaCompareFloats(xmlSchemaValPtr
x, xmlSchemaValPtr
y) {
4746 if (
x->type == XML_SCHEMAS_DOUBLE)
4748 else if (
x->type == XML_SCHEMAS_FLOAT)
4753 if (
y->type == XML_SCHEMAS_DOUBLE)
4755 else if (
y->type == XML_SCHEMAS_FLOAT)
4763 if (xmlXPathIsNaN(d1)) {
4764 if (xmlXPathIsNaN(d2))
4768 if (xmlXPathIsNaN(d2))
4770 if (d1 == xmlXPathPINF) {
4771 if (d2 == xmlXPathPINF)
4775 if (d2 == xmlXPathPINF)
4777 if (d1 == xmlXPathNINF) {
4778 if (d2 == xmlXPathNINF)
4782 if (d2 == xmlXPathNINF)
4814xmlSchemaCompareValuesInternal(xmlSchemaValType xtype,
4817 xmlSchemaWhitespaceValueType xws,
4818 xmlSchemaValType ytype,
4821 xmlSchemaWhitespaceValueType yws)
4824 case XML_SCHEMAS_UNKNOWN:
4825 case XML_SCHEMAS_ANYTYPE:
4827 case XML_SCHEMAS_INTEGER:
4828 case XML_SCHEMAS_NPINTEGER:
4829 case XML_SCHEMAS_NINTEGER:
4830 case XML_SCHEMAS_NNINTEGER:
4831 case XML_SCHEMAS_PINTEGER:
4832 case XML_SCHEMAS_INT:
4833 case XML_SCHEMAS_UINT:
4834 case XML_SCHEMAS_LONG:
4835 case XML_SCHEMAS_ULONG:
4836 case XML_SCHEMAS_SHORT:
4837 case XML_SCHEMAS_USHORT:
4838 case XML_SCHEMAS_BYTE:
4839 case XML_SCHEMAS_UBYTE:
4840 case XML_SCHEMAS_DECIMAL:
4844 return(xmlSchemaCompareDecimals(
x,
y));
4845 if ((ytype == XML_SCHEMAS_DECIMAL) ||
4846 (ytype == XML_SCHEMAS_INTEGER) ||
4847 (ytype == XML_SCHEMAS_NPINTEGER) ||
4848 (ytype == XML_SCHEMAS_NINTEGER) ||
4849 (ytype == XML_SCHEMAS_NNINTEGER) ||
4850 (ytype == XML_SCHEMAS_PINTEGER) ||
4851 (ytype == XML_SCHEMAS_INT) ||
4852 (ytype == XML_SCHEMAS_UINT) ||
4853 (ytype == XML_SCHEMAS_LONG) ||
4854 (ytype == XML_SCHEMAS_ULONG) ||
4855 (ytype == XML_SCHEMAS_SHORT) ||
4856 (ytype == XML_SCHEMAS_USHORT) ||
4857 (ytype == XML_SCHEMAS_BYTE) ||
4858 (ytype == XML_SCHEMAS_UBYTE))
4859 return(xmlSchemaCompareDecimals(
x,
y));
4861 case XML_SCHEMAS_DURATION:
4864 if (ytype == XML_SCHEMAS_DURATION)
4865 return(xmlSchemaCompareDurations(
x,
y));
4867 case XML_SCHEMAS_TIME:
4868 case XML_SCHEMAS_GDAY:
4869 case XML_SCHEMAS_GMONTH:
4870 case XML_SCHEMAS_GMONTHDAY:
4871 case XML_SCHEMAS_GYEAR:
4872 case XML_SCHEMAS_GYEARMONTH:
4873 case XML_SCHEMAS_DATE:
4874 case XML_SCHEMAS_DATETIME:
4877 if ((ytype == XML_SCHEMAS_DATETIME) ||
4878 (ytype == XML_SCHEMAS_TIME) ||
4879 (ytype == XML_SCHEMAS_GDAY) ||
4880 (ytype == XML_SCHEMAS_GMONTH) ||
4881 (ytype == XML_SCHEMAS_GMONTHDAY) ||
4882 (ytype == XML_SCHEMAS_GYEAR) ||
4883 (ytype == XML_SCHEMAS_DATE) ||
4884 (ytype == XML_SCHEMAS_GYEARMONTH))
4885 return (xmlSchemaCompareDates(
x,
y));
4891 case XML_SCHEMAS_ANYSIMPLETYPE:
4892 case XML_SCHEMAS_STRING:
4893 case XML_SCHEMAS_NORMSTRING:
4894 case XML_SCHEMAS_TOKEN:
4895 case XML_SCHEMAS_LANGUAGE:
4896 case XML_SCHEMAS_NMTOKEN:
4897 case XML_SCHEMAS_NAME:
4898 case XML_SCHEMAS_NCNAME:
4899 case XML_SCHEMAS_ID:
4900 case XML_SCHEMAS_IDREF:
4901 case XML_SCHEMAS_ENTITY:
4902 case XML_SCHEMAS_ANYURI:
4917 if (ytype == XML_SCHEMAS_QNAME) {
4923 if ((ytype == XML_SCHEMAS_ANYSIMPLETYPE) ||
4924 (ytype == XML_SCHEMAS_STRING) ||
4925 (ytype == XML_SCHEMAS_NORMSTRING) ||
4926 (ytype == XML_SCHEMAS_TOKEN) ||
4927 (ytype == XML_SCHEMAS_LANGUAGE) ||
4928 (ytype == XML_SCHEMAS_NMTOKEN) ||
4929 (ytype == XML_SCHEMAS_NAME) ||
4930 (ytype == XML_SCHEMAS_NCNAME) ||
4931 (ytype == XML_SCHEMAS_ID) ||
4932 (ytype == XML_SCHEMAS_IDREF) ||
4933 (ytype == XML_SCHEMAS_ENTITY) ||
4934 (ytype == XML_SCHEMAS_ANYURI)) {
4936 if (xws == XML_SCHEMA_WHITESPACE_PRESERVE) {
4938 if (yws == XML_SCHEMA_WHITESPACE_PRESERVE) {
4944 }
else if (yws == XML_SCHEMA_WHITESPACE_REPLACE)
4945 return (xmlSchemaComparePreserveReplaceStrings(xv, yv, 0));
4946 else if (yws == XML_SCHEMA_WHITESPACE_COLLAPSE)
4947 return (xmlSchemaComparePreserveCollapseStrings(xv, yv, 0));
4949 }
else if (xws == XML_SCHEMA_WHITESPACE_REPLACE) {
4951 if (yws == XML_SCHEMA_WHITESPACE_PRESERVE)
4952 return (xmlSchemaComparePreserveReplaceStrings(yv, xv, 1));
4953 if (yws == XML_SCHEMA_WHITESPACE_REPLACE)
4954 return (xmlSchemaCompareReplacedStrings(xv, yv));
4955 if (yws == XML_SCHEMA_WHITESPACE_COLLAPSE)
4956 return (xmlSchemaCompareReplaceCollapseStrings(xv, yv, 0));
4958 }
else if (xws == XML_SCHEMA_WHITESPACE_COLLAPSE) {
4960 if (yws == XML_SCHEMA_WHITESPACE_PRESERVE)
4961 return (xmlSchemaComparePreserveCollapseStrings(yv, xv, 1));
4962 if (yws == XML_SCHEMA_WHITESPACE_REPLACE)
4963 return (xmlSchemaCompareReplaceCollapseStrings(yv, xv, 1));
4964 if (yws == XML_SCHEMA_WHITESPACE_COLLAPSE)
4965 return (xmlSchemaCompareNormStrings(xv, yv));
4972 case XML_SCHEMAS_QNAME:
4973 case XML_SCHEMAS_NOTATION:
4976 if ((ytype == XML_SCHEMAS_QNAME) ||
4977 (ytype == XML_SCHEMAS_NOTATION)) {
4978 if ((
xmlStrEqual(
x->value.qname.name,
y->value.qname.name)) &&
4984 case XML_SCHEMAS_FLOAT:
4985 case XML_SCHEMAS_DOUBLE:
4988 if ((ytype == XML_SCHEMAS_FLOAT) ||
4989 (ytype == XML_SCHEMAS_DOUBLE))
4990 return (xmlSchemaCompareFloats(
x,
y));
4992 case XML_SCHEMAS_BOOLEAN:
4995 if (ytype == XML_SCHEMAS_BOOLEAN) {
4996 if (
x->value.b ==
y->value.b)
4998 if (
x->value.b == 0)
5003 case XML_SCHEMAS_HEXBINARY:
5006 if (ytype == XML_SCHEMAS_HEXBINARY) {
5007 if (
x->value.hex.total ==
y->value.hex.total) {
5014 else if (
x->value.hex.total >
y->value.hex.total)
5020 case XML_SCHEMAS_BASE64BINARY:
5023 if (ytype == XML_SCHEMAS_BASE64BINARY) {
5024 if (
x->value.base64.total ==
y->value.base64.total) {
5026 y->value.base64.str);
5034 else if (
x->value.base64.total >
y->value.base64.total)
5040 case XML_SCHEMAS_IDREFS:
5041 case XML_SCHEMAS_ENTITIES:
5042 case XML_SCHEMAS_NMTOKENS:
5060xmlSchemaCompareValues(xmlSchemaValPtr
x, xmlSchemaValPtr
y) {
5061 xmlSchemaWhitespaceValueType xws, yws;
5065 if (
x->type == XML_SCHEMAS_STRING)
5066 xws = XML_SCHEMA_WHITESPACE_PRESERVE;
5067 else if (
x->type == XML_SCHEMAS_NORMSTRING)
5068 xws = XML_SCHEMA_WHITESPACE_REPLACE;
5070 xws = XML_SCHEMA_WHITESPACE_COLLAPSE;
5072 if (
y->type == XML_SCHEMAS_STRING)
5073 yws = XML_SCHEMA_WHITESPACE_PRESERVE;
5074 else if (
y->type == XML_SCHEMAS_NORMSTRING)
5075 yws = XML_SCHEMA_WHITESPACE_REPLACE;
5077 yws = XML_SCHEMA_WHITESPACE_COLLAPSE;
5079 return(xmlSchemaCompareValuesInternal(
x->type,
x,
NULL, xws,
y->type,
5096xmlSchemaCompareValuesWhtsp(xmlSchemaValPtr
x,
5097 xmlSchemaWhitespaceValueType xws,
5099 xmlSchemaWhitespaceValueType yws)
5103 return(xmlSchemaCompareValuesInternal(
x->type,
x,
NULL, xws,
y->type,
5120xmlSchemaCompareValuesWhtspExt(xmlSchemaValType xtype,
5123 xmlSchemaWhitespaceValueType xws,
5124 xmlSchemaValType ytype,
5127 xmlSchemaWhitespaceValueType yws)
5129 return(xmlSchemaCompareValuesInternal(xtype,
x, xvalue, xws, ytype,
y,
5151 if (utf[0] & 0x80) {
5152 if ((utf[1] & 0xc0) != 0x80)
5154 if ((utf[0] & 0xe0) == 0xe0) {
5155 if ((utf[2] & 0xc0) != 0x80)
5157 if ((utf[0] & 0xf0) == 0xf0) {
5158 if ((utf[0] & 0xf8) != 0xf0 || (utf[3] & 0xc0) != 0x80)
5188xmlSchemaGetFacetValueAsULong(xmlSchemaFacetPtr facet)
5193 if (facet ==
NULL || facet->val ==
NULL)
5195 return ((
unsigned long) facet->val->value.decimal.lo);
5211xmlSchemaValidateListSimpleTypeFacet(xmlSchemaFacetPtr facet,
5213 unsigned long actualLen,
5214 unsigned long *expectedLen)
5222 if (facet->type == XML_SCHEMA_FACET_LENGTH) {
5223 if (actualLen != facet->val->value.decimal.lo) {
5224 if (expectedLen !=
NULL)
5225 *expectedLen = facet->val->value.decimal.lo;
5228 }
else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) {
5229 if (actualLen < facet->
val->value.decimal.lo) {
5230 if (expectedLen !=
NULL)
5231 *expectedLen = facet->val->value.decimal.lo;
5234 }
else if (facet->type == XML_SCHEMA_FACET_MAXLENGTH) {
5235 if (actualLen > facet->val->value.decimal.lo) {
5236 if (expectedLen !=
NULL)
5237 *expectedLen = facet->val->value.decimal.lo;
5266xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet,
5267 xmlSchemaValType valType,
5269 xmlSchemaValPtr
val,
5271 xmlSchemaWhitespaceValueType ws)
5273 unsigned int len = 0;
5278 if ((facet->type != XML_SCHEMA_FACET_LENGTH) &&
5279 (facet->type != XML_SCHEMA_FACET_MAXLENGTH) &&
5280 (facet->type != XML_SCHEMA_FACET_MINLENGTH))
5287 if ((facet->val ==
NULL) ||
5288 ((facet->val->type != XML_SCHEMAS_DECIMAL) &&
5289 (facet->val->type != XML_SCHEMAS_NNINTEGER)) ||
5290 (facet->val->value.decimal.frac != 0)) {
5293 if ((
val !=
NULL) && (
val->type == XML_SCHEMAS_HEXBINARY))
5294 len =
val->value.hex.total;
5295 else if ((
val !=
NULL) && (
val->type == XML_SCHEMAS_BASE64BINARY))
5296 len =
val->value.base64.total;
5299 case XML_SCHEMAS_STRING:
5300 case XML_SCHEMAS_NORMSTRING:
5301 if (ws == XML_SCHEMA_WHITESPACE_UNKNOWN) {
5308 if (valType == XML_SCHEMAS_STRING)
5313 if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE)
5322 case XML_SCHEMAS_IDREF:
5323 case XML_SCHEMAS_TOKEN:
5324 case XML_SCHEMAS_LANGUAGE:
5325 case XML_SCHEMAS_NMTOKEN:
5326 case XML_SCHEMAS_NAME:
5327 case XML_SCHEMAS_NCNAME:
5328 case XML_SCHEMAS_ID:
5332 case XML_SCHEMAS_ANYURI:
5336 case XML_SCHEMAS_QNAME:
5337 case XML_SCHEMAS_NOTATION:
5351 if (facet->type == XML_SCHEMA_FACET_LENGTH) {
5352 if (
len != facet->val->value.decimal.lo)
5354 }
else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) {
5355 if (len < facet->
val->value.decimal.lo)
5358 if (
len > facet->val->value.decimal.lo)
5380xmlSchemaValidateLengthFacet(xmlSchemaTypePtr
type,
5381 xmlSchemaFacetPtr facet,
5383 xmlSchemaValPtr
val,
5388 return (xmlSchemaValidateLengthFacetInternal(facet,
5390 XML_SCHEMA_WHITESPACE_UNKNOWN));
5409xmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet,
5410 xmlSchemaValType valType,
5412 xmlSchemaValPtr
val,
5414 xmlSchemaWhitespaceValueType ws)
5416 return (xmlSchemaValidateLengthFacetInternal(facet, valType,
value,
val,
5435xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet,
5436 xmlSchemaWhitespaceValueType fws,
5437 xmlSchemaValType valType,
5439 xmlSchemaValPtr
val,
5440 xmlSchemaWhitespaceValueType ws)
5447 switch (facet->type) {
5448 case XML_SCHEMA_FACET_PATTERN:
5462 ((
val->type >= XML_SCHEMAS_STRING &&
5463 val->type <= XML_SCHEMAS_NORMSTRING) ||
5464 (
val->type >= XML_SCHEMAS_TOKEN &&
5465 val->type <= XML_SCHEMAS_ENTITIES &&
5466 val->type != XML_SCHEMAS_QNAME))) {
5469 ret = xmlRegexpExec(facet->regexp,
value);
5475 case XML_SCHEMA_FACET_MAXEXCLUSIVE:
5476 ret = xmlSchemaCompareValues(
val, facet->val);
5482 case XML_SCHEMA_FACET_MAXINCLUSIVE:
5483 ret = xmlSchemaCompareValues(
val, facet->val);
5486 if ((
ret == -1) || (
ret == 0))
5489 case XML_SCHEMA_FACET_MINEXCLUSIVE:
5490 ret = xmlSchemaCompareValues(
val, facet->val);
5496 case XML_SCHEMA_FACET_MININCLUSIVE:
5497 ret = xmlSchemaCompareValues(
val, facet->val);
5500 if ((
ret == 1) || (
ret == 0))
5503 case XML_SCHEMA_FACET_WHITESPACE:
5511 case XML_SCHEMA_FACET_ENUMERATION:
5512 if (ws == XML_SCHEMA_WHITESPACE_UNKNOWN) {
5518 if ((facet->value !=
NULL) &&
5522 ret = xmlSchemaCompareValuesWhtspExt(facet->val->type,
5523 facet->val, facet->value, fws, valType,
val,
5531 case XML_SCHEMA_FACET_LENGTH:
5536 if ((valType == XML_SCHEMAS_QNAME) ||
5537 (valType == XML_SCHEMAS_NOTATION))
5540 case XML_SCHEMA_FACET_MAXLENGTH:
5541 case XML_SCHEMA_FACET_MINLENGTH: {
5542 unsigned int len = 0;
5544 if ((valType == XML_SCHEMAS_QNAME) ||
5545 (valType == XML_SCHEMAS_NOTATION))
5551 if ((facet->val ==
NULL) ||
5552 ((facet->val->type != XML_SCHEMAS_DECIMAL) &&
5553 (facet->val->type != XML_SCHEMAS_NNINTEGER)) ||
5554 (facet->val->value.decimal.frac != 0)) {
5557 if ((
val !=
NULL) && (
val->type == XML_SCHEMAS_HEXBINARY))
5558 len =
val->value.hex.total;
5559 else if ((
val !=
NULL) && (
val->type == XML_SCHEMAS_BASE64BINARY))
5560 len =
val->value.base64.total;
5563 case XML_SCHEMAS_STRING:
5564 case XML_SCHEMAS_NORMSTRING:
5565 if (ws == XML_SCHEMA_WHITESPACE_UNKNOWN) {
5572 if (valType == XML_SCHEMAS_STRING)
5577 if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE)
5586 case XML_SCHEMAS_IDREF:
5587 case XML_SCHEMAS_TOKEN:
5588 case XML_SCHEMAS_LANGUAGE:
5589 case XML_SCHEMAS_NMTOKEN:
5590 case XML_SCHEMAS_NAME:
5591 case XML_SCHEMAS_NCNAME:
5592 case XML_SCHEMAS_ID:
5593 case XML_SCHEMAS_ANYURI:
5601 if (facet->type == XML_SCHEMA_FACET_LENGTH) {
5602 if (
len != facet->val->value.decimal.lo)
5604 }
else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) {
5605 if (len < facet->
val->value.decimal.lo)
5608 if (
len > facet->val->value.decimal.lo)
5613 case XML_SCHEMA_FACET_TOTALDIGITS:
5614 case XML_SCHEMA_FACET_FRACTIONDIGITS:
5616 if ((facet->val ==
NULL) ||
5617 ((facet->val->type != XML_SCHEMAS_PINTEGER) &&
5618 (facet->val->type != XML_SCHEMAS_NNINTEGER)) ||
5619 (facet->val->value.decimal.frac != 0)) {
5623 ((
val->type != XML_SCHEMAS_DECIMAL) &&
5624 (
val->type != XML_SCHEMAS_INTEGER) &&
5625 (
val->type != XML_SCHEMAS_NPINTEGER) &&
5626 (
val->type != XML_SCHEMAS_NINTEGER) &&
5627 (
val->type != XML_SCHEMAS_NNINTEGER) &&
5628 (
val->type != XML_SCHEMAS_PINTEGER) &&
5629 (
val->type != XML_SCHEMAS_INT) &&
5630 (
val->type != XML_SCHEMAS_UINT) &&
5631 (
val->type != XML_SCHEMAS_LONG) &&
5632 (
val->type != XML_SCHEMAS_ULONG) &&
5633 (
val->type != XML_SCHEMAS_SHORT) &&
5634 (
val->type != XML_SCHEMAS_USHORT) &&
5635 (
val->type != XML_SCHEMAS_BYTE) &&
5636 (
val->type != XML_SCHEMAS_UBYTE))) {
5639 if (facet->type == XML_SCHEMA_FACET_TOTALDIGITS) {
5640 if (
val->value.decimal.total > facet->val->value.decimal.lo)
5643 }
else if (facet->type == XML_SCHEMA_FACET_FRACTIONDIGITS) {
5644 if (
val->value.decimal.frac > facet->val->value.decimal.lo)
5668xmlSchemaValidateFacet(xmlSchemaTypePtr
base,
5669 xmlSchemaFacetPtr facet,
5671 xmlSchemaValPtr
val)
5679 return(xmlSchemaValidateFacetInternal(facet,
5680 XML_SCHEMA_WHITESPACE_UNKNOWN,
val->type,
value,
val,
5681 XML_SCHEMA_WHITESPACE_UNKNOWN));
5683 return(xmlSchemaValidateFacetInternal(facet,
5684 XML_SCHEMA_WHITESPACE_UNKNOWN,
base->builtInType,
value,
val,
5685 XML_SCHEMA_WHITESPACE_UNKNOWN));
5707xmlSchemaValidateFacetWhtsp(xmlSchemaFacetPtr facet,
5708 xmlSchemaWhitespaceValueType fws,
5709 xmlSchemaValType valType,
5711 xmlSchemaValPtr
val,
5712 xmlSchemaWhitespaceValueType ws)
5714 return(xmlSchemaValidateFacetInternal(facet, fws, valType,
5723#define DBL_EPSILON 1E-9
5726#define INTEGER_DIGITS DBL_DIG
5727#define FRACTION_DIGITS (DBL_DIG + 1)
5728#define EXPONENT_DIGITS (3 + 2)
5739xmlSchemaFormatFloat(
double number,
char buffer[],
int buffersize)
5741 switch (xmlXPathIsInf(
number)) {
5743 if (buffersize > (
int)
sizeof(
"INF"))
5747 if (buffersize > (
int)
sizeof(
"-INF"))
5751 if (xmlXPathIsNaN(
number)) {
5752 if (buffersize > (
int)
sizeof(
"NaN"))
5754 }
else if (
number == 0) {
5758 char work[
DBL_DIG + EXPONENT_DIGITS + 3];
5759 int integer_place, fraction_place;
5761 char *after_fraction;
5762 double absolute_value;
5772 integer_place =
DBL_DIG + EXPONENT_DIGITS + 1;
5774 snprintf(work,
sizeof(work),
"%*.*e",
5775 integer_place, fraction_place,
number);
5778 ptr = after_fraction;
5779 while (*(--
ptr) ==
'0')
5783 while ((*
ptr++ = *after_fraction++) != 0);
5787 if (
size > buffersize) {
5788 work[buffersize - 1] = 0;
5818xmlSchemaGetCanonValue(xmlSchemaValPtr
val,
const xmlChar **retValue)
5823 switch (
val->type) {
5824 case XML_SCHEMAS_STRING:
5831 case XML_SCHEMAS_NORMSTRING:
5835 *retValue = xmlSchemaWhiteSpaceReplace(
5837 if ((*retValue) ==
NULL)
5842 case XML_SCHEMAS_TOKEN:
5843 case XML_SCHEMAS_LANGUAGE:
5844 case XML_SCHEMAS_NMTOKEN:
5845 case XML_SCHEMAS_NAME:
5846 case XML_SCHEMAS_NCNAME:
5847 case XML_SCHEMAS_ID:
5848 case XML_SCHEMAS_IDREF:
5849 case XML_SCHEMAS_ENTITY:
5850 case XML_SCHEMAS_NOTATION:
5851 case XML_SCHEMAS_ANYURI: