Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: third_party/libxml/xmlschemas.c

Issue 2951008: Update libxml to 2.7.7. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * schemas.c : implementation of the XML Schema handling and 2 * schemas.c : implementation of the XML Schema handling and
3 * schema validity checking 3 * schema 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 /* 10 /*
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 /* #define DEBUG_IDC */ 83 /* #define DEBUG_IDC */
84 84
85 /* #define DEBUG_IDC_NODE_TABLE */ 85 /* #define DEBUG_IDC_NODE_TABLE */
86 86
87 /* #define WXS_ELEM_DECL_CONS_ENABLED */ 87 /* #define WXS_ELEM_DECL_CONS_ENABLED */
88 88
89 #ifdef DEBUG_IDC 89 #ifdef DEBUG_IDC
90 #ifndef DEBUG_IDC_NODE_TABLE 90 #ifndef DEBUG_IDC_NODE_TABLE
91 #define DEBUG_IDC_NODE_TABLE 91 #define DEBUG_IDC_NODE_TABLE
92 #endif 92 #endif
93 #endif 93 #endif
94 94
95 /* #define ENABLE_PARTICLE_RESTRICTION 1 */ 95 /* #define ENABLE_PARTICLE_RESTRICTION 1 */
96 96
97 #define ENABLE_REDEFINE 97 #define ENABLE_REDEFINE
98 98
99 /* #define ENABLE_NAMED_LOCALS */ 99 /* #define ENABLE_NAMED_LOCALS */
100 100
101 /* #define ENABLE_IDC_NODE_TABLES_TEST */ 101 /* #define ENABLE_IDC_NODE_TABLES_TEST */
102 102
103 #define DUMP_CONTENT_MODEL 103 #define DUMP_CONTENT_MODEL
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 367
368 typedef struct _xmlSchemaBucket xmlSchemaBucket; 368 typedef struct _xmlSchemaBucket xmlSchemaBucket;
369 typedef xmlSchemaBucket *xmlSchemaBucketPtr; 369 typedef xmlSchemaBucket *xmlSchemaBucketPtr;
370 370
371 #define XML_SCHEMA_SCHEMA_MAIN 0 371 #define XML_SCHEMA_SCHEMA_MAIN 0
372 #define XML_SCHEMA_SCHEMA_IMPORT 1 372 #define XML_SCHEMA_SCHEMA_IMPORT 1
373 #define XML_SCHEMA_SCHEMA_INCLUDE 2 373 #define XML_SCHEMA_SCHEMA_INCLUDE 2
374 #define XML_SCHEMA_SCHEMA_REDEFINE 3 374 #define XML_SCHEMA_SCHEMA_REDEFINE 3
375 375
376 /** 376 /**
377 * xmlSchemaSchemaRelation: 377 * xmlSchemaSchemaRelation:
378 * 378 *
379 * Used to create a graph of schema relationships. 379 * Used to create a graph of schema relationships.
380 */ 380 */
381 typedef struct _xmlSchemaSchemaRelation xmlSchemaSchemaRelation; 381 typedef struct _xmlSchemaSchemaRelation xmlSchemaSchemaRelation;
382 typedef xmlSchemaSchemaRelation *xmlSchemaSchemaRelationPtr; 382 typedef xmlSchemaSchemaRelation *xmlSchemaSchemaRelationPtr;
383 struct _xmlSchemaSchemaRelation { 383 struct _xmlSchemaSchemaRelation {
384 xmlSchemaSchemaRelationPtr next; 384 xmlSchemaSchemaRelationPtr next;
385 int type; /* E.g. XML_SCHEMA_SCHEMA_IMPORT */ 385 int type; /* E.g. XML_SCHEMA_SCHEMA_IMPORT */
386 const xmlChar *importNamespace; 386 const xmlChar *importNamespace;
387 xmlSchemaBucketPtr bucket; 387 xmlSchemaBucketPtr bucket;
388 }; 388 };
389 389
390 #define XML_SCHEMA_BUCKET_MARKED 1<<0 390 #define XML_SCHEMA_BUCKET_MARKED 1<<0
391 #define XML_SCHEMA_BUCKET_COMPS_ADDED 1<<1 391 #define XML_SCHEMA_BUCKET_COMPS_ADDED 1<<1
392 392
393 struct _xmlSchemaBucket { 393 struct _xmlSchemaBucket {
394 int type; 394 int type;
395 int flags; 395 int flags;
396 const xmlChar *schemaLocation; 396 const xmlChar *schemaLocation;
397 const xmlChar *origTargetNamespace; 397 const xmlChar *origTargetNamespace;
398 const xmlChar *targetNamespace; 398 const xmlChar *targetNamespace;
399 xmlDocPtr doc; 399 xmlDocPtr doc;
400 xmlSchemaSchemaRelationPtr relations; 400 xmlSchemaSchemaRelationPtr relations;
401 int located; 401 int located;
402 int parsed; 402 int parsed;
403 int imported; 403 int imported;
404 int preserveDoc; 404 int preserveDoc;
405 xmlSchemaItemListPtr globals; /* Global components. */ 405 xmlSchemaItemListPtr globals; /* Global components. */
406 xmlSchemaItemListPtr locals; /* Local components. */ 406 xmlSchemaItemListPtr locals; /* Local components. */
407 }; 407 };
408 408
409 /** 409 /**
410 * xmlSchemaImport: 410 * xmlSchemaImport:
411 * (extends xmlSchemaBucket) 411 * (extends xmlSchemaBucket)
412 * 412 *
413 * Reflects a schema. Holds some information 413 * Reflects a schema. Holds some information
414 * about the schema and its toplevel components. Duplicate 414 * about the schema and its toplevel components. Duplicate
415 * toplevel components are not checked at this level. 415 * toplevel components are not checked at this level.
416 */ 416 */
417 typedef struct _xmlSchemaImport xmlSchemaImport; 417 typedef struct _xmlSchemaImport xmlSchemaImport;
418 typedef xmlSchemaImport *xmlSchemaImportPtr; 418 typedef xmlSchemaImport *xmlSchemaImportPtr;
419 struct _xmlSchemaImport { 419 struct _xmlSchemaImport {
420 int type; /* Main OR import OR include. */ 420 int type; /* Main OR import OR include. */
421 int flags; 421 int flags;
422 const xmlChar *schemaLocation; /* The URI of the schema document. */ 422 const xmlChar *schemaLocation; /* The URI of the schema document. */
423 /* For chameleon includes, @origTargetNamespace will be NULL */ 423 /* For chameleon includes, @origTargetNamespace will be NULL */
424 const xmlChar *origTargetNamespace; 424 const xmlChar *origTargetNamespace;
425 /* 425 /*
426 * For chameleon includes, @targetNamespace will be the 426 * For chameleon includes, @targetNamespace will be the
427 * targetNamespace of the including schema. 427 * targetNamespace of the including schema.
428 */ 428 */
429 const xmlChar *targetNamespace; 429 const xmlChar *targetNamespace;
430 xmlDocPtr doc; /* The schema node-tree. */ 430 xmlDocPtr doc; /* The schema node-tree. */
431 /* @relations will hold any included/imported/redefined schemas. */ 431 /* @relations will hold any included/imported/redefined schemas. */
432 xmlSchemaSchemaRelationPtr relations; 432 xmlSchemaSchemaRelationPtr relations;
433 int located; 433 int located;
434 int parsed; 434 int parsed;
435 int imported; 435 int imported;
436 int preserveDoc; 436 int preserveDoc;
437 xmlSchemaItemListPtr globals; 437 xmlSchemaItemListPtr globals;
(...skipping 12 matching lines...) Expand all
450 int flags; 450 int flags;
451 const xmlChar *schemaLocation; 451 const xmlChar *schemaLocation;
452 const xmlChar *origTargetNamespace; 452 const xmlChar *origTargetNamespace;
453 const xmlChar *targetNamespace; 453 const xmlChar *targetNamespace;
454 xmlDocPtr doc; 454 xmlDocPtr doc;
455 xmlSchemaSchemaRelationPtr relations; 455 xmlSchemaSchemaRelationPtr relations;
456 int located; 456 int located;
457 int parsed; 457 int parsed;
458 int imported; 458 int imported;
459 int preserveDoc; 459 int preserveDoc;
460 xmlSchemaItemListPtr globals; /* Global components. */ 460 xmlSchemaItemListPtr globals; /* Global components. */
461 xmlSchemaItemListPtr locals; /* Local components. */ 461 xmlSchemaItemListPtr locals; /* Local components. */
462 462
463 /* The owning main or import schema bucket. */ 463 /* The owning main or import schema bucket. */
464 xmlSchemaImportPtr ownerImport; 464 xmlSchemaImportPtr ownerImport;
465 }; 465 };
466 466
467 /** 467 /**
468 * xmlSchemaBasicItem: 468 * xmlSchemaBasicItem:
469 * 469 *
470 * The abstract base type for schema components. 470 * The abstract base type for schema components.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 * 510 *
511 * The abstract base type for tree-like structured schema components. 511 * The abstract base type for tree-like structured schema components.
512 * (Extends xmlSchemaTreeItem) 512 * (Extends xmlSchemaTreeItem)
513 */ 513 */
514 typedef struct _xmlSchemaAttributeUse xmlSchemaAttributeUse; 514 typedef struct _xmlSchemaAttributeUse xmlSchemaAttributeUse;
515 typedef xmlSchemaAttributeUse *xmlSchemaAttributeUsePtr; 515 typedef xmlSchemaAttributeUse *xmlSchemaAttributeUsePtr;
516 struct _xmlSchemaAttributeUse { 516 struct _xmlSchemaAttributeUse {
517 xmlSchemaTypeType type; 517 xmlSchemaTypeType type;
518 xmlSchemaAnnotPtr annot; 518 xmlSchemaAnnotPtr annot;
519 xmlSchemaAttributeUsePtr next; /* The next attr. use. */ 519 xmlSchemaAttributeUsePtr next; /* The next attr. use. */
520 /* 520 /*
521 * The attr. decl. OR a QName-ref. to an attr. decl. OR 521 * The attr. decl. OR a QName-ref. to an attr. decl. OR
522 * a QName-ref. to an attribute group definition. 522 * a QName-ref. to an attribute group definition.
523 */ 523 */
524 xmlSchemaAttributePtr attrDecl; 524 xmlSchemaAttributePtr attrDecl;
525 525
526 int flags; 526 int flags;
527 xmlNodePtr node; 527 xmlNodePtr node;
528 int occurs; /* required, optional */ 528 int occurs; /* required, optional */
529 const xmlChar * defValue; 529 const xmlChar * defValue;
530 xmlSchemaValPtr defVal; 530 xmlSchemaValPtr defVal;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 * xmlSchemaConstructionCtxt: 566 * xmlSchemaConstructionCtxt:
567 */ 567 */
568 typedef struct _xmlSchemaConstructionCtxt xmlSchemaConstructionCtxt; 568 typedef struct _xmlSchemaConstructionCtxt xmlSchemaConstructionCtxt;
569 typedef xmlSchemaConstructionCtxt *xmlSchemaConstructionCtxtPtr; 569 typedef xmlSchemaConstructionCtxt *xmlSchemaConstructionCtxtPtr;
570 struct _xmlSchemaConstructionCtxt { 570 struct _xmlSchemaConstructionCtxt {
571 xmlSchemaPtr mainSchema; /* The main schema. */ 571 xmlSchemaPtr mainSchema; /* The main schema. */
572 xmlSchemaBucketPtr mainBucket; /* The main schema bucket */ 572 xmlSchemaBucketPtr mainBucket; /* The main schema bucket */
573 xmlDictPtr dict; 573 xmlDictPtr dict;
574 xmlSchemaItemListPtr buckets; /* List of schema buckets. */ 574 xmlSchemaItemListPtr buckets; /* List of schema buckets. */
575 /* xmlSchemaItemListPtr relations; */ /* List of schema relations. */ 575 /* xmlSchemaItemListPtr relations; */ /* List of schema relations. */
576 xmlSchemaBucketPtr bucket; /* The current schema bucket */ 576 xmlSchemaBucketPtr bucket; /* The current schema bucket */
577 xmlSchemaItemListPtr pending; /* All Components of all schemas that 577 xmlSchemaItemListPtr pending; /* All Components of all schemas that
578 need to be fixed. */ 578 need to be fixed. */
579 xmlHashTablePtr substGroups; 579 xmlHashTablePtr substGroups;
580 xmlSchemaRedefPtr redefs; 580 xmlSchemaRedefPtr redefs;
581 xmlSchemaRedefPtr lastRedef; 581 xmlSchemaRedefPtr lastRedef;
582 }; 582 };
583 583
584 #define XML_SCHEMAS_PARSE_ERROR 1 584 #define XML_SCHEMAS_PARSE_ERROR 1
585 #define SCHEMAS_PARSE_OPTIONS XML_PARSE_NOENT 585 #define SCHEMAS_PARSE_OPTIONS XML_PARSE_NOENT
586 586
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 int options; 622 int options;
623 xmlSchemaValidCtxtPtr vctxt; 623 xmlSchemaValidCtxtPtr vctxt;
624 int isS4S; 624 int isS4S;
625 int isRedefine; 625 int isRedefine;
626 int xsiAssemble; 626 int xsiAssemble;
627 int stop; /* If the parser should stop; i.e. a critical error. */ 627 int stop; /* If the parser should stop; i.e. a critical error. */
628 const xmlChar *targetNamespace; 628 const xmlChar *targetNamespace;
629 xmlSchemaBucketPtr redefined; /* The schema to be redefined. */ 629 xmlSchemaBucketPtr redefined; /* The schema to be redefined. */
630 630
631 xmlSchemaRedefPtr redef; /* Used for redefinitions. */ 631 xmlSchemaRedefPtr redef; /* Used for redefinitions. */
632 int redefCounter; /* Used for redefinitions. */ 632 int redefCounter; /* Used for redefinitions. */
633 xmlSchemaItemListPtr attrProhibs; 633 xmlSchemaItemListPtr attrProhibs;
634 }; 634 };
635 635
636 /** 636 /**
637 * xmlSchemaQNameRef: 637 * xmlSchemaQNameRef:
638 * 638 *
639 * A component reference item (not a schema component) 639 * A component reference item (not a schema component)
640 * (Extends xmlSchemaBasicItem) 640 * (Extends xmlSchemaBasicItem)
641 */ 641 */
642 typedef struct _xmlSchemaQNameRef xmlSchemaQNameRef; 642 typedef struct _xmlSchemaQNameRef xmlSchemaQNameRef;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 * xmlSchemaPSVIIDCNode: 776 * xmlSchemaPSVIIDCNode:
777 * 777 *
778 * The node table item of a node table. 778 * The node table item of a node table.
779 */ 779 */
780 typedef struct _xmlSchemaPSVIIDCNode xmlSchemaPSVIIDCNode; 780 typedef struct _xmlSchemaPSVIIDCNode xmlSchemaPSVIIDCNode;
781 typedef xmlSchemaPSVIIDCNode *xmlSchemaPSVIIDCNodePtr; 781 typedef xmlSchemaPSVIIDCNode *xmlSchemaPSVIIDCNodePtr;
782 struct _xmlSchemaPSVIIDCNode { 782 struct _xmlSchemaPSVIIDCNode {
783 xmlNodePtr node; 783 xmlNodePtr node;
784 xmlSchemaPSVIIDCKeyPtr *keys; 784 xmlSchemaPSVIIDCKeyPtr *keys;
785 int nodeLine; 785 int nodeLine;
786 int nodeQNameID; 786 int nodeQNameID;
787 787
788 }; 788 };
789 789
790 /** 790 /**
791 * xmlSchemaPSVIIDCBinding: 791 * xmlSchemaPSVIIDCBinding:
792 * 792 *
793 * The identity-constraint binding item of the [identity-constraint table]. 793 * The identity-constraint binding item of the [identity-constraint table].
794 */ 794 */
795 typedef struct _xmlSchemaPSVIIDCBinding xmlSchemaPSVIIDCBinding; 795 typedef struct _xmlSchemaPSVIIDCBinding xmlSchemaPSVIIDCBinding;
796 typedef xmlSchemaPSVIIDCBinding *xmlSchemaPSVIIDCBindingPtr; 796 typedef xmlSchemaPSVIIDCBinding *xmlSchemaPSVIIDCBindingPtr;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 #define XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE 1<<10 872 #define XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE 1<<10
873 873
874 /** 874 /**
875 * xmlSchemaNodeInfo: 875 * xmlSchemaNodeInfo:
876 * 876 *
877 * Holds information of an element node. 877 * Holds information of an element node.
878 */ 878 */
879 struct _xmlSchemaNodeInfo { 879 struct _xmlSchemaNodeInfo {
880 int nodeType; 880 int nodeType;
881 xmlNodePtr node; 881 xmlNodePtr node;
882 int nodeLine; 882 int nodeLine;
883 const xmlChar *localName; 883 const xmlChar *localName;
884 const xmlChar *nsName; 884 const xmlChar *nsName;
885 const xmlChar *value; 885 const xmlChar *value;
886 xmlSchemaValPtr val; /* the pre-computed value if any */ 886 xmlSchemaValPtr val; /* the pre-computed value if any */
887 xmlSchemaTypePtr typeDef; /* the complex/simple type definition if any */ 887 xmlSchemaTypePtr typeDef; /* the complex/simple type definition if any */
888 888
889 int flags; /* combination of node info flags */ 889 int flags; /* combination of node info flags */
890 890
891 int valNeeded; 891 int valNeeded;
892 int normVal; 892 int normVal;
893 893
894 xmlSchemaElementPtr decl; /* the element/attribute declaration */ 894 xmlSchemaElementPtr decl; /* the element/attribute declaration */
895 int depth; 895 int depth;
896 xmlSchemaPSVIIDCBindingPtr idcTable; /* the table of PSVI IDC bindings 896 xmlSchemaPSVIIDCBindingPtr idcTable; /* the table of PSVI IDC bindings
897 for the scope element*/ 897 for the scope element*/
898 xmlSchemaIDCMatcherPtr idcMatchers; /* the IDC matchers for the scope 898 xmlSchemaIDCMatcherPtr idcMatchers; /* the IDC matchers for the scope
899 element */ 899 element */
900 xmlRegExecCtxtPtr regexCtxt; 900 xmlRegExecCtxtPtr regexCtxt;
901 901
902 const xmlChar **nsBindings; /* Namespace bindings on this element */ 902 const xmlChar **nsBindings; /* Namespace bindings on this element */
903 int nbNsBindings; 903 int nbNsBindings;
904 int sizeNsBindings; 904 int sizeNsBindings;
905 905
906 int hasKeyrefs; 906 int hasKeyrefs;
907 int appliedXPath; /* Indicates that an XPath has been applied. */ 907 int appliedXPath; /* Indicates that an XPath has been applied. */
908 }; 908 };
909 909
910 #define XML_SCHEMAS_ATTR_UNKNOWN 1 910 #define XML_SCHEMAS_ATTR_UNKNOWN 1
911 #define XML_SCHEMAS_ATTR_ASSESSED 2 911 #define XML_SCHEMAS_ATTR_ASSESSED 2
912 #define XML_SCHEMAS_ATTR_PROHIBITED 3 912 #define XML_SCHEMAS_ATTR_PROHIBITED 3
913 #define XML_SCHEMAS_ATTR_ERR_MISSING 4 913 #define XML_SCHEMAS_ATTR_ERR_MISSING 4
914 #define XML_SCHEMAS_ATTR_INVALID_VALUE 5 914 #define XML_SCHEMAS_ATTR_INVALID_VALUE 5
(...skipping 16 matching lines...) Expand all
931 #define XML_SCHEMA_ATTR_INFO_META_XSI_NIL 2 931 #define XML_SCHEMA_ATTR_INFO_META_XSI_NIL 2
932 #define XML_SCHEMA_ATTR_INFO_META_XSI_SCHEMA_LOC 3 932 #define XML_SCHEMA_ATTR_INFO_META_XSI_SCHEMA_LOC 3
933 #define XML_SCHEMA_ATTR_INFO_META_XSI_NO_NS_SCHEMA_LOC 4 933 #define XML_SCHEMA_ATTR_INFO_META_XSI_NO_NS_SCHEMA_LOC 4
934 #define XML_SCHEMA_ATTR_INFO_META_XMLNS 5 934 #define XML_SCHEMA_ATTR_INFO_META_XMLNS 5
935 935
936 typedef struct _xmlSchemaAttrInfo xmlSchemaAttrInfo; 936 typedef struct _xmlSchemaAttrInfo xmlSchemaAttrInfo;
937 typedef xmlSchemaAttrInfo *xmlSchemaAttrInfoPtr; 937 typedef xmlSchemaAttrInfo *xmlSchemaAttrInfoPtr;
938 struct _xmlSchemaAttrInfo { 938 struct _xmlSchemaAttrInfo {
939 int nodeType; 939 int nodeType;
940 xmlNodePtr node; 940 xmlNodePtr node;
941 int nodeLine; 941 int nodeLine;
942 const xmlChar *localName; 942 const xmlChar *localName;
943 const xmlChar *nsName; 943 const xmlChar *nsName;
944 const xmlChar *value; 944 const xmlChar *value;
945 xmlSchemaValPtr val; /* the pre-computed value if any */ 945 xmlSchemaValPtr val; /* the pre-computed value if any */
946 xmlSchemaTypePtr typeDef; /* the complex/simple type definition if any */ 946 xmlSchemaTypePtr typeDef; /* the complex/simple type definition if any */
947 int flags; /* combination of node info flags */ 947 int flags; /* combination of node info flags */
948 948
949 xmlSchemaAttributePtr decl; /* the attribute declaration */ 949 xmlSchemaAttributePtr decl; /* the attribute declaration */
950 xmlSchemaAttributeUsePtr use; /* the attribute use */ 950 xmlSchemaAttributeUsePtr use; /* the attribute use */
951 int state; 951 int state;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 * Returns the component name of a schema item. 1165 * Returns the component name of a schema item.
1166 */ 1166 */
1167 static const xmlChar * 1167 static const xmlChar *
1168 xmlSchemaGetComponentTypeStr(xmlSchemaBasicItemPtr item) 1168 xmlSchemaGetComponentTypeStr(xmlSchemaBasicItemPtr item)
1169 { 1169 {
1170 switch (item->type) { 1170 switch (item->type) {
1171 case XML_SCHEMA_TYPE_BASIC: 1171 case XML_SCHEMA_TYPE_BASIC:
1172 if (WXS_IS_COMPLEX(WXS_TYPE_CAST item)) 1172 if (WXS_IS_COMPLEX(WXS_TYPE_CAST item))
1173 return(BAD_CAST "complex type definition"); 1173 return(BAD_CAST "complex type definition");
1174 else 1174 else
1175 » » return(BAD_CAST "simple type definition");» 1175 » » return(BAD_CAST "simple type definition");
1176 default: 1176 default:
1177 return(xmlSchemaItemTypeToStr(item->type)); 1177 return(xmlSchemaItemTypeToStr(item->type));
1178 } 1178 }
1179 } 1179 }
1180 1180
1181 /** 1181 /**
1182 * xmlSchemaGetComponentNode: 1182 * xmlSchemaGetComponentNode:
1183 * @item: a schema component 1183 * @item: a schema component
1184 * 1184 *
1185 * Returns node associated with the schema component. 1185 * Returns node associated with the schema component.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 *buf = xmlStrdup(BAD_CAST "{"); 1293 *buf = xmlStrdup(BAD_CAST "{");
1294 *buf = xmlStrcat(*buf, namespaceName); 1294 *buf = xmlStrcat(*buf, namespaceName);
1295 *buf = xmlStrcat(*buf, BAD_CAST "}"); 1295 *buf = xmlStrcat(*buf, BAD_CAST "}");
1296 } 1296 }
1297 if (localName != NULL) { 1297 if (localName != NULL) {
1298 if (namespaceName == NULL) 1298 if (namespaceName == NULL)
1299 return(localName); 1299 return(localName);
1300 *buf = xmlStrcat(*buf, localName); 1300 *buf = xmlStrcat(*buf, localName);
1301 } else { 1301 } else {
1302 *buf = xmlStrcat(*buf, BAD_CAST "(NULL)"); 1302 *buf = xmlStrcat(*buf, BAD_CAST "(NULL)");
1303 } 1303 }
1304 return ((const xmlChar *) *buf); 1304 return ((const xmlChar *) *buf);
1305 } 1305 }
1306 1306
1307 static const xmlChar* 1307 static const xmlChar*
1308 xmlSchemaFormatQNameNs(xmlChar **buf, xmlNsPtr ns, const xmlChar *localName) 1308 xmlSchemaFormatQNameNs(xmlChar **buf, xmlNsPtr ns, const xmlChar *localName)
1309 { 1309 {
1310 if (ns != NULL) 1310 if (ns != NULL)
1311 return (xmlSchemaFormatQName(buf, ns->href, localName)); 1311 return (xmlSchemaFormatQName(buf, ns->href, localName));
1312 else 1312 else
1313 return (xmlSchemaFormatQName(buf, NULL, localName)); 1313 return (xmlSchemaFormatQName(buf, NULL, localName));
1314 } 1314 }
1315 1315
1316 static const xmlChar * 1316 static const xmlChar *
1317 xmlSchemaGetComponentName(xmlSchemaBasicItemPtr item) 1317 xmlSchemaGetComponentName(xmlSchemaBasicItemPtr item)
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 * API errors or if the value type is not supported yet. 1473 * API errors or if the value type is not supported yet.
1474 */ 1474 */
1475 static int 1475 static int
1476 xmlSchemaGetCanonValueWhtspExt(xmlSchemaValPtr val, 1476 xmlSchemaGetCanonValueWhtspExt(xmlSchemaValPtr val,
1477 xmlSchemaWhitespaceValueType ws, 1477 xmlSchemaWhitespaceValueType ws,
1478 xmlChar **retValue) 1478 xmlChar **retValue)
1479 { 1479 {
1480 int list; 1480 int list;
1481 xmlSchemaValType valType; 1481 xmlSchemaValType valType;
1482 const xmlChar *value, *value2 = NULL; 1482 const xmlChar *value, *value2 = NULL;
1483 1483
1484 1484
1485 if ((retValue == NULL) || (val == NULL)) 1485 if ((retValue == NULL) || (val == NULL))
1486 return (-1); 1486 return (-1);
1487 list = xmlSchemaValueGetNext(val) ? 1 : 0; 1487 list = xmlSchemaValueGetNext(val) ? 1 : 0;
1488 *retValue = NULL; 1488 *retValue = NULL;
1489 do { 1489 do {
1490 » value = NULL;» 1490 » value = NULL;
1491 » valType = xmlSchemaGetValType(val); 1491 » valType = xmlSchemaGetValType(val);
1492 » switch (valType) {» 1492 » switch (valType) {
1493 case XML_SCHEMAS_STRING: 1493 case XML_SCHEMAS_STRING:
1494 case XML_SCHEMAS_NORMSTRING: 1494 case XML_SCHEMAS_NORMSTRING:
1495 case XML_SCHEMAS_ANYSIMPLETYPE: 1495 case XML_SCHEMAS_ANYSIMPLETYPE:
1496 value = xmlSchemaValueGetAsString(val); 1496 value = xmlSchemaValueGetAsString(val);
1497 if (value != NULL) { 1497 if (value != NULL) {
1498 if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) 1498 if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE)
1499 value2 = xmlSchemaCollapseString(value); 1499 value2 = xmlSchemaCollapseString(value);
1500 else if (ws == XML_SCHEMA_WHITESPACE_REPLACE) 1500 else if (ws == XML_SCHEMA_WHITESPACE_REPLACE)
1501 value2 = xmlSchemaWhiteSpaceReplace(value); 1501 value2 = xmlSchemaWhiteSpaceReplace(value);
1502 if (value2 != NULL) 1502 if (value2 != NULL)
1503 value = value2; 1503 value = value2;
1504 } 1504 }
1505 » » break;» 1505 » » break;
1506 default: 1506 default:
1507 if (xmlSchemaGetCanonValue(val, &value2) == -1) { 1507 if (xmlSchemaGetCanonValue(val, &value2) == -1) {
1508 if (value2 != NULL) 1508 if (value2 != NULL)
1509 xmlFree((xmlChar *) value2); 1509 xmlFree((xmlChar *) value2);
1510 goto internal_error; 1510 goto internal_error;
1511 } 1511 }
1512 value = value2; 1512 value = value2;
1513 } 1513 }
1514 if (*retValue == NULL) 1514 if (*retValue == NULL)
1515 if (value == NULL) { 1515 if (value == NULL) {
(...skipping 17 matching lines...) Expand all
1533 if (value2 != NULL) 1533 if (value2 != NULL)
1534 xmlFree((xmlChar *) value2); 1534 xmlFree((xmlChar *) value2);
1535 return (-1); 1535 return (-1);
1536 } 1536 }
1537 1537
1538 /** 1538 /**
1539 * xmlSchemaFormatItemForReport: 1539 * xmlSchemaFormatItemForReport:
1540 * @buf: the string buffer 1540 * @buf: the string buffer
1541 * @itemDes: the designation of the item 1541 * @itemDes: the designation of the item
1542 * @itemName: the name of the item 1542 * @itemName: the name of the item
1543 * @item: the item as an object 1543 * @item: the item as an object
1544 * @itemNode: the node of the item 1544 * @itemNode: the node of the item
1545 * @local: the local name 1545 * @local: the local name
1546 * @parsing: if the function is used during the parse 1546 * @parsing: if the function is used during the parse
1547 * 1547 *
1548 * Returns a representation of the given item used 1548 * Returns a representation of the given item used
1549 * for error reports. 1549 * for error reports.
1550 * 1550 *
1551 * The following order is used to build the resulting 1551 * The following order is used to build the resulting
1552 * designation if the arguments are not NULL: 1552 * designation if the arguments are not NULL:
1553 * 1a. If itemDes not NULL -> itemDes 1553 * 1a. If itemDes not NULL -> itemDes
1554 * 1b. If (itemDes not NULL) and (itemName not NULL) 1554 * 1b. If (itemDes not NULL) and (itemName not NULL)
1555 * -> itemDes + itemName 1555 * -> itemDes + itemName
1556 * 2. If the preceding was NULL and (item not NULL) -> item 1556 * 2. If the preceding was NULL and (item not NULL) -> item
1557 * 3. If the preceding was NULL and (itemNode not NULL) -> itemNode 1557 * 3. If the preceding was NULL and (itemNode not NULL) -> itemNode
1558 * 1558 *
1559 * If the itemNode is an attribute node, the name of the attribute 1559 * If the itemNode is an attribute node, the name of the attribute
1560 * will be appended to the result. 1560 * will be appended to the result.
1561 * 1561 *
1562 * Returns the formatted string and sets @buf to the resulting value. 1562 * Returns the formatted string and sets @buf to the resulting value.
1563 */ 1563 */
1564 static xmlChar* 1564 static xmlChar*
1565 xmlSchemaFormatItemForReport(xmlChar **buf,» » 1565 xmlSchemaFormatItemForReport(xmlChar **buf,
1566 const xmlChar *itemDes, 1566 const xmlChar *itemDes,
1567 xmlSchemaBasicItemPtr item, 1567 xmlSchemaBasicItemPtr item,
1568 xmlNodePtr itemNode) 1568 xmlNodePtr itemNode)
1569 { 1569 {
1570 xmlChar *str = NULL; 1570 xmlChar *str = NULL;
1571 int named = 1; 1571 int named = 1;
1572 1572
1573 if (*buf != NULL) { 1573 if (*buf != NULL) {
1574 xmlFree(*buf); 1574 xmlFree(*buf);
1575 *buf = NULL; 1575 *buf = NULL;
1576 } 1576 }
1577 1577
1578 if (itemDes != NULL) { 1578 if (itemDes != NULL) {
1579 » *buf = xmlStrdup(itemDes);» 1579 » *buf = xmlStrdup(itemDes);
1580 } else if (item != NULL) { 1580 } else if (item != NULL) {
1581 switch (item->type) { 1581 switch (item->type) {
1582 case XML_SCHEMA_TYPE_BASIC: { 1582 case XML_SCHEMA_TYPE_BASIC: {
1583 xmlSchemaTypePtr type = WXS_TYPE_CAST item; 1583 xmlSchemaTypePtr type = WXS_TYPE_CAST item;
1584 1584
1585 if (WXS_IS_ATOMIC(type)) 1585 if (WXS_IS_ATOMIC(type))
1586 *buf = xmlStrdup(BAD_CAST "atomic type 'xs:"); 1586 *buf = xmlStrdup(BAD_CAST "atomic type 'xs:");
1587 else if (WXS_IS_LIST(type)) 1587 else if (WXS_IS_LIST(type))
1588 *buf = xmlStrdup(BAD_CAST "list type 'xs:"); 1588 *buf = xmlStrdup(BAD_CAST "list type 'xs:");
1589 else if (WXS_IS_UNION(type)) 1589 else if (WXS_IS_UNION(type))
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 *buf = xmlStrcat(*buf, BAD_CAST "complex type"); 1627 *buf = xmlStrcat(*buf, BAD_CAST "complex type");
1628 if (type->flags & XML_SCHEMAS_TYPE_GLOBAL) { 1628 if (type->flags & XML_SCHEMAS_TYPE_GLOBAL) {
1629 *buf = xmlStrcat(*buf, BAD_CAST " '"); 1629 *buf = xmlStrcat(*buf, BAD_CAST " '");
1630 *buf = xmlStrcat(*buf, type->name); 1630 *buf = xmlStrcat(*buf, type->name);
1631 *buf = xmlStrcat(*buf, BAD_CAST "'"); 1631 *buf = xmlStrcat(*buf, BAD_CAST "'");
1632 } 1632 }
1633 } 1633 }
1634 break; 1634 break;
1635 case XML_SCHEMA_TYPE_ATTRIBUTE_USE: { 1635 case XML_SCHEMA_TYPE_ATTRIBUTE_USE: {
1636 xmlSchemaAttributeUsePtr ause; 1636 xmlSchemaAttributeUsePtr ause;
1637 » 1637
1638 ause = WXS_ATTR_USE_CAST item; 1638 ause = WXS_ATTR_USE_CAST item;
1639 *buf = xmlStrdup(BAD_CAST "attribute use "); 1639 *buf = xmlStrdup(BAD_CAST "attribute use ");
1640 if (WXS_ATTRUSE_DECL(ause) != NULL) { 1640 if (WXS_ATTRUSE_DECL(ause) != NULL) {
1641 *buf = xmlStrcat(*buf, BAD_CAST "'"); 1641 *buf = xmlStrcat(*buf, BAD_CAST "'");
1642 *buf = xmlStrcat(*buf, 1642 *buf = xmlStrcat(*buf,
1643 xmlSchemaGetComponentQName(&str, WXS_ATTRUSE_DECL(ause)) ); 1643 xmlSchemaGetComponentQName(&str, WXS_ATTRUSE_DECL(ause)) );
1644 FREE_AND_NULL(str) 1644 FREE_AND_NULL(str)
1645 *buf = xmlStrcat(*buf, BAD_CAST "'"); 1645 *buf = xmlStrcat(*buf, BAD_CAST "'");
1646 } else { 1646 } else {
1647 *buf = xmlStrcat(*buf, BAD_CAST "(unknown)"); 1647 *buf = xmlStrcat(*buf, BAD_CAST "(unknown)");
1648 } 1648 }
1649 } 1649 }
1650 break; 1650 break;
1651 case XML_SCHEMA_TYPE_ATTRIBUTE: { 1651 case XML_SCHEMA_TYPE_ATTRIBUTE: {
1652 xmlSchemaAttributePtr attr; 1652 xmlSchemaAttributePtr attr;
1653 » 1653
1654 attr = (xmlSchemaAttributePtr) item; 1654 attr = (xmlSchemaAttributePtr) item;
1655 *buf = xmlStrdup(BAD_CAST "attribute decl."); 1655 *buf = xmlStrdup(BAD_CAST "attribute decl.");
1656 *buf = xmlStrcat(*buf, BAD_CAST " '"); 1656 *buf = xmlStrcat(*buf, BAD_CAST " '");
1657 *buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str, 1657 *buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str,
1658 attr->targetNamespace, attr->name)); 1658 attr->targetNamespace, attr->name));
1659 FREE_AND_NULL(str) 1659 FREE_AND_NULL(str)
1660 *buf = xmlStrcat(*buf, BAD_CAST "'"); 1660 *buf = xmlStrcat(*buf, BAD_CAST "'");
1661 } 1661 }
1662 break; 1662 break;
1663 case XML_SCHEMA_TYPE_ATTRIBUTEGROUP: 1663 case XML_SCHEMA_TYPE_ATTRIBUTEGROUP:
1664 xmlSchemaGetComponentDesignation(buf, item); 1664 xmlSchemaGetComponentDesignation(buf, item);
1665 break; 1665 break;
1666 case XML_SCHEMA_TYPE_ELEMENT: { 1666 case XML_SCHEMA_TYPE_ELEMENT: {
1667 xmlSchemaElementPtr elem; 1667 xmlSchemaElementPtr elem;
1668 1668
1669 » » elem = (xmlSchemaElementPtr) item;» 1669 » » elem = (xmlSchemaElementPtr) item;
1670 *buf = xmlStrdup(BAD_CAST "element decl."); 1670 *buf = xmlStrdup(BAD_CAST "element decl.");
1671 *buf = xmlStrcat(*buf, BAD_CAST " '"); 1671 *buf = xmlStrcat(*buf, BAD_CAST " '");
1672 *buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str, 1672 *buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str,
1673 elem->targetNamespace, elem->name)); 1673 elem->targetNamespace, elem->name));
1674 *buf = xmlStrcat(*buf, BAD_CAST "'"); 1674 *buf = xmlStrcat(*buf, BAD_CAST "'");
1675 } 1675 }
1676 break; 1676 break;
1677 case XML_SCHEMA_TYPE_IDC_UNIQUE: 1677 case XML_SCHEMA_TYPE_IDC_UNIQUE:
1678 case XML_SCHEMA_TYPE_IDC_KEY: 1678 case XML_SCHEMA_TYPE_IDC_KEY:
1679 » case XML_SCHEMA_TYPE_IDC_KEYREF:» » 1679 » case XML_SCHEMA_TYPE_IDC_KEYREF:
1680 if (item->type == XML_SCHEMA_TYPE_IDC_UNIQUE) 1680 if (item->type == XML_SCHEMA_TYPE_IDC_UNIQUE)
1681 *buf = xmlStrdup(BAD_CAST "unique '"); 1681 *buf = xmlStrdup(BAD_CAST "unique '");
1682 else if (item->type == XML_SCHEMA_TYPE_IDC_KEY) 1682 else if (item->type == XML_SCHEMA_TYPE_IDC_KEY)
1683 *buf = xmlStrdup(BAD_CAST "key '"); 1683 *buf = xmlStrdup(BAD_CAST "key '");
1684 else 1684 else
1685 *buf = xmlStrdup(BAD_CAST "keyRef '"); 1685 *buf = xmlStrdup(BAD_CAST "keyRef '");
1686 *buf = xmlStrcat(*buf, ((xmlSchemaIDCPtr) item)->name); 1686 *buf = xmlStrcat(*buf, ((xmlSchemaIDCPtr) item)->name);
1687 *buf = xmlStrcat(*buf, BAD_CAST "'"); 1687 *buf = xmlStrcat(*buf, BAD_CAST "'");
1688 break; 1688 break;
1689 case XML_SCHEMA_TYPE_ANY: 1689 case XML_SCHEMA_TYPE_ANY:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 case XML_SCHEMA_TYPE_NOTATION: { 1725 case XML_SCHEMA_TYPE_NOTATION: {
1726 *buf = xmlStrdup(WXS_ITEM_TYPE_NAME(item)); 1726 *buf = xmlStrdup(WXS_ITEM_TYPE_NAME(item));
1727 *buf = xmlStrcat(*buf, BAD_CAST " '"); 1727 *buf = xmlStrcat(*buf, BAD_CAST " '");
1728 *buf = xmlStrcat(*buf, xmlSchemaGetComponentQName(&str, item)); 1728 *buf = xmlStrcat(*buf, xmlSchemaGetComponentQName(&str, item));
1729 *buf = xmlStrcat(*buf, BAD_CAST "'"); 1729 *buf = xmlStrcat(*buf, BAD_CAST "'");
1730 FREE_AND_NULL(str); 1730 FREE_AND_NULL(str);
1731 } 1731 }
1732 default: 1732 default:
1733 named = 0; 1733 named = 0;
1734 } 1734 }
1735 } else 1735 } else
1736 named = 0; 1736 named = 0;
1737 1737
1738 if ((named == 0) && (itemNode != NULL)) { 1738 if ((named == 0) && (itemNode != NULL)) {
1739 xmlNodePtr elem; 1739 xmlNodePtr elem;
1740 1740
1741 if (itemNode->type == XML_ATTRIBUTE_NODE) 1741 if (itemNode->type == XML_ATTRIBUTE_NODE)
1742 elem = itemNode->parent; 1742 elem = itemNode->parent;
1743 » else 1743 » else
1744 elem = itemNode; 1744 elem = itemNode;
1745 *buf = xmlStrdup(BAD_CAST "Element '"); 1745 *buf = xmlStrdup(BAD_CAST "Element '");
1746 if (elem->ns != NULL) { 1746 if (elem->ns != NULL) {
1747 *buf = xmlStrcat(*buf, 1747 *buf = xmlStrcat(*buf,
1748 xmlSchemaFormatQName(&str, elem->ns->href, elem->name)); 1748 xmlSchemaFormatQName(&str, elem->ns->href, elem->name));
1749 FREE_AND_NULL(str) 1749 FREE_AND_NULL(str)
1750 } else 1750 } else
1751 *buf = xmlStrcat(*buf, elem->name); 1751 *buf = xmlStrcat(*buf, elem->name);
1752 *buf = xmlStrcat(*buf, BAD_CAST "'"); 1752 *buf = xmlStrcat(*buf, BAD_CAST "'");
1753 » 1753
1754 } 1754 }
1755 if ((itemNode != NULL) && (itemNode->type == XML_ATTRIBUTE_NODE)) { 1755 if ((itemNode != NULL) && (itemNode->type == XML_ATTRIBUTE_NODE)) {
1756 *buf = xmlStrcat(*buf, BAD_CAST ", attribute '"); 1756 *buf = xmlStrcat(*buf, BAD_CAST ", attribute '");
1757 if (itemNode->ns != NULL) { 1757 if (itemNode->ns != NULL) {
1758 *buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str, 1758 *buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str,
1759 itemNode->ns->href, itemNode->name)); 1759 itemNode->ns->href, itemNode->name));
1760 FREE_AND_NULL(str) 1760 FREE_AND_NULL(str)
1761 } else 1761 } else
1762 *buf = xmlStrcat(*buf, itemNode->name); 1762 *buf = xmlStrcat(*buf, itemNode->name);
1763 *buf = xmlStrcat(*buf, BAD_CAST "'"); 1763 *buf = xmlStrcat(*buf, BAD_CAST "'");
1764 } 1764 }
1765 FREE_AND_NULL(str) 1765 FREE_AND_NULL(str)
1766 1766
1767 return (*buf); 1767 return (*buf);
1768 } 1768 }
1769 1769
1770 /** 1770 /**
1771 * xmlSchemaFormatFacetEnumSet: 1771 * xmlSchemaFormatFacetEnumSet:
1772 * @buf: the string buffer 1772 * @buf: the string buffer
1773 * @type: the type holding the enumeration facets 1773 * @type: the type holding the enumeration facets
1774 * 1774 *
1775 * Builds a string consisting of all enumeration elements. 1775 * Builds a string consisting of all enumeration elements.
1776 * 1776 *
1777 * Returns a string of all enumeration elements. 1777 * Returns a string of all enumeration elements.
1778 */ 1778 */
1779 static const xmlChar * 1779 static const xmlChar *
1780 xmlSchemaFormatFacetEnumSet(xmlSchemaAbstractCtxtPtr actxt, 1780 xmlSchemaFormatFacetEnumSet(xmlSchemaAbstractCtxtPtr actxt,
1781 xmlChar **buf, xmlSchemaTypePtr type) 1781 xmlChar **buf, xmlSchemaTypePtr type)
1782 { 1782 {
1783 xmlSchemaFacetPtr facet; 1783 xmlSchemaFacetPtr facet;
1784 xmlSchemaWhitespaceValueType ws; 1784 xmlSchemaWhitespaceValueType ws;
1785 xmlChar *value = NULL; 1785 xmlChar *value = NULL;
1786 int res, found = 0; 1786 int res, found = 0;
1787 1787
1788 if (*buf != NULL) 1788 if (*buf != NULL)
1789 » xmlFree(*buf); 1789 » xmlFree(*buf);
1790 *buf = NULL; 1790 *buf = NULL;
1791 1791
1792 do { 1792 do {
1793 /* 1793 /*
1794 * Use the whitespace type of the base type. 1794 * Use the whitespace type of the base type.
1795 » */» 1795 » */
1796 ws = xmlSchemaGetWhiteSpaceFacetValue(type->baseType); 1796 ws = xmlSchemaGetWhiteSpaceFacetValue(type->baseType);
1797 for (facet = type->facets; facet != NULL; facet = facet->next) { 1797 for (facet = type->facets; facet != NULL; facet = facet->next) {
1798 if (facet->type != XML_SCHEMA_FACET_ENUMERATION) 1798 if (facet->type != XML_SCHEMA_FACET_ENUMERATION)
1799 continue; 1799 continue;
1800 found = 1; 1800 found = 1;
1801 res = xmlSchemaGetCanonValueWhtspExt(facet->val, 1801 res = xmlSchemaGetCanonValueWhtspExt(facet->val,
1802 ws, &value); 1802 ws, &value);
1803 if (res == -1) { 1803 if (res == -1) {
1804 xmlSchemaInternalErr(actxt, 1804 xmlSchemaInternalErr(actxt,
1805 "xmlSchemaFormatFacetEnumSet", 1805 "xmlSchemaFormatFacetEnumSet",
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1874 } 1874 }
1875 1875
1876 /** 1876 /**
1877 * xmlSchemaPErr: 1877 * xmlSchemaPErr:
1878 * @ctxt: the parsing context 1878 * @ctxt: the parsing context
1879 * @node: the context node 1879 * @node: the context node
1880 * @error: the error code 1880 * @error: the error code
1881 * @msg: the error message 1881 * @msg: the error message
1882 * @str1: extra data 1882 * @str1: extra data
1883 * @str2: extra data 1883 * @str2: extra data
1884 * 1884 *
1885 * Handle a parser error 1885 * Handle a parser error
1886 */ 1886 */
1887 static void 1887 static void
1888 xmlSchemaPErr(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, 1888 xmlSchemaPErr(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
1889 const char *msg, const xmlChar * str1, const xmlChar * str2) 1889 const char *msg, const xmlChar * str1, const xmlChar * str2)
1890 { 1890 {
1891 xmlGenericErrorFunc channel = NULL; 1891 xmlGenericErrorFunc channel = NULL;
1892 xmlStructuredErrorFunc schannel = NULL; 1892 xmlStructuredErrorFunc schannel = NULL;
1893 void *data = NULL; 1893 void *data = NULL;
1894 1894
(...skipping 12 matching lines...) Expand all
1907 1907
1908 /** 1908 /**
1909 * xmlSchemaPErr2: 1909 * xmlSchemaPErr2:
1910 * @ctxt: the parsing context 1910 * @ctxt: the parsing context
1911 * @node: the context node 1911 * @node: the context node
1912 * @node: the current child 1912 * @node: the current child
1913 * @error: the error code 1913 * @error: the error code
1914 * @msg: the error message 1914 * @msg: the error message
1915 * @str1: extra data 1915 * @str1: extra data
1916 * @str2: extra data 1916 * @str2: extra data
1917 * 1917 *
1918 * Handle a parser error 1918 * Handle a parser error
1919 */ 1919 */
1920 static void 1920 static void
1921 xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, 1921 xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
1922 xmlNodePtr child, int error, 1922 xmlNodePtr child, int error,
1923 const char *msg, const xmlChar * str1, const xmlChar * str2) 1923 const char *msg, const xmlChar * str1, const xmlChar * str2)
1924 { 1924 {
1925 if (child != NULL) 1925 if (child != NULL)
1926 xmlSchemaPErr(ctxt, child, error, msg, str1, str2); 1926 xmlSchemaPErr(ctxt, child, error, msg, str1, str2);
1927 else 1927 else
1928 xmlSchemaPErr(ctxt, node, error, msg, str1, str2); 1928 xmlSchemaPErr(ctxt, node, error, msg, str1, str2);
1929 } 1929 }
1930 1930
1931 1931
1932 /** 1932 /**
1933 * xmlSchemaPErrExt: 1933 * xmlSchemaPErrExt:
1934 * @ctxt: the parsing context 1934 * @ctxt: the parsing context
1935 * @node: the context node 1935 * @node: the context node
1936 * @error: the error code 1936 * @error: the error code
1937 * @strData1: extra data 1937 * @strData1: extra data
1938 * @strData2: extra data 1938 * @strData2: extra data
1939 * @strData3: extra data 1939 * @strData3: extra data
1940 * @msg: the message 1940 * @msg: the message
1941 * @str1: extra parameter for the message display 1941 * @str1: extra parameter for the message display
1942 * @str2: extra parameter for the message display 1942 * @str2: extra parameter for the message display
1943 * @str3: extra parameter for the message display 1943 * @str3: extra parameter for the message display
1944 * @str4: extra parameter for the message display 1944 * @str4: extra parameter for the message display
1945 * @str5: extra parameter for the message display 1945 * @str5: extra parameter for the message display
1946 * 1946 *
1947 * Handle a parser error 1947 * Handle a parser error
1948 */ 1948 */
1949 static void 1949 static void
1950 xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, 1950 xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
1951 » » const xmlChar * strData1, const xmlChar * strData2, 1951 » » const xmlChar * strData1, const xmlChar * strData2,
1952 » » const xmlChar * strData3, const char *msg, const xmlChar * str1, 1952 » » const xmlChar * strData3, const char *msg, const xmlChar * str1,
1953 const xmlChar * str2, const xmlChar * str3, const xmlChar * str4 , 1953 const xmlChar * str2, const xmlChar * str3, const xmlChar * str4 ,
1954 const xmlChar * str5) 1954 const xmlChar * str5)
1955 { 1955 {
1956 1956
1957 xmlGenericErrorFunc channel = NULL; 1957 xmlGenericErrorFunc channel = NULL;
1958 xmlStructuredErrorFunc schannel = NULL; 1958 xmlStructuredErrorFunc schannel = NULL;
1959 void *data = NULL; 1959 void *data = NULL;
1960 1960
1961 if (ctxt != NULL) { 1961 if (ctxt != NULL) {
1962 ctxt->nberrors++; 1962 ctxt->nberrors++;
1963 ctxt->err = error; 1963 ctxt->err = error;
1964 channel = ctxt->error; 1964 channel = ctxt->error;
1965 data = ctxt->errCtxt; 1965 data = ctxt->errCtxt;
1966 schannel = ctxt->serror; 1966 schannel = ctxt->serror;
1967 } 1967 }
1968 __xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP, 1968 __xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP,
1969 error, XML_ERR_ERROR, NULL, 0, 1969 error, XML_ERR_ERROR, NULL, 0,
1970 (const char *) strData1, (const char *) strData2, 1970 (const char *) strData1, (const char *) strData2,
1971 » » (const char *) strData3, 0, 0, msg, str1, str2, 1971 » » (const char *) strData3, 0, 0, msg, str1, str2,
1972 str3, str4, str5); 1972 str3, str4, str5);
1973 } 1973 }
1974 1974
1975 /************************************************************************ 1975 /************************************************************************
1976 * * 1976 * *
1977 * Allround error functions * 1977 * Allround error functions *
1978 * * 1978 * *
1979 ************************************************************************/ 1979 ************************************************************************/
1980 1980
1981 /** 1981 /**
(...skipping 27 matching lines...) Expand all
2009 #define WXS_ERROR_TYPE_WARNING 2 2009 #define WXS_ERROR_TYPE_WARNING 2
2010 /** 2010 /**
2011 * xmlSchemaErr3: 2011 * xmlSchemaErr3:
2012 * @ctxt: the validation context 2012 * @ctxt: the validation context
2013 * @node: the context node 2013 * @node: the context node
2014 * @error: the error code 2014 * @error: the error code
2015 * @msg: the error message 2015 * @msg: the error message
2016 * @str1: extra data 2016 * @str1: extra data
2017 * @str2: extra data 2017 * @str2: extra data
2018 * @str3: extra data 2018 * @str3: extra data
2019 * 2019 *
2020 * Handle a validation error 2020 * Handle a validation error
2021 */ 2021 */
2022 static void 2022 static void
2023 xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt, 2023 xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
2024 xmlErrorLevel errorLevel, 2024 xmlErrorLevel errorLevel,
2025 int error, xmlNodePtr node, int line, const char *msg, 2025 int error, xmlNodePtr node, int line, const char *msg,
2026 const xmlChar *str1, const xmlChar *str2, 2026 const xmlChar *str1, const xmlChar *str2,
2027 const xmlChar *str3, const xmlChar *str4) 2027 const xmlChar *str3, const xmlChar *str4)
2028 { 2028 {
2029 xmlStructuredErrorFunc schannel = NULL; 2029 xmlStructuredErrorFunc schannel = NULL;
2030 xmlGenericErrorFunc channel = NULL; 2030 xmlGenericErrorFunc channel = NULL;
2031 void *data = NULL; 2031 void *data = NULL;
2032 2032
2033 if (ctxt != NULL) { 2033 if (ctxt != NULL) {
2034 if (ctxt->type == XML_SCHEMA_CTXT_VALIDATOR) { 2034 if (ctxt->type == XML_SCHEMA_CTXT_VALIDATOR) {
2035 xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctxt; 2035 xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctxt;
2036 const char *file = NULL; 2036 const char *file = NULL;
2037 if (errorLevel != XML_ERR_WARNING) { 2037 if (errorLevel != XML_ERR_WARNING) {
2038 vctxt->nberrors++; 2038 vctxt->nberrors++;
2039 vctxt->err = error; 2039 vctxt->err = error;
2040 » » channel = vctxt->error;»» 2040 » » channel = vctxt->error;
2041 } else { 2041 } else {
2042 channel = vctxt->warning; 2042 channel = vctxt->warning;
2043 } 2043 }
2044 schannel = vctxt->serror; 2044 schannel = vctxt->serror;
2045 data = vctxt->errCtxt; 2045 data = vctxt->errCtxt;
2046 2046
2047 /* 2047 /*
2048 * Error node. If we specify a line number, then 2048 * Error node. If we specify a line number, then
2049 * do not channel any node to the error function. 2049 * do not channel any node to the error function.
2050 */ 2050 */
(...skipping 19 matching lines...) Expand all
2070 */ 2070 */
2071 node = NULL; 2071 node = NULL;
2072 /* 2072 /*
2073 * Get filename. 2073 * Get filename.
2074 */ 2074 */
2075 if (vctxt->doc != NULL) 2075 if (vctxt->doc != NULL)
2076 file = (const char *) vctxt->doc->URL; 2076 file = (const char *) vctxt->doc->URL;
2077 else if ((vctxt->parserCtxt != NULL) && 2077 else if ((vctxt->parserCtxt != NULL) &&
2078 (vctxt->parserCtxt->input != NULL)) 2078 (vctxt->parserCtxt->input != NULL))
2079 file = vctxt->parserCtxt->input->filename; 2079 file = vctxt->parserCtxt->input->filename;
2080 » }» 2080 » }
2081 __xmlRaiseError(schannel, channel, data, ctxt, 2081 __xmlRaiseError(schannel, channel, data, ctxt,
2082 node, XML_FROM_SCHEMASV, 2082 node, XML_FROM_SCHEMASV,
2083 error, errorLevel, file, line, 2083 error, errorLevel, file, line,
2084 (const char *) str1, (const char *) str2, 2084 (const char *) str1, (const char *) str2,
2085 (const char *) str3, 0, 0, msg, str1, str2, str3, str4); 2085 (const char *) str3, 0, 0, msg, str1, str2, str3, str4);
2086 2086
2087 } else if (ctxt->type == XML_SCHEMA_CTXT_PARSER) { 2087 } else if (ctxt->type == XML_SCHEMA_CTXT_PARSER) {
2088 xmlSchemaParserCtxtPtr pctxt = (xmlSchemaParserCtxtPtr) ctxt; 2088 xmlSchemaParserCtxtPtr pctxt = (xmlSchemaParserCtxtPtr) ctxt;
2089 if (errorLevel != XML_ERR_WARNING) { 2089 if (errorLevel != XML_ERR_WARNING) {
2090 pctxt->nberrors++; 2090 pctxt->nberrors++;
2091 pctxt->err = error; 2091 pctxt->err = error;
2092 » » channel = pctxt->error;»» 2092 » » channel = pctxt->error;
2093 } else { 2093 } else {
2094 channel = pctxt->warning; 2094 channel = pctxt->warning;
2095 } 2095 }
2096 schannel = pctxt->serror; 2096 schannel = pctxt->serror;
2097 data = pctxt->errCtxt; 2097 data = pctxt->errCtxt;
2098 __xmlRaiseError(schannel, channel, data, ctxt, 2098 __xmlRaiseError(schannel, channel, data, ctxt,
2099 node, XML_FROM_SCHEMASP, error, 2099 node, XML_FROM_SCHEMASP, error,
2100 errorLevel, NULL, 0, 2100 errorLevel, NULL, 0,
2101 (const char *) str1, (const char *) str2, 2101 (const char *) str1, (const char *) str2,
2102 (const char *) str3, 0, 0, msg, str1, str2, str3, str4); 2102 (const char *) str3, 0, 0, msg, str1, str2, str3, str4);
2103 } else { 2103 } else {
2104 TODO 2104 TODO
2105 } 2105 }
2106 } 2106 }
2107 } 2107 }
2108 2108
2109 /** 2109 /**
2110 * xmlSchemaErr3: 2110 * xmlSchemaErr3:
2111 * @ctxt: the validation context 2111 * @ctxt: the validation context
2112 * @node: the context node 2112 * @node: the context node
2113 * @error: the error code 2113 * @error: the error code
2114 * @msg: the error message 2114 * @msg: the error message
2115 * @str1: extra data 2115 * @str1: extra data
2116 * @str2: extra data 2116 * @str2: extra data
2117 * @str3: extra data 2117 * @str3: extra data
2118 * 2118 *
2119 * Handle a validation error 2119 * Handle a validation error
2120 */ 2120 */
2121 static void 2121 static void
2122 xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt, 2122 xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt,
2123 int error, xmlNodePtr node, const char *msg, 2123 int error, xmlNodePtr node, const char *msg,
2124 const xmlChar *str1, const xmlChar *str2, const xmlChar *str3) 2124 const xmlChar *str1, const xmlChar *str2, const xmlChar *str3)
2125 { 2125 {
2126 xmlSchemaErr4Line(actxt, XML_ERR_ERROR, error, node, 0, 2126 xmlSchemaErr4Line(actxt, XML_ERR_ERROR, error, node, 0,
2127 msg, str1, str2, str3, NULL); 2127 msg, str1, str2, str3, NULL);
2128 } 2128 }
2129 2129
2130 static void 2130 static void
2131 xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt, 2131 xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt,
2132 int error, xmlNodePtr node, const char *msg, 2132 int error, xmlNodePtr node, const char *msg,
2133 const xmlChar *str1, const xmlChar *str2, 2133 const xmlChar *str1, const xmlChar *str2,
2134 const xmlChar *str3, const xmlChar *str4) 2134 const xmlChar *str3, const xmlChar *str4)
2135 { 2135 {
2136 xmlSchemaErr4Line(actxt, XML_ERR_ERROR, error, node, 0, 2136 xmlSchemaErr4Line(actxt, XML_ERR_ERROR, error, node, 0,
2137 msg, str1, str2, str3, str4); 2137 msg, str1, str2, str3, str4);
2138 } 2138 }
2139 2139
2140 static void 2140 static void
2141 xmlSchemaErr(xmlSchemaAbstractCtxtPtr actxt, 2141 xmlSchemaErr(xmlSchemaAbstractCtxtPtr actxt,
2142 int error, xmlNodePtr node, const char *msg, 2142 int error, xmlNodePtr node, const char *msg,
2143 const xmlChar *str1, const xmlChar *str2) 2143 const xmlChar *str1, const xmlChar *str2)
2144 { 2144 {
2145 xmlSchemaErr4(actxt, error, node, msg, str1, str2, NULL, NULL); 2145 xmlSchemaErr4(actxt, error, node, msg, str1, str2, NULL, NULL);
2146 } 2146 }
2147 2147
2148 static xmlChar * 2148 static xmlChar *
2149 xmlSchemaFormatNodeForError(xmlChar ** msg, 2149 xmlSchemaFormatNodeForError(xmlChar ** msg,
2150 xmlSchemaAbstractCtxtPtr actxt, 2150 xmlSchemaAbstractCtxtPtr actxt,
2151 xmlNodePtr node) 2151 xmlNodePtr node)
2152 { 2152 {
2153 xmlChar *str = NULL; 2153 xmlChar *str = NULL;
2154 2154
2155 *msg = NULL; 2155 *msg = NULL;
2156 if ((node != NULL) && 2156 if ((node != NULL) &&
2157 (node->type != XML_ELEMENT_NODE) && 2157 (node->type != XML_ELEMENT_NODE) &&
2158 (node->type != XML_ATTRIBUTE_NODE)) 2158 (node->type != XML_ATTRIBUTE_NODE))
2159 { 2159 {
2160 » /* 2160 » /*
2161 * Don't try to format other nodes than element and 2161 * Don't try to format other nodes than element and
2162 * attribute nodes. 2162 * attribute nodes.
2163 * Play save and return an empty string. 2163 * Play save and return an empty string.
2164 */ 2164 */
2165 *msg = xmlStrdup(BAD_CAST ""); 2165 *msg = xmlStrdup(BAD_CAST "");
2166 return(*msg); 2166 return(*msg);
2167 } 2167 }
2168 if (node != NULL) { 2168 if (node != NULL) {
2169 /* 2169 /*
2170 * Work on tree nodes. 2170 * Work on tree nodes.
2171 */ 2171 */
2172 if (node->type == XML_ATTRIBUTE_NODE) { 2172 if (node->type == XML_ATTRIBUTE_NODE) {
2173 xmlNodePtr elem = node->parent; 2173 xmlNodePtr elem = node->parent;
2174 » 2174
2175 *msg = xmlStrdup(BAD_CAST "Element '"); 2175 *msg = xmlStrdup(BAD_CAST "Element '");
2176 if (elem->ns != NULL) 2176 if (elem->ns != NULL)
2177 *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str, 2177 *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str,
2178 elem->ns->href, elem->name)); 2178 elem->ns->href, elem->name));
2179 else 2179 else
2180 *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str, 2180 *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str,
2181 NULL, elem->name)); 2181 NULL, elem->name));
2182 FREE_AND_NULL(str); 2182 FREE_AND_NULL(str);
2183 *msg = xmlStrcat(*msg, BAD_CAST "', "); 2183 *msg = xmlStrcat(*msg, BAD_CAST "', ");
2184 » *msg = xmlStrcat(*msg, BAD_CAST "attribute '");» 2184 » *msg = xmlStrcat(*msg, BAD_CAST "attribute '");
2185 } else { 2185 } else {
2186 *msg = xmlStrdup(BAD_CAST "Element '"); 2186 *msg = xmlStrdup(BAD_CAST "Element '");
2187 } 2187 }
2188 if (node->ns != NULL) 2188 if (node->ns != NULL)
2189 *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str, 2189 *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str,
2190 node->ns->href, node->name)); 2190 node->ns->href, node->name));
2191 else 2191 else
2192 *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str, 2192 *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str,
2193 NULL, node->name)); 2193 NULL, node->name));
2194 FREE_AND_NULL(str); 2194 FREE_AND_NULL(str);
2195 *msg = xmlStrcat(*msg, BAD_CAST "': "); 2195 *msg = xmlStrcat(*msg, BAD_CAST "': ");
2196 } else if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR) { 2196 } else if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR) {
2197 xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) actxt; 2197 xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) actxt;
2198 /* 2198 /*
2199 * Work on node infos. 2199 * Work on node infos.
2200 » */» 2200 » */
2201 if (vctxt->inode->nodeType == XML_ATTRIBUTE_NODE) { 2201 if (vctxt->inode->nodeType == XML_ATTRIBUTE_NODE) {
2202 xmlSchemaNodeInfoPtr ielem = 2202 xmlSchemaNodeInfoPtr ielem =
2203 vctxt->elemInfos[vctxt->depth]; 2203 vctxt->elemInfos[vctxt->depth];
2204 2204
2205 *msg = xmlStrdup(BAD_CAST "Element '"); 2205 *msg = xmlStrdup(BAD_CAST "Element '");
2206 *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str, 2206 *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str,
2207 ielem->nsName, ielem->localName)); 2207 ielem->nsName, ielem->localName));
2208 FREE_AND_NULL(str); 2208 FREE_AND_NULL(str);
2209 *msg = xmlStrcat(*msg, BAD_CAST "', "); 2209 *msg = xmlStrcat(*msg, BAD_CAST "', ");
2210 » *msg = xmlStrcat(*msg, BAD_CAST "attribute '");» 2210 » *msg = xmlStrcat(*msg, BAD_CAST "attribute '");
2211 } else { 2211 } else {
2212 *msg = xmlStrdup(BAD_CAST "Element '"); 2212 *msg = xmlStrdup(BAD_CAST "Element '");
2213 } 2213 }
2214 *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str, 2214 *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str,
2215 vctxt->inode->nsName, vctxt->inode->localName)); 2215 vctxt->inode->nsName, vctxt->inode->localName));
2216 FREE_AND_NULL(str); 2216 FREE_AND_NULL(str);
2217 *msg = xmlStrcat(*msg, BAD_CAST "': "); 2217 *msg = xmlStrcat(*msg, BAD_CAST "': ");
2218 } else if (actxt->type == XML_SCHEMA_CTXT_PARSER) { 2218 } else if (actxt->type == XML_SCHEMA_CTXT_PARSER) {
2219 » /* 2219 » /*
2220 * Hmm, no node while parsing? 2220 * Hmm, no node while parsing?
2221 * Return an empty string, in case NULL will break something. 2221 * Return an empty string, in case NULL will break something.
2222 */ 2222 */
2223 *msg = xmlStrdup(BAD_CAST ""); 2223 *msg = xmlStrdup(BAD_CAST "");
2224 } else { 2224 } else {
2225 TODO 2225 TODO
2226 return (NULL); 2226 return (NULL);
2227 } 2227 }
2228 /* 2228 /*
2229 * VAL TODO: The output of the given schema component is currently 2229 * VAL TODO: The output of the given schema component is currently
(...skipping 17 matching lines...) Expand all
2247 const char *message, 2247 const char *message,
2248 const xmlChar *str1, 2248 const xmlChar *str1,
2249 const xmlChar *str2) 2249 const xmlChar *str2)
2250 { 2250 {
2251 xmlChar *msg = NULL; 2251 xmlChar *msg = NULL;
2252 2252
2253 if (actxt == NULL) 2253 if (actxt == NULL)
2254 return; 2254 return;
2255 msg = xmlStrdup(BAD_CAST "Internal error: "); 2255 msg = xmlStrdup(BAD_CAST "Internal error: ");
2256 msg = xmlStrcat(msg, BAD_CAST funcName); 2256 msg = xmlStrcat(msg, BAD_CAST funcName);
2257 msg = xmlStrcat(msg, BAD_CAST ", "); 2257 msg = xmlStrcat(msg, BAD_CAST ", ");
2258 msg = xmlStrcat(msg, BAD_CAST message); 2258 msg = xmlStrcat(msg, BAD_CAST message);
2259 msg = xmlStrcat(msg, BAD_CAST ".\n"); 2259 msg = xmlStrcat(msg, BAD_CAST ".\n");
2260 2260
2261 if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR) 2261 if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR)
2262 xmlSchemaErr(actxt, XML_SCHEMAV_INTERNAL, NULL, 2262 xmlSchemaErr(actxt, XML_SCHEMAV_INTERNAL, NULL,
2263 (const char *) msg, str1, str2); 2263 (const char *) msg, str1, str2);
2264 2264
2265 else if (actxt->type == XML_SCHEMA_CTXT_PARSER)» 2265 else if (actxt->type == XML_SCHEMA_CTXT_PARSER)
2266 xmlSchemaErr(actxt, XML_SCHEMAP_INTERNAL, NULL, 2266 xmlSchemaErr(actxt, XML_SCHEMAP_INTERNAL, NULL,
2267 (const char *) msg, str1, str2); 2267 (const char *) msg, str1, str2);
2268 2268
2269 FREE_AND_NULL(msg) 2269 FREE_AND_NULL(msg)
2270 } 2270 }
2271 2271
2272 static void 2272 static void
2273 xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt, 2273 xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt,
2274 const char *funcName, 2274 const char *funcName,
2275 const char *message) 2275 const char *message)
(...skipping 26 matching lines...) Expand all
2302 xmlChar *msg = NULL; 2302 xmlChar *msg = NULL;
2303 2303
2304 if ((node == NULL) && (item != NULL) && 2304 if ((node == NULL) && (item != NULL) &&
2305 (actxt->type == XML_SCHEMA_CTXT_PARSER)) { 2305 (actxt->type == XML_SCHEMA_CTXT_PARSER)) {
2306 node = WXS_ITEM_NODE(item); 2306 node = WXS_ITEM_NODE(item);
2307 xmlSchemaFormatItemForReport(&msg, NULL, item, NULL); 2307 xmlSchemaFormatItemForReport(&msg, NULL, item, NULL);
2308 msg = xmlStrcat(msg, BAD_CAST ": "); 2308 msg = xmlStrcat(msg, BAD_CAST ": ");
2309 } else 2309 } else
2310 xmlSchemaFormatNodeForError(&msg, actxt, node); 2310 xmlSchemaFormatNodeForError(&msg, actxt, node);
2311 msg = xmlStrcat(msg, (const xmlChar *) message); 2311 msg = xmlStrcat(msg, (const xmlChar *) message);
2312 msg = xmlStrcat(msg, BAD_CAST ".\n"); 2312 msg = xmlStrcat(msg, BAD_CAST ".\n");
2313 xmlSchemaErr4(actxt, error, node, 2313 xmlSchemaErr4(actxt, error, node,
2314 (const char *) msg, str1, str2, str3, str4); 2314 (const char *) msg, str1, str2, str3, str4);
2315 FREE_AND_NULL(msg) 2315 FREE_AND_NULL(msg)
2316 } 2316 }
2317 2317
2318 static void 2318 static void
2319 xmlSchemaCustomErr(xmlSchemaAbstractCtxtPtr actxt, 2319 xmlSchemaCustomErr(xmlSchemaAbstractCtxtPtr actxt,
2320 xmlParserErrors error, 2320 xmlParserErrors error,
2321 xmlNodePtr node, 2321 xmlNodePtr node,
2322 xmlSchemaBasicItemPtr item, 2322 xmlSchemaBasicItemPtr item,
2323 const char *message, 2323 const char *message,
2324 const xmlChar *str1, 2324 const xmlChar *str1,
2325 const xmlChar *str2) 2325 const xmlChar *str2)
2326 { 2326 {
2327 xmlSchemaCustomErr4(actxt, error, node, item, 2327 xmlSchemaCustomErr4(actxt, error, node, item,
2328 » message, str1, str2, NULL, NULL); 2328 » message, str1, str2, NULL, NULL);
2329 } 2329 }
2330 2330
2331 2331
2332 2332
2333 static void 2333 static void
2334 xmlSchemaCustomWarning(xmlSchemaAbstractCtxtPtr actxt, 2334 xmlSchemaCustomWarning(xmlSchemaAbstractCtxtPtr actxt,
2335 xmlParserErrors error, 2335 xmlParserErrors error,
2336 xmlNodePtr node, 2336 xmlNodePtr node,
2337 xmlSchemaTypePtr type ATTRIBUTE_UNUSED, 2337 xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
2338 const char *message, 2338 const char *message,
2339 const xmlChar *str1, 2339 const xmlChar *str1,
2340 const xmlChar *str2, 2340 const xmlChar *str2,
2341 const xmlChar *str3) 2341 const xmlChar *str3)
2342 { 2342 {
2343 xmlChar *msg = NULL; 2343 xmlChar *msg = NULL;
2344 2344
2345 xmlSchemaFormatNodeForError(&msg, actxt, node); 2345 xmlSchemaFormatNodeForError(&msg, actxt, node);
2346 msg = xmlStrcat(msg, (const xmlChar *) message); 2346 msg = xmlStrcat(msg, (const xmlChar *) message);
2347 msg = xmlStrcat(msg, BAD_CAST ".\n"); 2347 msg = xmlStrcat(msg, BAD_CAST ".\n");
2348 2348
2349 /* URGENT TODO: Set the error code to something sane. */ 2349 /* URGENT TODO: Set the error code to something sane. */
2350 xmlSchemaErr4Line(actxt, XML_ERR_WARNING, error, node, 0, 2350 xmlSchemaErr4Line(actxt, XML_ERR_WARNING, error, node, 0,
2351 (const char *) msg, str1, str2, str3, NULL); 2351 (const char *) msg, str1, str2, str3, NULL);
2352 2352
2353 FREE_AND_NULL(msg) 2353 FREE_AND_NULL(msg)
2354 } 2354 }
2355 2355
2356 2356
2357 2357
2358 static void 2358 static void
2359 xmlSchemaKeyrefErr(xmlSchemaValidCtxtPtr vctxt, 2359 xmlSchemaKeyrefErr(xmlSchemaValidCtxtPtr vctxt,
2360 xmlParserErrors error, 2360 xmlParserErrors error,
2361 xmlSchemaPSVIIDCNodePtr idcNode, 2361 xmlSchemaPSVIIDCNodePtr idcNode,
2362 xmlSchemaTypePtr type ATTRIBUTE_UNUSED, 2362 xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
2363 const char *message, 2363 const char *message,
2364 const xmlChar *str1, 2364 const xmlChar *str1,
2365 const xmlChar *str2) 2365 const xmlChar *str2)
2366 { 2366 {
2367 xmlChar *msg = NULL, *qname = NULL; 2367 xmlChar *msg = NULL, *qname = NULL;
2368 2368
2369 msg = xmlStrdup(BAD_CAST "Element '%s': "); 2369 msg = xmlStrdup(BAD_CAST "Element '%s': ");
2370 msg = xmlStrcat(msg, (const xmlChar *) message); 2370 msg = xmlStrcat(msg, (const xmlChar *) message);
2371 msg = xmlStrcat(msg, BAD_CAST ".\n"); 2371 msg = xmlStrcat(msg, BAD_CAST ".\n");
2372 xmlSchemaErr4Line(ACTXT_CAST vctxt, XML_ERR_ERROR, 2372 xmlSchemaErr4Line(ACTXT_CAST vctxt, XML_ERR_ERROR,
2373 error, NULL, idcNode->nodeLine, (const char *) msg, 2373 error, NULL, idcNode->nodeLine, (const char *) msg,
2374 xmlSchemaFormatQName(&qname, 2374 xmlSchemaFormatQName(&qname,
2375 vctxt->nodeQNames->items[idcNode->nodeQNameID +1], 2375 vctxt->nodeQNames->items[idcNode->nodeQNameID +1],
2376 » vctxt->nodeQNames->items[idcNode->nodeQNameID]), 2376 » vctxt->nodeQNames->items[idcNode->nodeQNameID]),
2377 str1, str2, NULL); 2377 str1, str2, NULL);
2378 FREE_AND_NULL(qname); 2378 FREE_AND_NULL(qname);
2379 FREE_AND_NULL(msg); 2379 FREE_AND_NULL(msg);
2380 } 2380 }
2381 2381
2382 static int 2382 static int
2383 xmlSchemaEvalErrorNodeType(xmlSchemaAbstractCtxtPtr actxt, 2383 xmlSchemaEvalErrorNodeType(xmlSchemaAbstractCtxtPtr actxt,
2384 xmlNodePtr node) 2384 xmlNodePtr node)
2385 { 2385 {
2386 if (node != NULL) 2386 if (node != NULL)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 msg = xmlStrcat(msg, BAD_CAST "list type"); 2449 msg = xmlStrcat(msg, BAD_CAST "list type");
2450 else if (WXS_IS_UNION(type)) 2450 else if (WXS_IS_UNION(type))
2451 msg = xmlStrcat(msg, BAD_CAST "union type"); 2451 msg = xmlStrcat(msg, BAD_CAST "union type");
2452 2452
2453 if (xmlSchemaIsGlobalItem(type)) { 2453 if (xmlSchemaIsGlobalItem(type)) {
2454 xmlChar *str = NULL; 2454 xmlChar *str = NULL;
2455 msg = xmlStrcat(msg, BAD_CAST " '"); 2455 msg = xmlStrcat(msg, BAD_CAST " '");
2456 if (type->builtInType != 0) { 2456 if (type->builtInType != 0) {
2457 msg = xmlStrcat(msg, BAD_CAST "xs:"); 2457 msg = xmlStrcat(msg, BAD_CAST "xs:");
2458 msg = xmlStrcat(msg, type->name); 2458 msg = xmlStrcat(msg, type->name);
2459 » } else 2459 » } else
2460 msg = xmlStrcat(msg, 2460 msg = xmlStrcat(msg,
2461 xmlSchemaFormatQName(&str, 2461 xmlSchemaFormatQName(&str,
2462 type->targetNamespace, type->name)); 2462 type->targetNamespace, type->name));
2463 msg = xmlStrcat(msg, BAD_CAST "'"); 2463 msg = xmlStrcat(msg, BAD_CAST "'");
2464 FREE_AND_NULL(str); 2464 FREE_AND_NULL(str);
2465 } 2465 }
2466 msg = xmlStrcat(msg, BAD_CAST ".\n"); 2466 msg = xmlStrcat(msg, BAD_CAST ".\n");
2467 if (displayValue || (xmlSchemaEvalErrorNodeType(actxt, node) == 2467 if (displayValue || (xmlSchemaEvalErrorNodeType(actxt, node) ==
2468 XML_ATTRIBUTE_NODE)) 2468 XML_ATTRIBUTE_NODE))
2469 xmlSchemaErr(actxt, error, node, (const char *) msg, value, NULL); 2469 xmlSchemaErr(actxt, error, node, (const char *) msg, value, NULL);
(...skipping 17 matching lines...) Expand all
2487 return (NULL); 2487 return (NULL);
2488 } 2488 }
2489 2489
2490 static void 2490 static void
2491 xmlSchemaIllegalAttrErr(xmlSchemaAbstractCtxtPtr actxt, 2491 xmlSchemaIllegalAttrErr(xmlSchemaAbstractCtxtPtr actxt,
2492 xmlParserErrors error, 2492 xmlParserErrors error,
2493 xmlSchemaAttrInfoPtr ni, 2493 xmlSchemaAttrInfoPtr ni,
2494 xmlNodePtr node) 2494 xmlNodePtr node)
2495 { 2495 {
2496 xmlChar *msg = NULL, *str = NULL; 2496 xmlChar *msg = NULL, *str = NULL;
2497 2497
2498 xmlSchemaFormatNodeForError(&msg, actxt, node); 2498 xmlSchemaFormatNodeForError(&msg, actxt, node);
2499 msg = xmlStrcat(msg, BAD_CAST "The attribute '%s' is not allowed.\n"); 2499 msg = xmlStrcat(msg, BAD_CAST "The attribute '%s' is not allowed.\n");
2500 xmlSchemaErr(actxt, error, node, (const char *) msg, 2500 xmlSchemaErr(actxt, error, node, (const char *) msg,
2501 xmlSchemaFormatErrorNodeQName(&str, (xmlSchemaNodeInfoPtr) ni, node), 2501 xmlSchemaFormatErrorNodeQName(&str, (xmlSchemaNodeInfoPtr) ni, node),
2502 » NULL); 2502 » NULL);
2503 FREE_AND_NULL(str) 2503 FREE_AND_NULL(str)
2504 FREE_AND_NULL(msg) 2504 FREE_AND_NULL(msg)
2505 } 2505 }
2506 2506
2507 static void 2507 static void
2508 xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt, 2508 xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt,
2509 xmlParserErrors error, 2509 xmlParserErrors error,
2510 xmlNodePtr node, 2510 xmlNodePtr node,
2511 xmlSchemaTypePtr type ATTRIBUTE_UNUSED, 2511 xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
2512 const char *message, 2512 const char *message,
2513 int nbval, 2513 int nbval,
2514 int nbneg, 2514 int nbneg,
2515 xmlChar **values) 2515 xmlChar **values)
2516 { 2516 {
2517 xmlChar *str = NULL, *msg = NULL; 2517 xmlChar *str = NULL, *msg = NULL;
2518 xmlChar *localName, *nsName; 2518 xmlChar *localName, *nsName;
2519 const xmlChar *cur, *end; 2519 const xmlChar *cur, *end;
2520 int i; 2520 int i;
2521 2521
2522 xmlSchemaFormatNodeForError(&msg, actxt, node); 2522 xmlSchemaFormatNodeForError(&msg, actxt, node);
2523 msg = xmlStrcat(msg, (const xmlChar *) message); 2523 msg = xmlStrcat(msg, (const xmlChar *) message);
2524 msg = xmlStrcat(msg, BAD_CAST "."); 2524 msg = xmlStrcat(msg, BAD_CAST ".");
2525 /* 2525 /*
2526 * Note that is does not make sense to report that we have a 2526 * Note that is does not make sense to report that we have a
2527 * wildcard here, since the wildcard might be unfolded into 2527 * wildcard here, since the wildcard might be unfolded into
2528 * multiple transitions. 2528 * multiple transitions.
2529 */ 2529 */
2530 if (nbval + nbneg > 0) { 2530 if (nbval + nbneg > 0) {
2531 if (nbval + nbneg > 1) { 2531 if (nbval + nbneg > 1) {
2532 str = xmlStrdup(BAD_CAST " Expected is one of ( "); 2532 str = xmlStrdup(BAD_CAST " Expected is one of ( ");
2533 } else 2533 } else
2534 str = xmlStrdup(BAD_CAST " Expected is ( "); 2534 str = xmlStrdup(BAD_CAST " Expected is ( ");
2535 nsName = NULL; 2535 nsName = NULL;
2536 » 2536
2537 for (i = 0; i < nbval + nbneg; i++) { 2537 for (i = 0; i < nbval + nbneg; i++) {
2538 cur = values[i]; 2538 cur = values[i];
2539 if (cur == NULL) 2539 if (cur == NULL)
2540 continue; 2540 continue;
2541 if ((cur[0] == 'n') && (cur[1] == 'o') && (cur[2] == 't') && 2541 if ((cur[0] == 'n') && (cur[1] == 'o') && (cur[2] == 't') &&
2542 (cur[3] == ' ')) { 2542 (cur[3] == ' ')) {
2543 cur += 4; 2543 cur += 4;
2544 str = xmlStrcat(str, BAD_CAST "##other"); 2544 str = xmlStrcat(str, BAD_CAST "##other");
2545 } 2545 }
2546 /* 2546 /*
2547 * Get the local name. 2547 * Get the local name.
2548 */ 2548 */
2549 localName = NULL; 2549 localName = NULL;
2550 » 2550
2551 end = cur; 2551 end = cur;
2552 if (*end == '*') { 2552 if (*end == '*') {
2553 localName = xmlStrdup(BAD_CAST "*"); 2553 localName = xmlStrdup(BAD_CAST "*");
2554 end++; 2554 end++;
2555 } else { 2555 } else {
2556 while ((*end != 0) && (*end != '|')) 2556 while ((*end != 0) && (*end != '|'))
2557 end++; 2557 end++;
2558 localName = xmlStrncat(localName, BAD_CAST cur, end - cur); 2558 localName = xmlStrncat(localName, BAD_CAST cur, end - cur);
2559 » }» » 2559 » }
2560 » if (*end != 0) {» » 2560 » if (*end != 0) {
2561 end++; 2561 end++;
2562 /* 2562 /*
2563 * Skip "*|*" if they come with negated expressions, since 2563 * Skip "*|*" if they come with negated expressions, since
2564 * they represent the same negated wildcard. 2564 * they represent the same negated wildcard.
2565 */ 2565 */
2566 if ((nbneg == 0) || (*end != '*') || (*localName != '*')) { 2566 if ((nbneg == 0) || (*end != '*') || (*localName != '*')) {
2567 /* 2567 /*
2568 * Get the namespace name. 2568 * Get the namespace name.
2569 */ 2569 */
2570 cur = end; 2570 cur = end;
2571 if (*end == '*') { 2571 if (*end == '*') {
2572 nsName = xmlStrdup(BAD_CAST "{*}"); 2572 nsName = xmlStrdup(BAD_CAST "{*}");
2573 } else { 2573 } else {
2574 while (*end != 0) 2574 while (*end != 0)
2575 end++; 2575 end++;
2576 » » » 2576
2577 if (i >= nbval) 2577 if (i >= nbval)
2578 nsName = xmlStrdup(BAD_CAST "{##other:"); 2578 nsName = xmlStrdup(BAD_CAST "{##other:");
2579 else 2579 else
2580 nsName = xmlStrdup(BAD_CAST "{"); 2580 nsName = xmlStrdup(BAD_CAST "{");
2581 » » » 2581
2582 nsName = xmlStrncat(nsName, BAD_CAST cur, end - cur); 2582 nsName = xmlStrncat(nsName, BAD_CAST cur, end - cur);
2583 nsName = xmlStrcat(nsName, BAD_CAST "}"); 2583 nsName = xmlStrcat(nsName, BAD_CAST "}");
2584 } 2584 }
2585 str = xmlStrcat(str, BAD_CAST nsName); 2585 str = xmlStrcat(str, BAD_CAST nsName);
2586 FREE_AND_NULL(nsName) 2586 FREE_AND_NULL(nsName)
2587 } else { 2587 } else {
2588 FREE_AND_NULL(localName); 2588 FREE_AND_NULL(localName);
2589 continue; 2589 continue;
2590 } 2590 }
2591 » }» 2591 » }
2592 str = xmlStrcat(str, BAD_CAST localName); 2592 str = xmlStrcat(str, BAD_CAST localName);
2593 FREE_AND_NULL(localName); 2593 FREE_AND_NULL(localName);
2594 » » 2594
2595 if (i < nbval + nbneg -1) 2595 if (i < nbval + nbneg -1)
2596 str = xmlStrcat(str, BAD_CAST ", "); 2596 str = xmlStrcat(str, BAD_CAST ", ");
2597 » }» 2597 » }
2598 str = xmlStrcat(str, BAD_CAST " ).\n"); 2598 str = xmlStrcat(str, BAD_CAST " ).\n");
2599 msg = xmlStrcat(msg, BAD_CAST str); 2599 msg = xmlStrcat(msg, BAD_CAST str);
2600 FREE_AND_NULL(str) 2600 FREE_AND_NULL(str)
2601 } else 2601 } else
2602 msg = xmlStrcat(msg, BAD_CAST "\n"); 2602 msg = xmlStrcat(msg, BAD_CAST "\n");
2603 xmlSchemaErr(actxt, error, node, (const char *) msg, NULL, NULL); 2603 xmlSchemaErr(actxt, error, node, (const char *) msg, NULL, NULL);
2604 xmlFree(msg); 2604 xmlFree(msg);
2605 } 2605 }
2606 2606
2607 static void 2607 static void
(...skipping 11 matching lines...) Expand all
2619 xmlChar *str = NULL, *msg = NULL; 2619 xmlChar *str = NULL, *msg = NULL;
2620 xmlSchemaTypeType facetType; 2620 xmlSchemaTypeType facetType;
2621 int nodeType = xmlSchemaEvalErrorNodeType(actxt, node); 2621 int nodeType = xmlSchemaEvalErrorNodeType(actxt, node);
2622 2622
2623 xmlSchemaFormatNodeForError(&msg, actxt, node); 2623 xmlSchemaFormatNodeForError(&msg, actxt, node);
2624 if (error == XML_SCHEMAV_CVC_ENUMERATION_VALID) { 2624 if (error == XML_SCHEMAV_CVC_ENUMERATION_VALID) {
2625 facetType = XML_SCHEMA_FACET_ENUMERATION; 2625 facetType = XML_SCHEMA_FACET_ENUMERATION;
2626 /* 2626 /*
2627 * If enumerations are validated, one must not expect the 2627 * If enumerations are validated, one must not expect the
2628 * facet to be given. 2628 * facet to be given.
2629 » */» 2629 » */
2630 } else» 2630 } else
2631 facetType = facet->type; 2631 facetType = facet->type;
2632 msg = xmlStrcat(msg, BAD_CAST "["); 2632 msg = xmlStrcat(msg, BAD_CAST "[");
2633 msg = xmlStrcat(msg, BAD_CAST "facet '"); 2633 msg = xmlStrcat(msg, BAD_CAST "facet '");
2634 msg = xmlStrcat(msg, xmlSchemaFacetTypeToString(facetType)); 2634 msg = xmlStrcat(msg, xmlSchemaFacetTypeToString(facetType));
2635 msg = xmlStrcat(msg, BAD_CAST "'] "); 2635 msg = xmlStrcat(msg, BAD_CAST "'] ");
2636 if (message == NULL) { 2636 if (message == NULL) {
2637 /* 2637 /*
2638 * Use a default message. 2638 * Use a default message.
2639 */ 2639 */
2640 if ((facetType == XML_SCHEMA_FACET_LENGTH) || 2640 if ((facetType == XML_SCHEMA_FACET_LENGTH) ||
2641 (facetType == XML_SCHEMA_FACET_MINLENGTH) || 2641 (facetType == XML_SCHEMA_FACET_MINLENGTH) ||
2642 (facetType == XML_SCHEMA_FACET_MAXLENGTH)) { 2642 (facetType == XML_SCHEMA_FACET_MAXLENGTH)) {
2643 2643
2644 char len[25], actLen[25]; 2644 char len[25], actLen[25];
2645 2645
2646 /* FIXME, TODO: What is the max expected string length of the 2646 /* FIXME, TODO: What is the max expected string length of the
2647 * this value? 2647 * this value?
2648 */ 2648 */
2649 if (nodeType == XML_ATTRIBUTE_NODE) 2649 if (nodeType == XML_ATTRIBUTE_NODE)
2650 msg = xmlStrcat(msg, BAD_CAST "The value '%s' has a length of '% s'; "); 2650 msg = xmlStrcat(msg, BAD_CAST "The value '%s' has a length of '% s'; ");
2651 else 2651 else
2652 msg = xmlStrcat(msg, BAD_CAST "The value has a length of '%s'; " ); 2652 msg = xmlStrcat(msg, BAD_CAST "The value has a length of '%s'; " );
2653 2653
2654 snprintf(len, 24, "%lu", xmlSchemaGetFacetValueAsULong(facet)); 2654 snprintf(len, 24, "%lu", xmlSchemaGetFacetValueAsULong(facet));
2655 snprintf(actLen, 24, "%lu", length); 2655 snprintf(actLen, 24, "%lu", length);
2656 2656
2657 if (facetType == XML_SCHEMA_FACET_LENGTH) 2657 if (facetType == XML_SCHEMA_FACET_LENGTH)
2658 » » msg = xmlStrcat(msg, 2658 » » msg = xmlStrcat(msg,
2659 » » BAD_CAST "this differs from the allowed length of '%s'.\n"); 2659 » » BAD_CAST "this differs from the allowed length of '%s'.\n");
2660 else if (facetType == XML_SCHEMA_FACET_MAXLENGTH) 2660 else if (facetType == XML_SCHEMA_FACET_MAXLENGTH)
2661 » » msg = xmlStrcat(msg, 2661 » » msg = xmlStrcat(msg,
2662 BAD_CAST "this exceeds the allowed maximum length of '%s'.\n"); 2662 BAD_CAST "this exceeds the allowed maximum length of '%s'.\n");
2663 else if (facetType == XML_SCHEMA_FACET_MINLENGTH) 2663 else if (facetType == XML_SCHEMA_FACET_MINLENGTH)
2664 » » msg = xmlStrcat(msg, 2664 » » msg = xmlStrcat(msg,
2665 BAD_CAST "this underruns the allowed minimum length of '%s'.\n") ; 2665 BAD_CAST "this underruns the allowed minimum length of '%s'.\n") ;
2666 » 2666
2667 if (nodeType == XML_ATTRIBUTE_NODE) 2667 if (nodeType == XML_ATTRIBUTE_NODE)
2668 xmlSchemaErr3(actxt, error, node, (const char *) msg, 2668 xmlSchemaErr3(actxt, error, node, (const char *) msg,
2669 value, (const xmlChar *) actLen, (const xmlChar *) len); 2669 value, (const xmlChar *) actLen, (const xmlChar *) len);
2670 » else 2670 » else
2671 xmlSchemaErr(actxt, error, node, (const char *) msg, 2671 xmlSchemaErr(actxt, error, node, (const char *) msg,
2672 (const xmlChar *) actLen, (const xmlChar *) len); 2672 (const xmlChar *) actLen, (const xmlChar *) len);
2673 » 2673
2674 } else if (facetType == XML_SCHEMA_FACET_ENUMERATION) { 2674 } else if (facetType == XML_SCHEMA_FACET_ENUMERATION) {
2675 msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not an element " 2675 msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not an element "
2676 "of the set {%s}.\n"); 2676 "of the set {%s}.\n");
2677 » xmlSchemaErr(actxt, error, node, (const char *) msg, value, 2677 » xmlSchemaErr(actxt, error, node, (const char *) msg, value,
2678 xmlSchemaFormatFacetEnumSet(actxt, &str, type)); 2678 xmlSchemaFormatFacetEnumSet(actxt, &str, type));
2679 } else if (facetType == XML_SCHEMA_FACET_PATTERN) { 2679 } else if (facetType == XML_SCHEMA_FACET_PATTERN) {
2680 msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not accepted " 2680 msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not accepted "
2681 "by the pattern '%s'.\n"); 2681 "by the pattern '%s'.\n");
2682 » xmlSchemaErr(actxt, error, node, (const char *) msg, value, 2682 » xmlSchemaErr(actxt, error, node, (const char *) msg, value,
2683 facet->value); 2683 facet->value);
2684 } else if (facetType == XML_SCHEMA_FACET_MININCLUSIVE) { 2684 } else if (facetType == XML_SCHEMA_FACET_MININCLUSIVE) {
2685 msg = xmlStrcat(msg, BAD_CAST "The value '%s' is less than the " 2685 msg = xmlStrcat(msg, BAD_CAST "The value '%s' is less than the "
2686 "minimum value allowed ('%s').\n"); 2686 "minimum value allowed ('%s').\n");
2687 xmlSchemaErr(actxt, error, node, (const char *) msg, value, 2687 xmlSchemaErr(actxt, error, node, (const char *) msg, value,
2688 facet->value); 2688 facet->value);
2689 } else if (facetType == XML_SCHEMA_FACET_MAXINCLUSIVE) { 2689 } else if (facetType == XML_SCHEMA_FACET_MAXINCLUSIVE) {
2690 msg = xmlStrcat(msg, BAD_CAST "The value '%s' is greater than the " 2690 msg = xmlStrcat(msg, BAD_CAST "The value '%s' is greater than the "
2691 "maximum value allowed ('%s').\n"); 2691 "maximum value allowed ('%s').\n");
2692 xmlSchemaErr(actxt, error, node, (const char *) msg, value, 2692 xmlSchemaErr(actxt, error, node, (const char *) msg, value,
(...skipping 11 matching lines...) Expand all
2704 } else if (facetType == XML_SCHEMA_FACET_TOTALDIGITS) { 2704 } else if (facetType == XML_SCHEMA_FACET_TOTALDIGITS) {
2705 msg = xmlStrcat(msg, BAD_CAST "The value '%s' has more " 2705 msg = xmlStrcat(msg, BAD_CAST "The value '%s' has more "
2706 "digits than are allowed ('%s').\n"); 2706 "digits than are allowed ('%s').\n");
2707 xmlSchemaErr(actxt, error, node, (const char*) msg, value, 2707 xmlSchemaErr(actxt, error, node, (const char*) msg, value,
2708 facet->value); 2708 facet->value);
2709 } else if (facetType == XML_SCHEMA_FACET_FRACTIONDIGITS) { 2709 } else if (facetType == XML_SCHEMA_FACET_FRACTIONDIGITS) {
2710 msg = xmlStrcat(msg, BAD_CAST "The value '%s' has more fractional " 2710 msg = xmlStrcat(msg, BAD_CAST "The value '%s' has more fractional "
2711 "digits than are allowed ('%s').\n"); 2711 "digits than are allowed ('%s').\n");
2712 xmlSchemaErr(actxt, error, node, (const char*) msg, value, 2712 xmlSchemaErr(actxt, error, node, (const char*) msg, value,
2713 facet->value); 2713 facet->value);
2714 » } else if (nodeType == XML_ATTRIBUTE_NODE) {» » 2714 » } else if (nodeType == XML_ATTRIBUTE_NODE) {
2715 msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not facet-valid.\n" ); 2715 msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not facet-valid.\n" );
2716 » xmlSchemaErr(actxt, error, node, (const char *) msg, value, NULL);» 2716 » xmlSchemaErr(actxt, error, node, (const char *) msg, value, NULL);
2717 » } else {» 2717 » } else {
2718 msg = xmlStrcat(msg, BAD_CAST "The value is not facet-valid.\n"); 2718 msg = xmlStrcat(msg, BAD_CAST "The value is not facet-valid.\n");
2719 xmlSchemaErr(actxt, error, node, (const char *) msg, NULL, NULL); 2719 xmlSchemaErr(actxt, error, node, (const char *) msg, NULL, NULL);
2720 } 2720 }
2721 } else { 2721 } else {
2722 msg = xmlStrcat(msg, (const xmlChar *) message); 2722 msg = xmlStrcat(msg, (const xmlChar *) message);
2723 msg = xmlStrcat(msg, BAD_CAST ".\n"); 2723 msg = xmlStrcat(msg, BAD_CAST ".\n");
2724 xmlSchemaErr(actxt, error, node, (const char *) msg, str1, str2); 2724 xmlSchemaErr(actxt, error, node, (const char *) msg, str1, str2);
2725 } 2725 }
2726 FREE_AND_NULL(str) 2726 FREE_AND_NULL(str)
2727 xmlFree(msg); 2727 xmlFree(msg);
2728 } 2728 }
2729 2729
2730 #define VERROR(err, type, msg) \ 2730 #define VERROR(err, type, msg) \
2731 xmlSchemaCustomErr(ACTXT_CAST vctxt, err, NULL, type, msg, NULL, NULL); 2731 xmlSchemaCustomErr(ACTXT_CAST vctxt, err, NULL, type, msg, NULL, NULL);
2732 2732
2733 #define VERROR_INT(func, msg) xmlSchemaInternalErr(ACTXT_CAST vctxt, func, msg); 2733 #define VERROR_INT(func, msg) xmlSchemaInternalErr(ACTXT_CAST vctxt, func, msg);
2734 2734
2735 #define PERROR_INT(func, msg) xmlSchemaInternalErr(ACTXT_CAST pctxt, func, msg); 2735 #define PERROR_INT(func, msg) xmlSchemaInternalErr(ACTXT_CAST pctxt, func, msg);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
2960 xmlSchemaPAttrUseErr4(xmlSchemaParserCtxtPtr ctxt, 2960 xmlSchemaPAttrUseErr4(xmlSchemaParserCtxtPtr ctxt,
2961 xmlParserErrors error, 2961 xmlParserErrors error,
2962 xmlNodePtr node, 2962 xmlNodePtr node,
2963 xmlSchemaBasicItemPtr ownerItem, 2963 xmlSchemaBasicItemPtr ownerItem,
2964 const xmlSchemaAttributeUsePtr attruse, 2964 const xmlSchemaAttributeUsePtr attruse,
2965 const char *message, 2965 const char *message,
2966 const xmlChar *str1, const xmlChar *str2, 2966 const xmlChar *str1, const xmlChar *str2,
2967 const xmlChar *str3,const xmlChar *str4) 2967 const xmlChar *str3,const xmlChar *str4)
2968 { 2968 {
2969 xmlChar *str = NULL, *msg = NULL; 2969 xmlChar *str = NULL, *msg = NULL;
2970 2970
2971 xmlSchemaFormatItemForReport(&msg, NULL, ownerItem, NULL); 2971 xmlSchemaFormatItemForReport(&msg, NULL, ownerItem, NULL);
2972 msg = xmlStrcat(msg, BAD_CAST ", "); 2972 msg = xmlStrcat(msg, BAD_CAST ", ");
2973 msg = xmlStrcat(msg, 2973 msg = xmlStrcat(msg,
2974 BAD_CAST xmlSchemaFormatItemForReport(&str, NULL, 2974 BAD_CAST xmlSchemaFormatItemForReport(&str, NULL,
2975 WXS_BASIC_CAST attruse, NULL)); 2975 WXS_BASIC_CAST attruse, NULL));
2976 FREE_AND_NULL(str); 2976 FREE_AND_NULL(str);
2977 msg = xmlStrcat(msg, BAD_CAST ": "); 2977 msg = xmlStrcat(msg, BAD_CAST ": ");
2978 msg = xmlStrcat(msg, (const xmlChar *) message); 2978 msg = xmlStrcat(msg, (const xmlChar *) message);
2979 msg = xmlStrcat(msg, BAD_CAST ".\n"); 2979 msg = xmlStrcat(msg, BAD_CAST ".\n");
2980 xmlSchemaErr4(ACTXT_CAST ctxt, error, node, 2980 xmlSchemaErr4(ACTXT_CAST ctxt, error, node,
2981 (const char *) msg, str1, str2, str3, str4); 2981 (const char *) msg, str1, str2, str3, str4);
2982 xmlFree(msg); 2982 xmlFree(msg);
2983 } 2983 }
2984 2984
2985 /** 2985 /**
2986 * xmlSchemaPIllegalFacetAtomicErr: 2986 * xmlSchemaPIllegalFacetAtomicErr:
2987 * @ctxt: the schema parser context 2987 * @ctxt: the schema parser context
2988 * @error: the error code 2988 * @error: the error code
2989 * @type: the schema type 2989 * @type: the schema type
2990 * @baseType: the base type of type 2990 * @baseType: the base type of type
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
3064 BAD_CAST des, BAD_CAST name1, BAD_CAST name2, NULL, NULL); 3064 BAD_CAST des, BAD_CAST name1, BAD_CAST name2, NULL, NULL);
3065 FREE_AND_NULL(des); 3065 FREE_AND_NULL(des);
3066 } 3066 }
3067 3067
3068 /** 3068 /**
3069 * xmlSchemaPSimpleTypeErr: 3069 * xmlSchemaPSimpleTypeErr:
3070 * @ctxt: the schema validation context 3070 * @ctxt: the schema validation context
3071 * @error: the error code 3071 * @error: the error code
3072 * @type: the type specifier 3072 * @type: the type specifier
3073 * @ownerDes: the designation of the owner 3073 * @ownerDes: the designation of the owner
3074 * @ownerItem: the schema object if existent 3074 * @ownerItem: the schema object if existent
3075 * @node: the validated node 3075 * @node: the validated node
3076 * @value: the validated value 3076 * @value: the validated value
3077 * 3077 *
3078 * Reports a simple type validation error. 3078 * Reports a simple type validation error.
3079 * TODO: Should this report the value of an element as well? 3079 * TODO: Should this report the value of an element as well?
3080 */ 3080 */
3081 static void 3081 static void
3082 xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt, 3082 xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt,
3083 xmlParserErrors error, 3083 xmlParserErrors error,
3084 xmlSchemaBasicItemPtr ownerItem ATTRIBUTE_UNUSED, 3084 xmlSchemaBasicItemPtr ownerItem ATTRIBUTE_UNUSED,
3085 xmlNodePtr node, 3085 xmlNodePtr node,
3086 xmlSchemaTypePtr type, 3086 xmlSchemaTypePtr type,
3087 const char *expected, 3087 const char *expected,
3088 const xmlChar *value, 3088 const xmlChar *value,
3089 const char *message, 3089 const char *message,
3090 const xmlChar *str1, 3090 const xmlChar *str1,
3091 const xmlChar *str2) 3091 const xmlChar *str2)
3092 { 3092 {
3093 xmlChar *msg = NULL; 3093 xmlChar *msg = NULL;
3094 3094
3095 xmlSchemaFormatNodeForError(&msg, ACTXT_CAST ctxt, node); 3095 xmlSchemaFormatNodeForError(&msg, ACTXT_CAST ctxt, node);
3096 if (message == NULL) { 3096 if (message == NULL) {
3097 /* 3097 /*
3098 * Use default messages. 3098 * Use default messages.
3099 » */» 3099 » */
3100 if (type != NULL) { 3100 if (type != NULL) {
3101 if (node->type == XML_ATTRIBUTE_NODE) 3101 if (node->type == XML_ATTRIBUTE_NODE)
3102 msg = xmlStrcat(msg, BAD_CAST "'%s' is not a valid value of "); 3102 msg = xmlStrcat(msg, BAD_CAST "'%s' is not a valid value of ");
3103 else 3103 else
3104 msg = xmlStrcat(msg, BAD_CAST "The character content is not a " 3104 msg = xmlStrcat(msg, BAD_CAST "The character content is not a "
3105 » » "valid value of ");» 3105 » » "valid value of ");
3106 if (! xmlSchemaIsGlobalItem(type)) 3106 if (! xmlSchemaIsGlobalItem(type))
3107 msg = xmlStrcat(msg, BAD_CAST "the local "); 3107 msg = xmlStrcat(msg, BAD_CAST "the local ");
3108 else 3108 else
3109 msg = xmlStrcat(msg, BAD_CAST "the "); 3109 msg = xmlStrcat(msg, BAD_CAST "the ");
3110 » 3110
3111 if (WXS_IS_ATOMIC(type)) 3111 if (WXS_IS_ATOMIC(type))
3112 msg = xmlStrcat(msg, BAD_CAST "atomic type"); 3112 msg = xmlStrcat(msg, BAD_CAST "atomic type");
3113 else if (WXS_IS_LIST(type)) 3113 else if (WXS_IS_LIST(type))
3114 msg = xmlStrcat(msg, BAD_CAST "list type"); 3114 msg = xmlStrcat(msg, BAD_CAST "list type");
3115 else if (WXS_IS_UNION(type)) 3115 else if (WXS_IS_UNION(type))
3116 msg = xmlStrcat(msg, BAD_CAST "union type"); 3116 msg = xmlStrcat(msg, BAD_CAST "union type");
3117 » 3117
3118 if (xmlSchemaIsGlobalItem(type)) { 3118 if (xmlSchemaIsGlobalItem(type)) {
3119 xmlChar *str = NULL; 3119 xmlChar *str = NULL;
3120 msg = xmlStrcat(msg, BAD_CAST " '"); 3120 msg = xmlStrcat(msg, BAD_CAST " '");
3121 if (type->builtInType != 0) { 3121 if (type->builtInType != 0) {
3122 msg = xmlStrcat(msg, BAD_CAST "xs:"); 3122 msg = xmlStrcat(msg, BAD_CAST "xs:");
3123 msg = xmlStrcat(msg, type->name); 3123 msg = xmlStrcat(msg, type->name);
3124 » » } else 3124 » » } else
3125 msg = xmlStrcat(msg, 3125 msg = xmlStrcat(msg,
3126 xmlSchemaFormatQName(&str, 3126 xmlSchemaFormatQName(&str,
3127 type->targetNamespace, type->name)); 3127 type->targetNamespace, type->name));
3128 msg = xmlStrcat(msg, BAD_CAST "'."); 3128 msg = xmlStrcat(msg, BAD_CAST "'.");
3129 FREE_AND_NULL(str); 3129 FREE_AND_NULL(str);
3130 } 3130 }
3131 } else { 3131 } else {
3132 if (node->type == XML_ATTRIBUTE_NODE) 3132 if (node->type == XML_ATTRIBUTE_NODE)
3133 msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not valid."); 3133 msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not valid.");
3134 else 3134 else
3135 msg = xmlStrcat(msg, BAD_CAST "The character content is not " 3135 msg = xmlStrcat(msg, BAD_CAST "The character content is not "
3136 "valid."); 3136 "valid.");
3137 » }» 3137 » }
3138 if (expected) { 3138 if (expected) {
3139 msg = xmlStrcat(msg, BAD_CAST " Expected is '"); 3139 msg = xmlStrcat(msg, BAD_CAST " Expected is '");
3140 msg = xmlStrcat(msg, BAD_CAST expected); 3140 msg = xmlStrcat(msg, BAD_CAST expected);
3141 msg = xmlStrcat(msg, BAD_CAST "'.\n"); 3141 msg = xmlStrcat(msg, BAD_CAST "'.\n");
3142 } else 3142 } else
3143 msg = xmlStrcat(msg, BAD_CAST "\n"); 3143 msg = xmlStrcat(msg, BAD_CAST "\n");
3144 if (node->type == XML_ATTRIBUTE_NODE) 3144 if (node->type == XML_ATTRIBUTE_NODE)
3145 xmlSchemaPErr(ctxt, node, error, (const char *) msg, value, NULL); 3145 xmlSchemaPErr(ctxt, node, error, (const char *) msg, value, NULL);
3146 else 3146 else
3147 xmlSchemaPErr(ctxt, node, error, (const char *) msg, NULL, NULL); 3147 xmlSchemaPErr(ctxt, node, error, (const char *) msg, NULL, NULL);
3148 } else { 3148 } else {
3149 msg = xmlStrcat(msg, BAD_CAST message); 3149 msg = xmlStrcat(msg, BAD_CAST message);
3150 msg = xmlStrcat(msg, BAD_CAST ".\n"); 3150 msg = xmlStrcat(msg, BAD_CAST ".\n");
3151 xmlSchemaPErrExt(ctxt, node, error, NULL, NULL, NULL, 3151 xmlSchemaPErrExt(ctxt, node, error, NULL, NULL, NULL,
3152 (const char*) msg, str1, str2, NULL, NULL, NULL); 3152 (const char*) msg, str1, str2, NULL, NULL, NULL);
3153 } 3153 }
3154 /* Cleanup. */ 3154 /* Cleanup. */
3155 FREE_AND_NULL(msg) 3155 FREE_AND_NULL(msg)
3156 } 3156 }
3157 3157
3158 /** 3158 /**
3159 * xmlSchemaPContentErr: 3159 * xmlSchemaPContentErr:
3160 * @ctxt: the schema parser context 3160 * @ctxt: the schema parser context
3161 * @error: the error code 3161 * @error: the error code
3162 * @onwerDes: the designation of the holder of the content 3162 * @onwerDes: the designation of the holder of the content
3163 * @ownerItem: the owner item of the holder of the content 3163 * @ownerItem: the owner item of the holder of the content
3164 * @ownerElem: the node of the holder of the content 3164 * @ownerElem: the node of the holder of the content
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
3365 list->sizeItems = 0; 3365 list->sizeItems = 0;
3366 return(-1); 3366 return(-1);
3367 } 3367 }
3368 } 3368 }
3369 list->items[list->nbItems++] = item; 3369 list->items[list->nbItems++] = item;
3370 return(0); 3370 return(0);
3371 } 3371 }
3372 3372
3373 static int 3373 static int
3374 xmlSchemaItemListInsert(xmlSchemaItemListPtr list, void *item, int idx) 3374 xmlSchemaItemListInsert(xmlSchemaItemListPtr list, void *item, int idx)
3375 { 3375 {
3376 if (list->items == NULL) { 3376 if (list->items == NULL) {
3377 list->items = (void **) xmlMalloc( 3377 list->items = (void **) xmlMalloc(
3378 20 * sizeof(void *)); 3378 20 * sizeof(void *));
3379 if (list->items == NULL) { 3379 if (list->items == NULL) {
3380 xmlSchemaPErrMemory(NULL, "allocating new item list", NULL); 3380 xmlSchemaPErrMemory(NULL, "allocating new item list", NULL);
3381 return(-1); 3381 return(-1);
3382 } 3382 }
3383 list->sizeItems = 20; 3383 list->sizeItems = 20;
3384 } else if (list->sizeItems <= list->nbItems) { 3384 } else if (list->sizeItems <= list->nbItems) {
3385 list->sizeItems *= 2; 3385 list->sizeItems *= 2;
(...skipping 19 matching lines...) Expand all
3405 } 3405 }
3406 return(0); 3406 return(0);
3407 } 3407 }
3408 3408
3409 #if 0 /* enable if ever needed */ 3409 #if 0 /* enable if ever needed */
3410 static int 3410 static int
3411 xmlSchemaItemListInsertSize(xmlSchemaItemListPtr list, 3411 xmlSchemaItemListInsertSize(xmlSchemaItemListPtr list,
3412 int initialSize, 3412 int initialSize,
3413 void *item, 3413 void *item,
3414 int idx) 3414 int idx)
3415 { 3415 {
3416 if (list->items == NULL) { 3416 if (list->items == NULL) {
3417 if (initialSize <= 0) 3417 if (initialSize <= 0)
3418 initialSize = 1; 3418 initialSize = 1;
3419 list->items = (void **) xmlMalloc( 3419 list->items = (void **) xmlMalloc(
3420 initialSize * sizeof(void *)); 3420 initialSize * sizeof(void *));
3421 if (list->items == NULL) { 3421 if (list->items == NULL) {
3422 xmlSchemaPErrMemory(NULL, "allocating new item list", NULL); 3422 xmlSchemaPErrMemory(NULL, "allocating new item list", NULL);
3423 return(-1); 3423 return(-1);
3424 } 3424 }
3425 list->sizeItems = initialSize; 3425 list->sizeItems = initialSize;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3460 } 3460 }
3461 3461
3462 if (list->nbItems == 1) { 3462 if (list->nbItems == 1) {
3463 /* TODO: Really free the list? */ 3463 /* TODO: Really free the list? */
3464 xmlFree(list->items); 3464 xmlFree(list->items);
3465 list->items = NULL; 3465 list->items = NULL;
3466 list->nbItems = 0; 3466 list->nbItems = 0;
3467 list->sizeItems = 0; 3467 list->sizeItems = 0;
3468 } else if (list->nbItems -1 == idx) { 3468 } else if (list->nbItems -1 == idx) {
3469 list->nbItems--; 3469 list->nbItems--;
3470 } else {» 3470 } else {
3471 for (i = idx; i < list->nbItems -1; i++) 3471 for (i = idx; i < list->nbItems -1; i++)
3472 list->items[i] = list->items[i+1]; 3472 list->items[i] = list->items[i+1];
3473 list->nbItems--; 3473 list->nbItems--;
3474 } 3474 }
3475 return(0); 3475 return(0);
3476 } 3476 }
3477 3477
3478 /** 3478 /**
3479 * xmlSchemaItemListFree: 3479 * xmlSchemaItemListFree:
3480 * @annot: a schema type structure 3480 * @annot: a schema type structure
(...skipping 14 matching lines...) Expand all
3495 xmlSchemaBucketFree(xmlSchemaBucketPtr bucket) 3495 xmlSchemaBucketFree(xmlSchemaBucketPtr bucket)
3496 { 3496 {
3497 if (bucket == NULL) 3497 if (bucket == NULL)
3498 return; 3498 return;
3499 if (bucket->globals != NULL) { 3499 if (bucket->globals != NULL) {
3500 xmlSchemaComponentListFree(bucket->globals); 3500 xmlSchemaComponentListFree(bucket->globals);
3501 xmlSchemaItemListFree(bucket->globals); 3501 xmlSchemaItemListFree(bucket->globals);
3502 } 3502 }
3503 if (bucket->locals != NULL) { 3503 if (bucket->locals != NULL) {
3504 xmlSchemaComponentListFree(bucket->locals); 3504 xmlSchemaComponentListFree(bucket->locals);
3505 » xmlSchemaItemListFree(bucket->locals);» 3505 » xmlSchemaItemListFree(bucket->locals);
3506 } 3506 }
3507 if (bucket->relations != NULL) { 3507 if (bucket->relations != NULL) {
3508 xmlSchemaSchemaRelationPtr prev, cur = bucket->relations; 3508 xmlSchemaSchemaRelationPtr prev, cur = bucket->relations;
3509 do { 3509 do {
3510 » prev = cur;» 3510 » prev = cur;
3511 cur = cur->next; 3511 cur = cur->next;
3512 xmlFree(prev); 3512 xmlFree(prev);
3513 } while (cur != NULL); 3513 } while (cur != NULL);
3514 } 3514 }
3515 if ((! bucket->preserveDoc) && (bucket->doc != NULL)) { 3515 if ((! bucket->preserveDoc) && (bucket->doc != NULL)) {
3516 xmlFreeDoc(bucket->doc); 3516 xmlFreeDoc(bucket->doc);
3517 } 3517 }
3518 if (bucket->type == XML_SCHEMA_SCHEMA_IMPORT) { 3518 if (bucket->type == XML_SCHEMA_SCHEMA_IMPORT) {
3519 if (WXS_IMPBUCKET(bucket)->schema != NULL) 3519 if (WXS_IMPBUCKET(bucket)->schema != NULL)
3520 xmlSchemaFree(WXS_IMPBUCKET(bucket)->schema); 3520 xmlSchemaFree(WXS_IMPBUCKET(bucket)->schema);
3521 } 3521 }
3522 xmlFree(bucket); 3522 xmlFree(bucket);
3523 } 3523 }
3524 3524
3525 static xmlSchemaBucketPtr 3525 static xmlSchemaBucketPtr
3526 xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt, 3526 xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt,
3527 int type, const xmlChar *targetNamespace) 3527 int type, const xmlChar *targetNamespace)
(...skipping 24 matching lines...) Expand all
3552 ret->globals = xmlSchemaItemListCreate(); 3552 ret->globals = xmlSchemaItemListCreate();
3553 if (ret->globals == NULL) { 3553 if (ret->globals == NULL) {
3554 xmlFree(ret); 3554 xmlFree(ret);
3555 return(NULL); 3555 return(NULL);
3556 } 3556 }
3557 ret->locals = xmlSchemaItemListCreate(); 3557 ret->locals = xmlSchemaItemListCreate();
3558 if (ret->locals == NULL) { 3558 if (ret->locals == NULL) {
3559 xmlFree(ret); 3559 xmlFree(ret);
3560 return(NULL); 3560 return(NULL);
3561 } 3561 }
3562 /* 3562 /*
3563 * The following will assure that only the first bucket is marked as 3563 * The following will assure that only the first bucket is marked as
3564 * XML_SCHEMA_SCHEMA_MAIN and it points to the *main* schema. 3564 * XML_SCHEMA_SCHEMA_MAIN and it points to the *main* schema.
3565 * For each following import buckets an xmlSchema will be created. 3565 * For each following import buckets an xmlSchema will be created.
3566 * An xmlSchema will be created for every distinct targetNamespace. 3566 * An xmlSchema will be created for every distinct targetNamespace.
3567 * We assign the targetNamespace to the schemata here. 3567 * We assign the targetNamespace to the schemata here.
3568 */ 3568 */
3569 if (! WXS_HAS_BUCKETS(pctxt)) { 3569 if (! WXS_HAS_BUCKETS(pctxt)) {
3570 if (WXS_IS_BUCKET_INCREDEF(type)) { 3570 if (WXS_IS_BUCKET_INCREDEF(type)) {
3571 PERROR_INT("xmlSchemaBucketCreate", 3571 PERROR_INT("xmlSchemaBucketCreate",
3572 "first bucket but it's an include or redefine"); 3572 "first bucket but it's an include or redefine");
3573 xmlSchemaBucketFree(ret); 3573 xmlSchemaBucketFree(ret);
3574 return(NULL); 3574 return(NULL);
3575 } 3575 }
3576 » /* Force the type to be XML_SCHEMA_SCHEMA_MAIN. */ 3576 » /* Force the type to be XML_SCHEMA_SCHEMA_MAIN. */
3577 ret->type = XML_SCHEMA_SCHEMA_MAIN; 3577 ret->type = XML_SCHEMA_SCHEMA_MAIN;
3578 /* Point to the *main* schema. */ 3578 /* Point to the *main* schema. */
3579 WXS_CONSTRUCTOR(pctxt)->mainBucket = ret; 3579 WXS_CONSTRUCTOR(pctxt)->mainBucket = ret;
3580 WXS_IMPBUCKET(ret)->schema = mainSchema; 3580 WXS_IMPBUCKET(ret)->schema = mainSchema;
3581 /* 3581 /*
3582 * Ensure that the main schema gets a targetNamespace. 3582 * Ensure that the main schema gets a targetNamespace.
3583 */ 3583 */
3584 mainSchema->targetNamespace = targetNamespace; 3584 mainSchema->targetNamespace = targetNamespace;
3585 } else { 3585 } else {
3586 » if (type == XML_SCHEMA_SCHEMA_MAIN) {» 3586 » if (type == XML_SCHEMA_SCHEMA_MAIN) {
3587 PERROR_INT("xmlSchemaBucketCreate", 3587 PERROR_INT("xmlSchemaBucketCreate",
3588 "main bucket but it's not the first one"); 3588 "main bucket but it's not the first one");
3589 xmlSchemaBucketFree(ret); 3589 xmlSchemaBucketFree(ret);
3590 return(NULL); 3590 return(NULL);
3591 » } else if (type == XML_SCHEMA_SCHEMA_IMPORT) {» 3591 » } else if (type == XML_SCHEMA_SCHEMA_IMPORT) {
3592 /* 3592 /*
3593 * Create a schema for imports and assign the 3593 * Create a schema for imports and assign the
3594 * targetNamespace. 3594 * targetNamespace.
3595 */ 3595 */
3596 WXS_IMPBUCKET(ret)->schema = xmlSchemaNewSchema(pctxt); 3596 WXS_IMPBUCKET(ret)->schema = xmlSchemaNewSchema(pctxt);
3597 if (WXS_IMPBUCKET(ret)->schema == NULL) { 3597 if (WXS_IMPBUCKET(ret)->schema == NULL) {
3598 xmlSchemaBucketFree(ret); 3598 xmlSchemaBucketFree(ret);
3599 return(NULL); 3599 return(NULL);
3600 } 3600 }
3601 WXS_IMPBUCKET(ret)->schema->targetNamespace = targetNamespace; 3601 WXS_IMPBUCKET(ret)->schema->targetNamespace = targetNamespace;
3602 } 3602 }
3603 } 3603 }
3604 if (WXS_IS_BUCKET_IMPMAIN(type)) { 3604 if (WXS_IS_BUCKET_IMPMAIN(type)) {
3605 int res; 3605 int res;
3606 /* 3606 /*
3607 * Imports go into the "schemasImports" slot of the main *schema*. 3607 * Imports go into the "schemasImports" slot of the main *schema*.
3608 * Note that we create an import entry for the main schema as well; i.e., 3608 * Note that we create an import entry for the main schema as well; i.e.,
3609 * even if there's only one schema, we'll get an import. 3609 * even if there's only one schema, we'll get an import.
3610 */ 3610 */
3611 if (mainSchema->schemasImports == NULL) { 3611 if (mainSchema->schemasImports == NULL) {
3612 mainSchema->schemasImports = xmlHashCreateDict(5, 3612 mainSchema->schemasImports = xmlHashCreateDict(5,
3613 WXS_CONSTRUCTOR(pctxt)->dict); 3613 WXS_CONSTRUCTOR(pctxt)->dict);
(...skipping 22 matching lines...) Expand all
3636 else 3636 else
3637 WXS_INCBUCKET(ret)->ownerImport = 3637 WXS_INCBUCKET(ret)->ownerImport =
3638 WXS_INCBUCKET(WXS_CONSTRUCTOR(pctxt)->bucket)->ownerImport; 3638 WXS_INCBUCKET(WXS_CONSTRUCTOR(pctxt)->bucket)->ownerImport;
3639 3639
3640 /* Includes got into the "includes" slot of the *main* schema. */ 3640 /* Includes got into the "includes" slot of the *main* schema. */
3641 if (mainSchema->includes == NULL) { 3641 if (mainSchema->includes == NULL) {
3642 mainSchema->includes = xmlSchemaItemListCreate(); 3642 mainSchema->includes = xmlSchemaItemListCreate();
3643 if (mainSchema->includes == NULL) { 3643 if (mainSchema->includes == NULL) {
3644 xmlSchemaBucketFree(ret); 3644 xmlSchemaBucketFree(ret);
3645 return(NULL); 3645 return(NULL);
3646 » }» 3646 » }
3647 } 3647 }
3648 xmlSchemaItemListAdd(mainSchema->includes, ret); 3648 xmlSchemaItemListAdd(mainSchema->includes, ret);
3649 } 3649 }
3650 /* 3650 /*
3651 * Add to list of all buckets; this is used for lookup 3651 * Add to list of all buckets; this is used for lookup
3652 * during schema construction time only. 3652 * during schema construction time only.
3653 */ 3653 */
3654 if (xmlSchemaItemListAdd(WXS_CONSTRUCTOR(pctxt)->buckets, ret) == -1) 3654 if (xmlSchemaItemListAdd(WXS_CONSTRUCTOR(pctxt)->buckets, ret) == -1)
3655 return(NULL); 3655 return(NULL);
3656 return(ret); 3656 return(ret);
3657 } 3657 }
3658 3658
3659 static int 3659 static int
3660 xmlSchemaAddItemSize(xmlSchemaItemListPtr *list, int initialSize, void *item) 3660 xmlSchemaAddItemSize(xmlSchemaItemListPtr *list, int initialSize, void *item)
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
4008 if ((list == NULL) || (list->nbItems == 0)) 4008 if ((list == NULL) || (list->nbItems == 0))
4009 return; 4009 return;
4010 { 4010 {
4011 xmlSchemaTreeItemPtr item; 4011 xmlSchemaTreeItemPtr item;
4012 xmlSchemaTreeItemPtr *items = (xmlSchemaTreeItemPtr *) list->items; 4012 xmlSchemaTreeItemPtr *items = (xmlSchemaTreeItemPtr *) list->items;
4013 int i; 4013 int i;
4014 4014
4015 for (i = 0; i < list->nbItems; i++) { 4015 for (i = 0; i < list->nbItems; i++) {
4016 item = items[i]; 4016 item = items[i];
4017 if (item == NULL) 4017 if (item == NULL)
4018 » » continue;» 4018 » » continue;
4019 switch (item->type) { 4019 switch (item->type) {
4020 case XML_SCHEMA_TYPE_SIMPLE: 4020 case XML_SCHEMA_TYPE_SIMPLE:
4021 case XML_SCHEMA_TYPE_COMPLEX: 4021 case XML_SCHEMA_TYPE_COMPLEX:
4022 xmlSchemaFreeType((xmlSchemaTypePtr) item); 4022 xmlSchemaFreeType((xmlSchemaTypePtr) item);
4023 break; 4023 break;
4024 case XML_SCHEMA_TYPE_ATTRIBUTE: 4024 case XML_SCHEMA_TYPE_ATTRIBUTE:
4025 xmlSchemaFreeAttribute((xmlSchemaAttributePtr) item); 4025 xmlSchemaFreeAttribute((xmlSchemaAttributePtr) item);
4026 break; 4026 break;
4027 case XML_SCHEMA_TYPE_ATTRIBUTE_USE: 4027 case XML_SCHEMA_TYPE_ATTRIBUTE_USE:
4028 xmlSchemaFreeAttributeUse((xmlSchemaAttributeUsePtr) item); 4028 xmlSchemaFreeAttributeUse((xmlSchemaAttributeUsePtr) item);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
4115 if (schema->idcDef != NULL) 4115 if (schema->idcDef != NULL)
4116 xmlHashFree(schema->idcDef, NULL); 4116 xmlHashFree(schema->idcDef, NULL);
4117 4117
4118 if (schema->schemasImports != NULL) 4118 if (schema->schemasImports != NULL)
4119 xmlHashFree(schema->schemasImports, 4119 xmlHashFree(schema->schemasImports,
4120 (xmlHashDeallocator) xmlSchemaBucketFree); 4120 (xmlHashDeallocator) xmlSchemaBucketFree);
4121 if (schema->includes != NULL) { 4121 if (schema->includes != NULL) {
4122 xmlSchemaItemListPtr list = (xmlSchemaItemListPtr) schema->includes; 4122 xmlSchemaItemListPtr list = (xmlSchemaItemListPtr) schema->includes;
4123 int i; 4123 int i;
4124 for (i = 0; i < list->nbItems; i++) { 4124 for (i = 0; i < list->nbItems; i++) {
4125 » xmlSchemaBucketFree((xmlSchemaBucketPtr) list->items[i]);» 4125 » xmlSchemaBucketFree((xmlSchemaBucketPtr) list->items[i]);
4126 } 4126 }
4127 xmlSchemaItemListFree(list); 4127 xmlSchemaItemListFree(list);
4128 } 4128 }
4129 if (schema->annot != NULL) 4129 if (schema->annot != NULL)
4130 xmlSchemaFreeAnnot(schema->annot); 4130 xmlSchemaFreeAnnot(schema->annot);
4131 /* Never free the doc here, since this will be done by the buckets. */ 4131 /* Never free the doc here, since this will be done by the buckets. */
4132 4132
4133 xmlDictFree(schema->dict); 4133 xmlDictFree(schema->dict);
4134 xmlFree(schema); 4134 xmlFree(schema);
4135 } 4135 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
4267 xmlChar *str = NULL; 4267 xmlChar *str = NULL;
4268 xmlSchemaTreeItemPtr term; 4268 xmlSchemaTreeItemPtr term;
4269 char shift[100]; 4269 char shift[100];
4270 int i; 4270 int i;
4271 4271
4272 if (particle == NULL) 4272 if (particle == NULL)
4273 return; 4273 return;
4274 for (i = 0;((i < depth) && (i < 25));i++) 4274 for (i = 0;((i < depth) && (i < 25));i++)
4275 shift[2 * i] = shift[2 * i + 1] = ' '; 4275 shift[2 * i] = shift[2 * i + 1] = ' ';
4276 shift[2 * i] = shift[2 * i + 1] = 0; 4276 shift[2 * i] = shift[2 * i + 1] = 0;
4277 fprintf(output, shift); 4277 fprintf(output, "%s", shift);
4278 if (particle->children == NULL) { 4278 if (particle->children == NULL) {
4279 fprintf(output, "MISSING particle term\n"); 4279 fprintf(output, "MISSING particle term\n");
4280 return; 4280 return;
4281 } 4281 }
4282 term = particle->children; 4282 term = particle->children;
4283 if (term == NULL) { 4283 if (term == NULL) {
4284 fprintf(output, "(NULL)"); 4284 fprintf(output, "(NULL)");
4285 } else { 4285 } else {
4286 switch (term->type) { 4286 switch (term->type) {
4287 case XML_SCHEMA_TYPE_ELEMENT: 4287 case XML_SCHEMA_TYPE_ELEMENT:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4323 output, depth +1); 4323 output, depth +1);
4324 } 4324 }
4325 if (particle->next != NULL) 4325 if (particle->next != NULL)
4326 xmlSchemaContentModelDump((xmlSchemaParticlePtr) particle->next, 4326 xmlSchemaContentModelDump((xmlSchemaParticlePtr) particle->next,
4327 output, depth); 4327 output, depth);
4328 } 4328 }
4329 4329
4330 /** 4330 /**
4331 * xmlSchemaAttrUsesDump: 4331 * xmlSchemaAttrUsesDump:
4332 * @uses: attribute uses list 4332 * @uses: attribute uses list
4333 * @output: the file output 4333 * @output: the file output
4334 * 4334 *
4335 * Dumps a list of attribute use components. 4335 * Dumps a list of attribute use components.
4336 */ 4336 */
4337 static void 4337 static void
4338 xmlSchemaAttrUsesDump(xmlSchemaItemListPtr uses, FILE * output) 4338 xmlSchemaAttrUsesDump(xmlSchemaItemListPtr uses, FILE * output)
4339 { 4339 {
4340 xmlSchemaAttributeUsePtr use; 4340 xmlSchemaAttributeUsePtr use;
4341 xmlSchemaAttributeUseProhibPtr prohib; 4341 xmlSchemaAttributeUseProhibPtr prohib;
4342 xmlSchemaQNameRefPtr ref; 4342 xmlSchemaQNameRefPtr ref;
4343 const xmlChar *name, *tns; 4343 const xmlChar *name, *tns;
4344 xmlChar *str = NULL; 4344 xmlChar *str = NULL;
4345 int i; 4345 int i;
4346 4346
4347 if ((uses == NULL) || (uses->nbItems == 0)) 4347 if ((uses == NULL) || (uses->nbItems == 0))
4348 return; 4348 return;
4349 4349
4350 fprintf(output, " attributes:\n"); 4350 fprintf(output, " attributes:\n");
4351 for (i = 0; i < uses->nbItems; i++) { 4351 for (i = 0; i < uses->nbItems; i++) {
4352 use = uses->items[i]; 4352 use = uses->items[i];
4353 if (use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) { 4353 if (use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) {
4354 fprintf(output, " [prohibition] "); 4354 fprintf(output, " [prohibition] ");
4355 prohib = (xmlSchemaAttributeUseProhibPtr) use; 4355 prohib = (xmlSchemaAttributeUseProhibPtr) use;
4356 name = prohib->name; 4356 name = prohib->name;
4357 tns = prohib->targetNamespace; 4357 tns = prohib->targetNamespace;
4358 } else if (use->type == XML_SCHEMA_EXTRA_QNAMEREF) { 4358 } else if (use->type == XML_SCHEMA_EXTRA_QNAMEREF) {
4359 fprintf(output, " [reference] "); 4359 fprintf(output, " [reference] ");
4360 ref = (xmlSchemaQNameRefPtr) use; 4360 ref = (xmlSchemaQNameRefPtr) use;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
4526 int i, j, res; 4526 int i, j, res;
4527 4527
4528 fprintf(output, "IDC: TABLES on '%s'\n", 4528 fprintf(output, "IDC: TABLES on '%s'\n",
4529 xmlSchemaFormatQName(&str, namespaceName, localName)); 4529 xmlSchemaFormatQName(&str, namespaceName, localName));
4530 FREE_AND_NULL(str) 4530 FREE_AND_NULL(str)
4531 4531
4532 if (bind == NULL) 4532 if (bind == NULL)
4533 return; 4533 return;
4534 do { 4534 do {
4535 fprintf(output, "IDC: BINDING '%s' (%d)\n", 4535 fprintf(output, "IDC: BINDING '%s' (%d)\n",
4536 » xmlSchemaGetComponentQName(&str, 4536 » xmlSchemaGetComponentQName(&str,
4537 bind->definition), bind->nbNodes); 4537 bind->definition), bind->nbNodes);
4538 FREE_AND_NULL(str) 4538 FREE_AND_NULL(str)
4539 for (i = 0; i < bind->nbNodes; i++) { 4539 for (i = 0; i < bind->nbNodes; i++) {
4540 tab = bind->nodeTable[i]; 4540 tab = bind->nodeTable[i];
4541 fprintf(output, " ( "); 4541 fprintf(output, " ( ");
4542 for (j = 0; j < bind->definition->nbFields; j++) { 4542 for (j = 0; j < bind->definition->nbFields; j++) {
4543 key = tab->keys[j]; 4543 key = tab->keys[j];
4544 if ((key != NULL) && (key->val != NULL)) { 4544 if ((key != NULL) && (key->val != NULL)) {
4545 res = xmlSchemaGetCanonValue(key->val, &value); 4545 res = xmlSchemaGetCanonValue(key->val, &value);
4546 if (res >= 0) 4546 if (res >= 0)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
4627 * a namespace URI of @uri. 4627 * a namespace URI of @uri.
4628 * 4628 *
4629 * Returns the attribute or NULL if not present. 4629 * Returns the attribute or NULL if not present.
4630 */ 4630 */
4631 static xmlAttrPtr 4631 static xmlAttrPtr
4632 xmlSchemaGetPropNodeNs(xmlNodePtr node, const char *uri, const char *name) 4632 xmlSchemaGetPropNodeNs(xmlNodePtr node, const char *uri, const char *name)
4633 { 4633 {
4634 xmlAttrPtr prop; 4634 xmlAttrPtr prop;
4635 4635
4636 if ((node == NULL) || (name == NULL)) 4636 if ((node == NULL) || (name == NULL))
4637 » return(NULL); 4637 » return(NULL);
4638 prop = node->properties; 4638 prop = node->properties;
4639 while (prop != NULL) { 4639 while (prop != NULL) {
4640 if ((prop->ns != NULL) && 4640 if ((prop->ns != NULL) &&
4641 xmlStrEqual(prop->name, BAD_CAST name) && 4641 xmlStrEqual(prop->name, BAD_CAST name) &&
4642 xmlStrEqual(prop->ns->href, BAD_CAST uri)) 4642 xmlStrEqual(prop->ns->href, BAD_CAST uri))
4643 return(prop); 4643 return(prop);
4644 prop = prop->next; 4644 prop = prop->next;
4645 } 4645 }
4646 return (NULL); 4646 return (NULL);
4647 } 4647 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
4722 * 4722 *
4723 * Lookup a global element declaration in the schema. 4723 * Lookup a global element declaration in the schema.
4724 * 4724 *
4725 * Returns the element declaration or NULL if not found. 4725 * Returns the element declaration or NULL if not found.
4726 */ 4726 */
4727 static xmlSchemaElementPtr 4727 static xmlSchemaElementPtr
4728 xmlSchemaGetElem(xmlSchemaPtr schema, const xmlChar * name, 4728 xmlSchemaGetElem(xmlSchemaPtr schema, const xmlChar * name,
4729 const xmlChar * nsName) 4729 const xmlChar * nsName)
4730 { 4730 {
4731 xmlSchemaElementPtr ret = NULL; 4731 xmlSchemaElementPtr ret = NULL;
4732 4732
4733 if ((name == NULL) || (schema == NULL)) 4733 if ((name == NULL) || (schema == NULL))
4734 return(NULL); 4734 return(NULL);
4735 if (schema != NULL) { 4735 if (schema != NULL) {
4736 WXS_FIND_GLOBAL_ITEM(elemDecl) 4736 WXS_FIND_GLOBAL_ITEM(elemDecl)
4737 } 4737 }
4738 exit: 4738 exit:
4739 #ifdef DEBUG 4739 #ifdef DEBUG
4740 if (ret == NULL) { 4740 if (ret == NULL) {
4741 if (nsName == NULL) 4741 if (nsName == NULL)
4742 fprintf(stderr, "Unable to lookup element decl. %s", name); 4742 fprintf(stderr, "Unable to lookup element decl. %s", name);
4743 else 4743 else
4744 fprintf(stderr, "Unable to lookup element decl. %s:%s", name, 4744 fprintf(stderr, "Unable to lookup element decl. %s:%s", name,
4745 nsName); 4745 nsName);
4746 } 4746 }
4747 #endif 4747 #endif
(...skipping 10 matching lines...) Expand all
4758 * 4758 *
4759 * Returns the group definition or NULL if not found. 4759 * Returns the group definition or NULL if not found.
4760 */ 4760 */
4761 static xmlSchemaTypePtr 4761 static xmlSchemaTypePtr
4762 xmlSchemaGetType(xmlSchemaPtr schema, const xmlChar * name, 4762 xmlSchemaGetType(xmlSchemaPtr schema, const xmlChar * name,
4763 const xmlChar * nsName) 4763 const xmlChar * nsName)
4764 { 4764 {
4765 xmlSchemaTypePtr ret = NULL; 4765 xmlSchemaTypePtr ret = NULL;
4766 4766
4767 if (name == NULL) 4767 if (name == NULL)
4768 return (NULL); 4768 return (NULL);
4769 /* First try the built-in types. */ 4769 /* First try the built-in types. */
4770 if ((nsName != NULL) && xmlStrEqual(nsName, xmlSchemaNs)) {» 4770 if ((nsName != NULL) && xmlStrEqual(nsName, xmlSchemaNs)) {
4771 ret = xmlSchemaGetPredefinedType(name, nsName); 4771 ret = xmlSchemaGetPredefinedType(name, nsName);
4772 if (ret != NULL) 4772 if (ret != NULL)
4773 goto exit; 4773 goto exit;
4774 /* 4774 /*
4775 * Note that we try the parsed schemas as well here 4775 * Note that we try the parsed schemas as well here
4776 * since one might have parsed the S4S, which contain more 4776 * since one might have parsed the S4S, which contain more
4777 * than the built-in types. 4777 * than the built-in types.
4778 * TODO: Can we optimize this? 4778 * TODO: Can we optimize this?
4779 */ 4779 */
4780 } 4780 }
4781 if (schema != NULL) { 4781 if (schema != NULL) {
4782 WXS_FIND_GLOBAL_ITEM(typeDecl) 4782 WXS_FIND_GLOBAL_ITEM(typeDecl)
4783 } 4783 }
4784 exit: 4784 exit:
4785 4785
4786 #ifdef DEBUG 4786 #ifdef DEBUG
4787 if (ret == NULL) { 4787 if (ret == NULL) {
4788 if (nsName == NULL) 4788 if (nsName == NULL)
4789 fprintf(stderr, "Unable to lookup type %s", name); 4789 fprintf(stderr, "Unable to lookup type %s", name);
4790 else 4790 else
4791 fprintf(stderr, "Unable to lookup type %s:%s", name, 4791 fprintf(stderr, "Unable to lookup type %s:%s", name,
4792 nsName); 4792 nsName);
4793 } 4793 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
4884 const xmlChar * nsName) 4884 const xmlChar * nsName)
4885 { 4885 {
4886 xmlSchemaModelGroupDefPtr ret = NULL; 4886 xmlSchemaModelGroupDefPtr ret = NULL;
4887 4887
4888 if ((name == NULL) || (schema == NULL)) 4888 if ((name == NULL) || (schema == NULL))
4889 return (NULL); 4889 return (NULL);
4890 if (schema != NULL) { 4890 if (schema != NULL) {
4891 WXS_FIND_GLOBAL_ITEM(groupDecl) 4891 WXS_FIND_GLOBAL_ITEM(groupDecl)
4892 } 4892 }
4893 exit: 4893 exit:
4894 4894
4895 #ifdef DEBUG 4895 #ifdef DEBUG
4896 if (ret == NULL) { 4896 if (ret == NULL) {
4897 if (nsName == NULL) 4897 if (nsName == NULL)
4898 fprintf(stderr, "Unable to lookup group %s", name); 4898 fprintf(stderr, "Unable to lookup group %s", name);
4899 else 4899 else
4900 fprintf(stderr, "Unable to lookup group %s:%s", name, 4900 fprintf(stderr, "Unable to lookup group %s:%s", name,
4901 nsName); 4901 nsName);
4902 } 4902 }
4903 #endif 4903 #endif
4904 return (ret); 4904 return (ret);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
4993 if (!(IS_BLANK_CH(*str))) 4993 if (!(IS_BLANK_CH(*str)))
4994 return (0); 4994 return (0);
4995 str++; 4995 str++;
4996 } 4996 }
4997 } else while ((*str != 0) && (len != 0)) { 4997 } else while ((*str != 0) && (len != 0)) {
4998 if (!(IS_BLANK_CH(*str))) 4998 if (!(IS_BLANK_CH(*str)))
4999 return (0); 4999 return (0);
5000 str++; 5000 str++;
5001 len--; 5001 len--;
5002 } 5002 }
5003 5003
5004 return (1); 5004 return (1);
5005 } 5005 }
5006 5006
5007 #define WXS_COMP_NAME(c, t) ((t) (c))->name 5007 #define WXS_COMP_NAME(c, t) ((t) (c))->name
5008 #define WXS_COMP_TNS(c, t) ((t) (c))->targetNamespace 5008 #define WXS_COMP_TNS(c, t) ((t) (c))->targetNamespace
5009 /* 5009 /*
5010 * xmlSchemaFindRedefCompInGraph: 5010 * xmlSchemaFindRedefCompInGraph:
5011 * ATTENTION TODO: This uses pointer comp. for strings. 5011 * ATTENTION TODO: This uses pointer comp. for strings.
5012 */ 5012 */
5013 static xmlSchemaBasicItemPtr 5013 static xmlSchemaBasicItemPtr
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5054 xmlSchemaAttributeGroupPtr) == name) && 5054 xmlSchemaAttributeGroupPtr) == name) &&
5055 (WXS_COMP_TNS(ret, 5055 (WXS_COMP_TNS(ret,
5056 xmlSchemaAttributeGroupPtr) == nsName)) 5056 xmlSchemaAttributeGroupPtr) == nsName))
5057 { 5057 {
5058 return(ret); 5058 return(ret);
5059 } 5059 }
5060 break; 5060 break;
5061 default: 5061 default:
5062 /* Should not be hit. */ 5062 /* Should not be hit. */
5063 return(NULL); 5063 return(NULL);
5064 » }» » 5064 » }
5065 } 5065 }
5066 } 5066 }
5067 subschemas: 5067 subschemas:
5068 /* 5068 /*
5069 * Process imported/included schemas. 5069 * Process imported/included schemas.
5070 */ 5070 */
5071 if (bucket->relations != NULL) { 5071 if (bucket->relations != NULL) {
5072 xmlSchemaSchemaRelationPtr rel = bucket->relations; 5072 xmlSchemaSchemaRelationPtr rel = bucket->relations;
5073 5073
5074 /* 5074 /*
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
5202 return (ret); 5202 return (ret);
5203 } 5203 }
5204 5204
5205 /* 5205 /*
5206 * xmlSchemaAddRedef: 5206 * xmlSchemaAddRedef:
5207 * 5207 *
5208 * Adds a redefinition information. This is used at a later stage to: 5208 * Adds a redefinition information. This is used at a later stage to:
5209 * resolve references to the redefined components and to check constraints. 5209 * resolve references to the redefined components and to check constraints.
5210 */ 5210 */
5211 static xmlSchemaRedefPtr 5211 static xmlSchemaRedefPtr
5212 xmlSchemaAddRedef(xmlSchemaParserCtxtPtr pctxt,»» 5212 xmlSchemaAddRedef(xmlSchemaParserCtxtPtr pctxt,
5213 xmlSchemaBucketPtr targetBucket, 5213 xmlSchemaBucketPtr targetBucket,
5214 void *item, 5214 void *item,
5215 const xmlChar *refName, 5215 const xmlChar *refName,
5216 const xmlChar *refTargetNs) 5216 const xmlChar *refTargetNs)
5217 { 5217 {
5218 xmlSchemaRedefPtr ret; 5218 xmlSchemaRedefPtr ret;
5219 5219
5220 ret = (xmlSchemaRedefPtr) 5220 ret = (xmlSchemaRedefPtr)
5221 xmlMalloc(sizeof(xmlSchemaRedef)); 5221 xmlMalloc(sizeof(xmlSchemaRedef));
5222 if (ret == NULL) { 5222 if (ret == NULL) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
5265 ret = (xmlSchemaAttributeGroupPtr) 5265 ret = (xmlSchemaAttributeGroupPtr)
5266 xmlMalloc(sizeof(xmlSchemaAttributeGroup)); 5266 xmlMalloc(sizeof(xmlSchemaAttributeGroup));
5267 if (ret == NULL) { 5267 if (ret == NULL) {
5268 xmlSchemaPErrMemory(pctxt, "allocating attribute group", NULL); 5268 xmlSchemaPErrMemory(pctxt, "allocating attribute group", NULL);
5269 return (NULL); 5269 return (NULL);
5270 } 5270 }
5271 memset(ret, 0, sizeof(xmlSchemaAttributeGroup)); 5271 memset(ret, 0, sizeof(xmlSchemaAttributeGroup));
5272 ret->type = XML_SCHEMA_TYPE_ATTRIBUTEGROUP; 5272 ret->type = XML_SCHEMA_TYPE_ATTRIBUTEGROUP;
5273 ret->name = name; 5273 ret->name = name;
5274 ret->targetNamespace = nsName; 5274 ret->targetNamespace = nsName;
5275 ret->node = node; 5275 ret->node = node;
5276 5276
5277 /* TODO: Remove the flag. */ 5277 /* TODO: Remove the flag. */
5278 ret->flags |= XML_SCHEMAS_ATTRGROUP_GLOBAL; 5278 ret->flags |= XML_SCHEMAS_ATTRGROUP_GLOBAL;
5279 if (pctxt->isRedefine) { 5279 if (pctxt->isRedefine) {
5280 pctxt->redef = xmlSchemaAddRedef(pctxt, pctxt->redefined, 5280 pctxt->redef = xmlSchemaAddRedef(pctxt, pctxt->redefined,
5281 ret, name, nsName); 5281 ret, name, nsName);
5282 if (pctxt->redef == NULL) { 5282 if (pctxt->redef == NULL) {
5283 xmlFree(ret); 5283 xmlFree(ret);
5284 return(NULL); 5284 return(NULL);
5285 » }» 5285 » }
5286 pctxt->redefCounter = 0; 5286 pctxt->redefCounter = 0;
5287 } 5287 }
5288 WXS_ADD_GLOBAL(pctxt, ret); 5288 WXS_ADD_GLOBAL(pctxt, ret);
5289 WXS_ADD_PENDING(pctxt, ret); 5289 WXS_ADD_PENDING(pctxt, ret);
5290 return (ret); 5290 return (ret);
5291 } 5291 }
5292 5292
5293 /** 5293 /**
5294 * xmlSchemaAddElement: 5294 * xmlSchemaAddElement:
5295 * @ctxt: a schema parser context 5295 * @ctxt: a schema parser context
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
5364 ret->name = name; 5364 ret->name = name;
5365 ret->targetNamespace = nsName; 5365 ret->targetNamespace = nsName;
5366 ret->node = node; 5366 ret->node = node;
5367 if (topLevel) { 5367 if (topLevel) {
5368 if (ctxt->isRedefine) { 5368 if (ctxt->isRedefine) {
5369 ctxt->redef = xmlSchemaAddRedef(ctxt, ctxt->redefined, 5369 ctxt->redef = xmlSchemaAddRedef(ctxt, ctxt->redefined,
5370 ret, name, nsName); 5370 ret, name, nsName);
5371 if (ctxt->redef == NULL) { 5371 if (ctxt->redef == NULL) {
5372 xmlFree(ret); 5372 xmlFree(ret);
5373 return(NULL); 5373 return(NULL);
5374 » }» 5374 » }
5375 ctxt->redefCounter = 0; 5375 ctxt->redefCounter = 0;
5376 } 5376 }
5377 WXS_ADD_GLOBAL(ctxt, ret); 5377 WXS_ADD_GLOBAL(ctxt, ret);
5378 } else 5378 } else
5379 WXS_ADD_LOCAL(ctxt, ret); 5379 WXS_ADD_LOCAL(ctxt, ret);
5380 WXS_ADD_PENDING(ctxt, ret); 5380 WXS_ADD_PENDING(ctxt, ret);
5381 return (ret); 5381 return (ret);
5382 } 5382 }
5383 5383
5384 static xmlSchemaQNameRefPtr 5384 static xmlSchemaQNameRefPtr
5385 xmlSchemaNewQNameRef(xmlSchemaParserCtxtPtr pctxt, 5385 xmlSchemaNewQNameRef(xmlSchemaParserCtxtPtr pctxt,
5386 xmlSchemaTypeType refType, 5386 xmlSchemaTypeType refType,
5387 const xmlChar *refName, 5387 const xmlChar *refName,
5388 const xmlChar *refNs) 5388 const xmlChar *refNs)
5389 { 5389 {
5390 xmlSchemaQNameRefPtr ret; 5390 xmlSchemaQNameRefPtr ret;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
5502 } 5502 }
5503 ret->type = XML_SCHEMA_TYPE_PARTICLE; 5503 ret->type = XML_SCHEMA_TYPE_PARTICLE;
5504 ret->annot = NULL; 5504 ret->annot = NULL;
5505 ret->node = node; 5505 ret->node = node;
5506 ret->minOccurs = min; 5506 ret->minOccurs = min;
5507 ret->maxOccurs = max; 5507 ret->maxOccurs = max;
5508 ret->next = NULL; 5508 ret->next = NULL;
5509 ret->children = NULL; 5509 ret->children = NULL;
5510 5510
5511 WXS_ADD_LOCAL(ctxt, ret); 5511 WXS_ADD_LOCAL(ctxt, ret);
5512 /* 5512 /*
5513 * Note that addition to pending components will be done locally 5513 * Note that addition to pending components will be done locally
5514 * to the specific parsing function, since the most particles 5514 * to the specific parsing function, since the most particles
5515 * need not to be fixed up (i.e. the reference to be resolved). 5515 * need not to be fixed up (i.e. the reference to be resolved).
5516 * REMOVED: WXS_ADD_PENDING(ctxt, ret); 5516 * REMOVED: WXS_ADD_PENDING(ctxt, ret);
5517 */ 5517 */
5518 return (ret); 5518 return (ret);
5519 } 5519 }
5520 5520
5521 /** 5521 /**
5522 * xmlSchemaAddModelGroupDefinition: 5522 * xmlSchemaAddModelGroupDefinition:
(...skipping 28 matching lines...) Expand all
5551 ret->type = XML_SCHEMA_TYPE_GROUP; 5551 ret->type = XML_SCHEMA_TYPE_GROUP;
5552 ret->node = node; 5552 ret->node = node;
5553 ret->targetNamespace = nsName; 5553 ret->targetNamespace = nsName;
5554 5554
5555 if (ctxt->isRedefine) { 5555 if (ctxt->isRedefine) {
5556 ctxt->redef = xmlSchemaAddRedef(ctxt, ctxt->redefined, 5556 ctxt->redef = xmlSchemaAddRedef(ctxt, ctxt->redefined,
5557 ret, name, nsName); 5557 ret, name, nsName);
5558 if (ctxt->redef == NULL) { 5558 if (ctxt->redef == NULL) {
5559 xmlFree(ret); 5559 xmlFree(ret);
5560 return(NULL); 5560 return(NULL);
5561 » }» 5561 » }
5562 ctxt->redefCounter = 0; 5562 ctxt->redefCounter = 0;
5563 } 5563 }
5564 WXS_ADD_GLOBAL(ctxt, ret); 5564 WXS_ADD_GLOBAL(ctxt, ret);
5565 WXS_ADD_PENDING(ctxt, ret); 5565 WXS_ADD_PENDING(ctxt, ret);
5566 return (ret); 5566 return (ret);
5567 } 5567 }
5568 5568
5569 /** 5569 /**
5570 * xmlSchemaNewWildcardNs: 5570 * xmlSchemaNewWildcardNs:
5571 * @ctxt: a schema validation context 5571 * @ctxt: a schema validation context
(...skipping 16 matching lines...) Expand all
5588 ret->value = NULL; 5588 ret->value = NULL;
5589 ret->next = NULL; 5589 ret->next = NULL;
5590 return (ret); 5590 return (ret);
5591 } 5591 }
5592 5592
5593 static xmlSchemaIDCPtr 5593 static xmlSchemaIDCPtr
5594 xmlSchemaAddIDC(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, 5594 xmlSchemaAddIDC(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
5595 const xmlChar *name, const xmlChar *nsName, 5595 const xmlChar *name, const xmlChar *nsName,
5596 int category, xmlNodePtr node) 5596 int category, xmlNodePtr node)
5597 { 5597 {
5598 xmlSchemaIDCPtr ret = NULL; 5598 xmlSchemaIDCPtr ret = NULL;
5599 5599
5600 if ((ctxt == NULL) || (schema == NULL) || (name == NULL)) 5600 if ((ctxt == NULL) || (schema == NULL) || (name == NULL))
5601 return (NULL); 5601 return (NULL);
5602 5602
5603 ret = (xmlSchemaIDCPtr) xmlMalloc(sizeof(xmlSchemaIDC)); 5603 ret = (xmlSchemaIDCPtr) xmlMalloc(sizeof(xmlSchemaIDC));
5604 if (ret == NULL) { 5604 if (ret == NULL) {
5605 xmlSchemaPErrMemory(ctxt, 5605 xmlSchemaPErrMemory(ctxt,
5606 "allocating an identity-constraint definition", NULL); 5606 "allocating an identity-constraint definition", NULL);
5607 return (NULL); 5607 return (NULL);
5608 } 5608 }
5609 memset(ret, 0, sizeof(xmlSchemaIDC)); 5609 memset(ret, 0, sizeof(xmlSchemaIDC));
5610 /* The target namespace of the parent element declaration. */ 5610 /* The target namespace of the parent element declaration. */
5611 ret->targetNamespace = nsName; 5611 ret->targetNamespace = nsName;
5612 ret->name = name; 5612 ret->name = name;
5613 ret->type = category; 5613 ret->type = category;
5614 ret->node = node; 5614 ret->node = node;
5615 5615
5616 WXS_ADD_GLOBAL(ctxt, ret); 5616 WXS_ADD_GLOBAL(ctxt, ret);
5617 /* 5617 /*
5618 * Only keyrefs need to be fixup up. 5618 * Only keyrefs need to be fixup up.
5619 */ 5619 */
5620 if (category == XML_SCHEMA_TYPE_IDC_KEYREF) 5620 if (category == XML_SCHEMA_TYPE_IDC_KEYREF)
5621 WXS_ADD_PENDING(ctxt, ret); 5621 WXS_ADD_PENDING(ctxt, ret);
5622 return (ret); 5622 return (ret);
5623 } 5623 }
5624 5624
5625 /** 5625 /**
(...skipping 15 matching lines...) Expand all
5641 if ((ctxt == NULL) || (schema == NULL)) 5641 if ((ctxt == NULL) || (schema == NULL))
5642 return (NULL); 5642 return (NULL);
5643 5643
5644 ret = (xmlSchemaWildcardPtr) xmlMalloc(sizeof(xmlSchemaWildcard)); 5644 ret = (xmlSchemaWildcardPtr) xmlMalloc(sizeof(xmlSchemaWildcard));
5645 if (ret == NULL) { 5645 if (ret == NULL) {
5646 xmlSchemaPErrMemory(ctxt, "adding wildcard", NULL); 5646 xmlSchemaPErrMemory(ctxt, "adding wildcard", NULL);
5647 return (NULL); 5647 return (NULL);
5648 } 5648 }
5649 memset(ret, 0, sizeof(xmlSchemaWildcard)); 5649 memset(ret, 0, sizeof(xmlSchemaWildcard));
5650 ret->type = type; 5650 ret->type = type;
5651 ret->node = node; 5651 ret->node = node;
5652 WXS_ADD_LOCAL(ctxt, ret); 5652 WXS_ADD_LOCAL(ctxt, ret);
5653 return (ret); 5653 return (ret);
5654 } 5654 }
5655 5655
5656 static void 5656 static void
5657 xmlSchemaSubstGroupFree(xmlSchemaSubstGroupPtr group) 5657 xmlSchemaSubstGroupFree(xmlSchemaSubstGroupPtr group)
5658 { 5658 {
5659 if (group == NULL) 5659 if (group == NULL)
5660 return; 5660 return;
5661 if (group->members != NULL) 5661 if (group->members != NULL)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5697 "failed to add a new substitution container"); 5697 "failed to add a new substitution container");
5698 xmlSchemaSubstGroupFree(ret); 5698 xmlSchemaSubstGroupFree(ret);
5699 return(NULL); 5699 return(NULL);
5700 } 5700 }
5701 return(ret); 5701 return(ret);
5702 } 5702 }
5703 5703
5704 static xmlSchemaSubstGroupPtr 5704 static xmlSchemaSubstGroupPtr
5705 xmlSchemaSubstGroupGet(xmlSchemaParserCtxtPtr pctxt, 5705 xmlSchemaSubstGroupGet(xmlSchemaParserCtxtPtr pctxt,
5706 xmlSchemaElementPtr head) 5706 xmlSchemaElementPtr head)
5707 { 5707 {
5708 if (WXS_SUBST_GROUPS(pctxt) == NULL) 5708 if (WXS_SUBST_GROUPS(pctxt) == NULL)
5709 return(NULL); 5709 return(NULL);
5710 return(xmlHashLookup2(WXS_SUBST_GROUPS(pctxt), 5710 return(xmlHashLookup2(WXS_SUBST_GROUPS(pctxt),
5711 head->name, head->targetNamespace)); 5711 head->name, head->targetNamespace));
5712 5712
5713 } 5713 }
5714 5714
5715 /** 5715 /**
5716 * xmlSchemaAddElementSubstitutionMember: 5716 * xmlSchemaAddElementSubstitutionMember:
5717 * @pctxt: a schema parser context 5717 * @pctxt: a schema parser context
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
6113 xmlSchemaPGetBoolNodeValue(xmlSchemaParserCtxtPtr ctxt, 6113 xmlSchemaPGetBoolNodeValue(xmlSchemaParserCtxtPtr ctxt,
6114 xmlSchemaBasicItemPtr ownerItem, 6114 xmlSchemaBasicItemPtr ownerItem,
6115 xmlNodePtr node) 6115 xmlNodePtr node)
6116 { 6116 {
6117 xmlChar *value = NULL; 6117 xmlChar *value = NULL;
6118 int res = 0; 6118 int res = 0;
6119 6119
6120 value = xmlNodeGetContent(node); 6120 value = xmlNodeGetContent(node);
6121 /* 6121 /*
6122 * 3.2.2.1 Lexical representation 6122 * 3.2.2.1 Lexical representation
6123 * An instance of a datatype that is defined as ·boolean· 6123 * An instance of a datatype that is defined as �boolean�
6124 * can have the following legal literals {true, false, 1, 0}. 6124 * can have the following legal literals {true, false, 1, 0}.
6125 */ 6125 */
6126 if (xmlStrEqual(BAD_CAST value, BAD_CAST "true")) 6126 if (xmlStrEqual(BAD_CAST value, BAD_CAST "true"))
6127 res = 1; 6127 res = 1;
6128 else if (xmlStrEqual(BAD_CAST value, BAD_CAST "false")) 6128 else if (xmlStrEqual(BAD_CAST value, BAD_CAST "false"))
6129 res = 0; 6129 res = 0;
6130 else if (xmlStrEqual(BAD_CAST value, BAD_CAST "1")) 6130 else if (xmlStrEqual(BAD_CAST value, BAD_CAST "1"))
6131 res = 1; 6131 res = 1;
6132 else if (xmlStrEqual(BAD_CAST value, BAD_CAST "0")) 6132 else if (xmlStrEqual(BAD_CAST value, BAD_CAST "0"))
6133 res = 0; 6133 res = 0;
(...skipping 27 matching lines...) Expand all
6161 xmlNodePtr node, 6161 xmlNodePtr node,
6162 const char *name, int def) 6162 const char *name, int def)
6163 { 6163 {
6164 const xmlChar *val; 6164 const xmlChar *val;
6165 6165
6166 val = xmlSchemaGetProp(ctxt, node, name); 6166 val = xmlSchemaGetProp(ctxt, node, name);
6167 if (val == NULL) 6167 if (val == NULL)
6168 return (def); 6168 return (def);
6169 /* 6169 /*
6170 * 3.2.2.1 Lexical representation 6170 * 3.2.2.1 Lexical representation
6171 * An instance of a datatype that is defined as ·boolean· 6171 * An instance of a datatype that is defined as �boolean�
6172 * can have the following legal literals {true, false, 1, 0}. 6172 * can have the following legal literals {true, false, 1, 0}.
6173 */ 6173 */
6174 if (xmlStrEqual(val, BAD_CAST "true")) 6174 if (xmlStrEqual(val, BAD_CAST "true"))
6175 def = 1; 6175 def = 1;
6176 else if (xmlStrEqual(val, BAD_CAST "false")) 6176 else if (xmlStrEqual(val, BAD_CAST "false"))
6177 def = 0; 6177 def = 0;
6178 else if (xmlStrEqual(val, BAD_CAST "1")) 6178 else if (xmlStrEqual(val, BAD_CAST "1"))
6179 def = 1; 6179 def = 1;
6180 else if (xmlStrEqual(val, BAD_CAST "0")) 6180 else if (xmlStrEqual(val, BAD_CAST "0"))
6181 def = 0; 6181 def = 0;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
6281 */ 6281 */
6282 if (ret < 0) { 6282 if (ret < 0) {
6283 PERROR_INT("xmlSchemaPValAttrNodeValue", 6283 PERROR_INT("xmlSchemaPValAttrNodeValue",
6284 "failed to validate a schema attribute value"); 6284 "failed to validate a schema attribute value");
6285 return (-1); 6285 return (-1);
6286 } else if (ret > 0) { 6286 } else if (ret > 0) {
6287 if (WXS_IS_LIST(type)) 6287 if (WXS_IS_LIST(type))
6288 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2; 6288 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
6289 else 6289 else
6290 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1; 6290 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
6291 » xmlSchemaPSimpleTypeErr(pctxt, 6291 » xmlSchemaPSimpleTypeErr(pctxt,
6292 ret, ownerItem, (xmlNodePtr) attr, 6292 ret, ownerItem, (xmlNodePtr) attr,
6293 type, NULL, value, NULL, NULL, NULL); 6293 type, NULL, value, NULL, NULL, NULL);
6294 } 6294 }
6295 return (ret); 6295 return (ret);
6296 } 6296 }
6297 6297
6298 /** 6298 /**
6299 * xmlSchemaPValAttrNode: 6299 * xmlSchemaPValAttrNode:
6300 * 6300 *
6301 * @ctxt: a schema parser context 6301 * @ctxt: a schema parser context
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
6345 * @value: the resulting value if any 6345 * @value: the resulting value if any
6346 * 6346 *
6347 * Extracts and validates a value against the given built-in type. 6347 * Extracts and validates a value against the given built-in type.
6348 * This one is intended to be used internally for validation 6348 * This one is intended to be used internally for validation
6349 * of schema attribute values during parsing of the schema. 6349 * of schema attribute values during parsing of the schema.
6350 * 6350 *
6351 * Returns 0 if the value is valid, a positive error code 6351 * Returns 0 if the value is valid, a positive error code
6352 * number otherwise and -1 in case of an internal or API error. 6352 * number otherwise and -1 in case of an internal or API error.
6353 */ 6353 */
6354 static int 6354 static int
6355 xmlSchemaPValAttr(xmlSchemaParserCtxtPtr ctxt,» » 6355 xmlSchemaPValAttr(xmlSchemaParserCtxtPtr ctxt,
6356 xmlSchemaBasicItemPtr ownerItem, 6356 xmlSchemaBasicItemPtr ownerItem,
6357 xmlNodePtr ownerElem, 6357 xmlNodePtr ownerElem,
6358 const char *name, 6358 const char *name,
6359 xmlSchemaTypePtr type, 6359 xmlSchemaTypePtr type,
6360 const xmlChar **value) 6360 const xmlChar **value)
6361 { 6361 {
6362 xmlAttrPtr attr; 6362 xmlAttrPtr attr;
6363 6363
6364 if ((ctxt == NULL) || (type == NULL)) { 6364 if ((ctxt == NULL) || (type == NULL)) {
6365 if (value != NULL) 6365 if (value != NULL)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
6435 } 6435 }
6436 6436
6437 /** 6437 /**
6438 * xmlSchemaParseLocalAttributes: 6438 * xmlSchemaParseLocalAttributes:
6439 * @ctxt: a schema validation context 6439 * @ctxt: a schema validation context
6440 * @schema: the schema being built 6440 * @schema: the schema being built
6441 * @node: a subtree containing XML Schema informations 6441 * @node: a subtree containing XML Schema informations
6442 * @type: the hosting type where the attributes will be anchored 6442 * @type: the hosting type where the attributes will be anchored
6443 * 6443 *
6444 * Parses attribute uses and attribute declarations and 6444 * Parses attribute uses and attribute declarations and
6445 * attribute group references. 6445 * attribute group references.
6446 */ 6446 */
6447 static int 6447 static int
6448 xmlSchemaParseLocalAttributes(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, 6448 xmlSchemaParseLocalAttributes(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
6449 xmlNodePtr *child, xmlSchemaItemListPtr *list, 6449 xmlNodePtr *child, xmlSchemaItemListPtr *list,
6450 int parentType, int *hasRefs) 6450 int parentType, int *hasRefs)
6451 { 6451 {
6452 void *item; 6452 void *item;
6453 6453
6454 while ((IS_SCHEMA((*child), "attribute")) || 6454 while ((IS_SCHEMA((*child), "attribute")) ||
6455 (IS_SCHEMA((*child), "attributeGroup"))) { 6455 (IS_SCHEMA((*child), "attributeGroup"))) {
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
6790 if (tmp == NULL) { 6790 if (tmp == NULL) {
6791 tmp = xmlSchemaNewWildcardNsConstraint(ctxt); 6791 tmp = xmlSchemaNewWildcardNsConstraint(ctxt);
6792 if (tmp == NULL) { 6792 if (tmp == NULL) {
6793 xmlFree(nsItem); 6793 xmlFree(nsItem);
6794 return (-1); 6794 return (-1);
6795 } 6795 }
6796 tmp->value = dictnsItem; 6796 tmp->value = dictnsItem;
6797 tmp->next = NULL; 6797 tmp->next = NULL;
6798 if (wildc->nsSet == NULL) 6798 if (wildc->nsSet == NULL)
6799 wildc->nsSet = tmp; 6799 wildc->nsSet = tmp;
6800 » » else 6800 » » else if (lastNs != NULL)
6801 lastNs->next = tmp; 6801 lastNs->next = tmp;
6802 lastNs = tmp; 6802 lastNs = tmp;
6803 } 6803 }
6804 6804
6805 } 6805 }
6806 xmlFree(nsItem); 6806 xmlFree(nsItem);
6807 cur = end; 6807 cur = end;
6808 } while (*cur != 0); 6808 } while (*cur != 0);
6809 } 6809 }
6810 return (ret); 6810 return (ret);
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
7078 * Returns the attribute declaration. 7078 * Returns the attribute declaration.
7079 */ 7079 */
7080 static xmlSchemaBasicItemPtr 7080 static xmlSchemaBasicItemPtr
7081 xmlSchemaParseLocalAttribute(xmlSchemaParserCtxtPtr pctxt, 7081 xmlSchemaParseLocalAttribute(xmlSchemaParserCtxtPtr pctxt,
7082 xmlSchemaPtr schema, 7082 xmlSchemaPtr schema,
7083 xmlNodePtr node, 7083 xmlNodePtr node,
7084 xmlSchemaItemListPtr uses, 7084 xmlSchemaItemListPtr uses,
7085 int parentType) 7085 int parentType)
7086 { 7086 {
7087 const xmlChar *attrValue, *name = NULL, *ns = NULL; 7087 const xmlChar *attrValue, *name = NULL, *ns = NULL;
7088 xmlSchemaAttributeUsePtr use = NULL; 7088 xmlSchemaAttributeUsePtr use = NULL;
7089 xmlNodePtr child = NULL; 7089 xmlNodePtr child = NULL;
7090 xmlAttrPtr attr; 7090 xmlAttrPtr attr;
7091 const xmlChar *tmpNs = NULL, *tmpName = NULL, *defValue = NULL; 7091 const xmlChar *tmpNs = NULL, *tmpName = NULL, *defValue = NULL;
7092 int isRef = 0, occurs = XML_SCHEMAS_ATTR_USE_OPTIONAL; 7092 int isRef = 0, occurs = XML_SCHEMAS_ATTR_USE_OPTIONAL;
7093 int nberrors, hasForm = 0, defValueType = 0; 7093 int nberrors, hasForm = 0, defValueType = 0;
7094 7094
7095 #define WXS_ATTR_DEF_VAL_DEFAULT 1 7095 #define WXS_ATTR_DEF_VAL_DEFAULT 1
7096 #define WXS_ATTR_DEF_VAL_FIXED 2 7096 #define WXS_ATTR_DEF_VAL_FIXED 2
7097 7097
7098 /* 7098 /*
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
7132 xmlSchemaPValAttrNodeID(pctxt, attr); 7132 xmlSchemaPValAttrNodeID(pctxt, attr);
7133 goto attr_next; 7133 goto attr_next;
7134 } else if (xmlStrEqual(attr->name, BAD_CAST "type")) { 7134 } else if (xmlStrEqual(attr->name, BAD_CAST "type")) {
7135 xmlSchemaPValAttrNodeQName(pctxt, schema, NULL, 7135 xmlSchemaPValAttrNodeQName(pctxt, schema, NULL,
7136 attr, &tmpNs, &tmpName); 7136 attr, &tmpNs, &tmpName);
7137 goto attr_next; 7137 goto attr_next;
7138 } else if (xmlStrEqual(attr->name, BAD_CAST "form")) { 7138 } else if (xmlStrEqual(attr->name, BAD_CAST "form")) {
7139 /* 7139 /*
7140 * Evaluate the target namespace 7140 * Evaluate the target namespace
7141 */ 7141 */
7142 » » hasForm = 1;» » 7142 » » hasForm = 1;
7143 attrValue = xmlSchemaGetNodeContent(pctxt, 7143 attrValue = xmlSchemaGetNodeContent(pctxt,
7144 (xmlNodePtr) attr); 7144 (xmlNodePtr) attr);
7145 if (xmlStrEqual(attrValue, BAD_CAST "qualified")) { 7145 if (xmlStrEqual(attrValue, BAD_CAST "qualified")) {
7146 ns = pctxt->targetNamespace; 7146 ns = pctxt->targetNamespace;
7147 } else if (!xmlStrEqual(attrValue, BAD_CAST "unqualified")) 7147 } else if (!xmlStrEqual(attrValue, BAD_CAST "unqualified"))
7148 { 7148 {
7149 xmlSchemaPSimpleTypeErr(pctxt, 7149 xmlSchemaPSimpleTypeErr(pctxt,
7150 XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, 7150 XML_SCHEMAP_S4S_ATTR_INVALID_VALUE,
7151 NULL, (xmlNodePtr) attr, 7151 NULL, (xmlNodePtr) attr,
7152 NULL, "(qualified | unqualified)", 7152 NULL, "(qualified | unqualified)",
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
7203 goto attr_next; 7203 goto attr_next;
7204 } 7204 }
7205 } else if (! xmlStrEqual(attr->ns->href, xmlSchemaNs)) 7205 } else if (! xmlStrEqual(attr->ns->href, xmlSchemaNs))
7206 goto attr_next; 7206 goto attr_next;
7207 7207
7208 xmlSchemaPIllegalAttrErr(pctxt, 7208 xmlSchemaPIllegalAttrErr(pctxt,
7209 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); 7209 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
7210 7210
7211 attr_next: 7211 attr_next:
7212 attr = attr->next; 7212 attr = attr->next;
7213 } 7213 }
7214 /* 7214 /*
7215 * 3.2.3 : 2 7215 * 3.2.3 : 2
7216 * If default and use are both present, use must have 7216 * If default and use are both present, use must have
7217 * the actual value optional. 7217 * the actual value optional.
7218 */ 7218 */
7219 if ((defValueType == WXS_ATTR_DEF_VAL_DEFAULT) && 7219 if ((defValueType == WXS_ATTR_DEF_VAL_DEFAULT) &&
7220 (occurs != XML_SCHEMAS_ATTR_USE_OPTIONAL)) { 7220 (occurs != XML_SCHEMAS_ATTR_USE_OPTIONAL)) {
7221 xmlSchemaPSimpleTypeErr(pctxt, 7221 xmlSchemaPSimpleTypeErr(pctxt,
7222 XML_SCHEMAP_SRC_ATTRIBUTE_2, 7222 XML_SCHEMAP_SRC_ATTRIBUTE_2,
7223 NULL, node, NULL, 7223 NULL, node, NULL,
7224 "(optional | prohibited | required)", NULL, 7224 "(optional | prohibited | required)", NULL,
7225 "The value of the attribute 'use' must be 'optional' " 7225 "The value of the attribute 'use' must be 'optional' "
7226 "if the attribute 'default' is present", 7226 "if the attribute 'default' is present",
7227 NULL, NULL); 7227 NULL, NULL);
7228 } 7228 }
7229 /* 7229 /*
7230 * We want correct attributes. 7230 * We want correct attributes.
7231 */ 7231 */
7232 if (nberrors != pctxt->nberrors) 7232 if (nberrors != pctxt->nberrors)
7233 return(NULL); 7233 return(NULL);
7234 if (! isRef) { 7234 if (! isRef) {
7235 xmlSchemaAttributePtr attrDecl; 7235 xmlSchemaAttributePtr attrDecl;
7236 7236
7237 /* TODO: move XML_SCHEMAS_QUALIF_ATTR to the parser. */ 7237 /* TODO: move XML_SCHEMAS_QUALIF_ATTR to the parser. */
7238 if ((! hasForm) && (schema->flags & XML_SCHEMAS_QUALIF_ATTR)) 7238 if ((! hasForm) && (schema->flags & XML_SCHEMAS_QUALIF_ATTR))
7239 » ns = pctxt->targetNamespace;» » 7239 » ns = pctxt->targetNamespace;
7240 /* 7240 /*
7241 * 3.2.6 Schema Component Constraint: xsi: Not Allowed 7241 * 3.2.6 Schema Component Constraint: xsi: Not Allowed
7242 * TODO: Move this to the component layer. 7242 * TODO: Move this to the component layer.
7243 */ 7243 */
7244 if (xmlStrEqual(ns, xmlSchemaInstanceNs)) { 7244 if (xmlStrEqual(ns, xmlSchemaInstanceNs)) {
7245 xmlSchemaCustomErr(ACTXT_CAST pctxt, 7245 xmlSchemaCustomErr(ACTXT_CAST pctxt,
7246 XML_SCHEMAP_NO_XSI, 7246 XML_SCHEMAP_NO_XSI,
7247 node, NULL, 7247 node, NULL,
7248 "The target namespace must not match '%s'", 7248 "The target namespace must not match '%s'",
7249 xmlSchemaInstanceNs, NULL); 7249 xmlSchemaInstanceNs, NULL);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
7286 attrDecl = xmlSchemaAddAttribute(pctxt, schema, name, ns, node, 0); 7286 attrDecl = xmlSchemaAddAttribute(pctxt, schema, name, ns, node, 0);
7287 if (attrDecl == NULL) 7287 if (attrDecl == NULL)
7288 return (NULL); 7288 return (NULL);
7289 if (tmpName != NULL) { 7289 if (tmpName != NULL) {
7290 attrDecl->typeName = tmpName; 7290 attrDecl->typeName = tmpName;
7291 attrDecl->typeNs = tmpNs; 7291 attrDecl->typeNs = tmpNs;
7292 } 7292 }
7293 use->attrDecl = attrDecl; 7293 use->attrDecl = attrDecl;
7294 /* 7294 /*
7295 * Value constraint. 7295 * Value constraint.
7296 » */» 7296 » */
7297 if (defValue != NULL) { 7297 if (defValue != NULL) {
7298 attrDecl->defValue = defValue; 7298 attrDecl->defValue = defValue;
7299 if (defValueType == WXS_ATTR_DEF_VAL_FIXED) 7299 if (defValueType == WXS_ATTR_DEF_VAL_FIXED)
7300 attrDecl->flags |= XML_SCHEMAS_ATTR_FIXED; 7300 attrDecl->flags |= XML_SCHEMAS_ATTR_FIXED;
7301 } 7301 }
7302 } else if (occurs != XML_SCHEMAS_ATTR_USE_PROHIBITED) { 7302 } else if (occurs != XML_SCHEMAS_ATTR_USE_PROHIBITED) {
7303 xmlSchemaQNameRefPtr ref; 7303 xmlSchemaQNameRefPtr ref;
7304 7304
7305 /* 7305 /*
7306 * Create the attribute use component. 7306 * Create the attribute use component.
(...skipping 19 matching lines...) Expand all
7326 */ 7326 */
7327 use->attrDecl = WXS_ATTR_CAST ref; 7327 use->attrDecl = WXS_ATTR_CAST ref;
7328 /* 7328 /*
7329 * Value constraint. 7329 * Value constraint.
7330 */ 7330 */
7331 if (defValue != NULL) 7331 if (defValue != NULL)
7332 use->defValue = defValue; 7332 use->defValue = defValue;
7333 if (defValueType == WXS_ATTR_DEF_VAL_FIXED) 7333 if (defValueType == WXS_ATTR_DEF_VAL_FIXED)
7334 use->flags |= XML_SCHEMA_ATTR_USE_FIXED; 7334 use->flags |= XML_SCHEMA_ATTR_USE_FIXED;
7335 } 7335 }
7336 7336
7337 check_children: 7337 check_children:
7338 /* 7338 /*
7339 * And now for the children... 7339 * And now for the children...
7340 */ 7340 */
7341 child = node->children; 7341 child = node->children;
7342 if (occurs == XML_SCHEMAS_ATTR_USE_PROHIBITED) { 7342 if (occurs == XML_SCHEMAS_ATTR_USE_PROHIBITED) {
7343 » xmlSchemaAttributeUseProhibPtr prohib;» 7343 » xmlSchemaAttributeUseProhibPtr prohib;
7344 7344
7345 if (IS_SCHEMA(child, "annotation")) { 7345 if (IS_SCHEMA(child, "annotation")) {
7346 xmlSchemaParseAnnotation(pctxt, child, 0); 7346 xmlSchemaParseAnnotation(pctxt, child, 0);
7347 child = child->next; 7347 child = child->next;
7348 } 7348 }
7349 if (child != NULL) { 7349 if (child != NULL) {
7350 xmlSchemaPContentErr(pctxt, 7350 xmlSchemaPContentErr(pctxt,
7351 XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, 7351 XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED,
7352 NULL, node, child, NULL, 7352 NULL, node, child, NULL,
7353 "(annotation?)"); 7353 "(annotation?)");
7354 } 7354 }
7355 /* 7355 /*
7356 * Check for pointlessness of attribute prohibitions. 7356 * Check for pointlessness of attribute prohibitions.
7357 */ 7357 */
7358 » if (parentType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP) {» » 7358 » if (parentType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP) {
7359 xmlSchemaCustomWarning(ACTXT_CAST pctxt, 7359 xmlSchemaCustomWarning(ACTXT_CAST pctxt,
7360 XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH, 7360 XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH,
7361 node, NULL, 7361 node, NULL,
7362 "Skipping attribute use prohibition, since it is " 7362 "Skipping attribute use prohibition, since it is "
7363 "pointless inside an <attributeGroup>", 7363 "pointless inside an <attributeGroup>",
7364 NULL, NULL, NULL); 7364 NULL, NULL, NULL);
7365 return(NULL); 7365 return(NULL);
7366 } else if (parentType == XML_SCHEMA_TYPE_EXTENSION) { 7366 } else if (parentType == XML_SCHEMA_TYPE_EXTENSION) {
7367 xmlSchemaCustomWarning(ACTXT_CAST pctxt, 7367 xmlSchemaCustomWarning(ACTXT_CAST pctxt,
7368 XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH, 7368 XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH,
7369 node, NULL, 7369 node, NULL,
7370 "Skipping attribute use prohibition, since it is " 7370 "Skipping attribute use prohibition, since it is "
7371 "pointless when extending a type", 7371 "pointless when extending a type",
7372 NULL, NULL, NULL); 7372 NULL, NULL, NULL);
7373 return(NULL); 7373 return(NULL);
7374 } 7374 }
7375 if (! isRef) { 7375 if (! isRef) {
7376 » tmpName = name; 7376 » tmpName = name;
7377 tmpNs = ns; 7377 tmpNs = ns;
7378 } 7378 }
7379 /* 7379 /*
7380 * Check for duplicate attribute prohibitions. 7380 * Check for duplicate attribute prohibitions.
7381 */ 7381 */
7382 if (uses) { 7382 if (uses) {
7383 int i; 7383 int i;
7384 » 7384
7385 for (i = 0; i < uses->nbItems; i++) { 7385 for (i = 0; i < uses->nbItems; i++) {
7386 use = uses->items[i]; 7386 use = uses->items[i];
7387 if ((use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) && 7387 if ((use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) &&
7388 (tmpName == (WXS_ATTR_PROHIB_CAST use)->name) && 7388 (tmpName == (WXS_ATTR_PROHIB_CAST use)->name) &&
7389 (tmpNs == (WXS_ATTR_PROHIB_CAST use)->targetNamespace)) 7389 (tmpNs == (WXS_ATTR_PROHIB_CAST use)->targetNamespace))
7390 { 7390 {
7391 xmlChar *str = NULL; 7391 xmlChar *str = NULL;
7392 » » 7392
7393 xmlSchemaCustomWarning(ACTXT_CAST pctxt, 7393 xmlSchemaCustomWarning(ACTXT_CAST pctxt,
7394 XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH, 7394 XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH,
7395 node, NULL, 7395 node, NULL,
7396 "Skipping duplicate attribute use prohibition '%s'", 7396 "Skipping duplicate attribute use prohibition '%s'",
7397 xmlSchemaFormatQName(&str, tmpNs, tmpName), 7397 xmlSchemaFormatQName(&str, tmpNs, tmpName),
7398 NULL, NULL); 7398 NULL, NULL);
7399 » » FREE_AND_NULL(str)» » » 7399 » » FREE_AND_NULL(str)
7400 return(NULL); 7400 return(NULL);
7401 » » }» 7401 » » }
7402 } 7402 }
7403 } 7403 }
7404 /* 7404 /*
7405 * Create the attribute prohibition helper component. 7405 * Create the attribute prohibition helper component.
7406 */ 7406 */
7407 prohib = xmlSchemaAddAttributeUseProhib(pctxt); 7407 prohib = xmlSchemaAddAttributeUseProhib(pctxt);
7408 if (prohib == NULL) 7408 if (prohib == NULL)
7409 return(NULL); 7409 return(NULL);
7410 prohib->node = node; 7410 prohib->node = node;
7411 prohib->name = tmpName; 7411 prohib->name = tmpName;
7412 prohib->targetNamespace = tmpNs; 7412 prohib->targetNamespace = tmpNs;
7413 if (isRef) { 7413 if (isRef) {
7414 /* 7414 /*
7415 * We need at least to resolve to the attribute declaration. 7415 * We need at least to resolve to the attribute declaration.
7416 */ 7416 */
7417 WXS_ADD_PENDING(pctxt, prohib); 7417 WXS_ADD_PENDING(pctxt, prohib);
7418 } 7418 }
7419 return(WXS_BASIC_CAST prohib); 7419 return(WXS_BASIC_CAST prohib);
7420 } else { 7420 } else {
7421 if (IS_SCHEMA(child, "annotation")) { 7421 if (IS_SCHEMA(child, "annotation")) {
7422 /* 7422 /*
7423 * TODO: Should this go into the attr decl? 7423 * TODO: Should this go into the attr decl?
7424 */ 7424 */
7425 use->annot = xmlSchemaParseAnnotation(pctxt, child, 1); 7425 use->annot = xmlSchemaParseAnnotation(pctxt, child, 1);
7426 child = child->next; 7426 child = child->next;
7427 } 7427 }
7428 if (isRef) { 7428 if (isRef) {
7429 if (child != NULL) { 7429 if (child != NULL) {
7430 if (IS_SCHEMA(child, "simpleType")) 7430 if (IS_SCHEMA(child, "simpleType"))
(...skipping 26 matching lines...) Expand all
7457 } else 7457 } else
7458 WXS_ATTRUSE_TYPEDEF(use) = 7458 WXS_ATTRUSE_TYPEDEF(use) =
7459 xmlSchemaParseSimpleType(pctxt, schema, child, 0); 7459 xmlSchemaParseSimpleType(pctxt, schema, child, 0);
7460 child = child->next; 7460 child = child->next;
7461 } 7461 }
7462 if (child != NULL) 7462 if (child != NULL)
7463 xmlSchemaPContentErr(pctxt, XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, 7463 xmlSchemaPContentErr(pctxt, XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED,
7464 NULL, node, child, NULL, 7464 NULL, node, child, NULL,
7465 "(annotation?, simpleType?)"); 7465 "(annotation?, simpleType?)");
7466 } 7466 }
7467 } 7467 }
7468 return (WXS_BASIC_CAST use); 7468 return (WXS_BASIC_CAST use);
7469 } 7469 }
7470 7470
7471 7471
7472 static xmlSchemaAttributePtr 7472 static xmlSchemaAttributePtr
7473 xmlSchemaParseGlobalAttribute(xmlSchemaParserCtxtPtr pctxt, 7473 xmlSchemaParseGlobalAttribute(xmlSchemaParserCtxtPtr pctxt,
7474 xmlSchemaPtr schema, 7474 xmlSchemaPtr schema,
7475 xmlNodePtr node) 7475 xmlNodePtr node)
7476 { 7476 {
7477 const xmlChar *attrValue; 7477 const xmlChar *attrValue;
7478 xmlSchemaAttributePtr ret; 7478 xmlSchemaAttributePtr ret;
7479 xmlNodePtr child = NULL; 7479 xmlNodePtr child = NULL;
7480 xmlAttrPtr attr; 7480 xmlAttrPtr attr;
7481 7481
7482 /* 7482 /*
7483 * Note that the w3c spec assumes the schema to be validated with schema 7483 * Note that the w3c spec assumes the schema to be validated with schema
7484 * for schemas beforehand. 7484 * for schemas beforehand.
7485 * 7485 *
7486 * 3.2.3 Constraints on XML Representations of Attribute Declarations 7486 * 3.2.3 Constraints on XML Representations of Attribute Declarations
7487 */ 7487 */
7488 if ((pctxt == NULL) || (schema == NULL) || (node == NULL)) 7488 if ((pctxt == NULL) || (schema == NULL) || (node == NULL))
7489 return (NULL); 7489 return (NULL);
7490 /* 7490 /*
7491 * 3.2.3 : 3.1 7491 * 3.2.3 : 3.1
7492 * One of ref or name must be present, but not both 7492 * One of ref or name must be present, but not both
7493 */ 7493 */
7494 attr = xmlSchemaGetPropNode(node, "name"); 7494 attr = xmlSchemaGetPropNode(node, "name");
7495 if (attr == NULL) { 7495 if (attr == NULL) {
7496 xmlSchemaPMissingAttrErr(pctxt, XML_SCHEMAP_S4S_ATTR_MISSING, 7496 xmlSchemaPMissingAttrErr(pctxt, XML_SCHEMAP_S4S_ATTR_MISSING,
7497 NULL, node, "name", NULL); 7497 NULL, node, "name", NULL);
7498 return (NULL); 7498 return (NULL);
7499 } 7499 }
(...skipping 25 matching lines...) Expand all
7525 XML_SCHEMAP_NO_XSI, node, NULL, 7525 XML_SCHEMAP_NO_XSI, node, NULL,
7526 "The target namespace must not match '%s'", 7526 "The target namespace must not match '%s'",
7527 xmlSchemaInstanceNs, NULL); 7527 xmlSchemaInstanceNs, NULL);
7528 } 7528 }
7529 7529
7530 ret = xmlSchemaAddAttribute(pctxt, schema, attrValue, 7530 ret = xmlSchemaAddAttribute(pctxt, schema, attrValue,
7531 pctxt->targetNamespace, node, 1); 7531 pctxt->targetNamespace, node, 1);
7532 if (ret == NULL) 7532 if (ret == NULL)
7533 return (NULL); 7533 return (NULL);
7534 ret->flags |= XML_SCHEMAS_ATTR_GLOBAL; 7534 ret->flags |= XML_SCHEMAS_ATTR_GLOBAL;
7535 » 7535
7536 /* 7536 /*
7537 * Check for illegal attributes. 7537 * Check for illegal attributes.
7538 */ 7538 */
7539 attr = node->properties; 7539 attr = node->properties;
7540 while (attr != NULL) { 7540 while (attr != NULL) {
7541 if (attr->ns == NULL) { 7541 if (attr->ns == NULL) {
7542 if ((!xmlStrEqual(attr->name, BAD_CAST "id")) && 7542 if ((!xmlStrEqual(attr->name, BAD_CAST "id")) &&
7543 (!xmlStrEqual(attr->name, BAD_CAST "default")) && 7543 (!xmlStrEqual(attr->name, BAD_CAST "default")) &&
7544 (!xmlStrEqual(attr->name, BAD_CAST "fixed")) && 7544 (!xmlStrEqual(attr->name, BAD_CAST "fixed")) &&
7545 (!xmlStrEqual(attr->name, BAD_CAST "name")) && 7545 (!xmlStrEqual(attr->name, BAD_CAST "name")) &&
7546 (!xmlStrEqual(attr->name, BAD_CAST "type"))) 7546 (!xmlStrEqual(attr->name, BAD_CAST "type")))
7547 { 7547 {
7548 xmlSchemaPIllegalAttrErr(pctxt, 7548 xmlSchemaPIllegalAttrErr(pctxt,
7549 » » XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);» » 7549 » » XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
7550 } 7550 }
7551 } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) { 7551 } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) {
7552 xmlSchemaPIllegalAttrErr(pctxt, 7552 xmlSchemaPIllegalAttrErr(pctxt,
7553 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); 7553 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
7554 } 7554 }
7555 attr = attr->next; 7555 attr = attr->next;
7556 } 7556 }
7557 xmlSchemaPValAttrQName(pctxt, schema, NULL, 7557 xmlSchemaPValAttrQName(pctxt, schema, NULL,
7558 node, "type", &ret->typeNs, &ret->typeName); 7558 node, "type", &ret->typeNs, &ret->typeName);
7559 7559
7560 xmlSchemaPValAttrID(pctxt, node, BAD_CAST "id"); 7560 xmlSchemaPValAttrID(pctxt, node, BAD_CAST "id");
7561 /* 7561 /*
7562 * Attribute "fixed". 7562 * Attribute "fixed".
7563 */ 7563 */
7564 ret->defValue = xmlSchemaGetProp(pctxt, node, "fixed"); 7564 ret->defValue = xmlSchemaGetProp(pctxt, node, "fixed");
7565 if (ret->defValue != NULL) 7565 if (ret->defValue != NULL)
7566 ret->flags |= XML_SCHEMAS_ATTR_FIXED; 7566 ret->flags |= XML_SCHEMAS_ATTR_FIXED;
7567 /* 7567 /*
7568 * Attribute "default". 7568 * Attribute "default".
7569 */ 7569 */
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
7634 7634
7635 if ((pctxt == NULL) || (schema == NULL) || (node == NULL)) 7635 if ((pctxt == NULL) || (schema == NULL) || (node == NULL))
7636 return (NULL); 7636 return (NULL);
7637 7637
7638 attr = xmlSchemaGetPropNode(node, "ref"); 7638 attr = xmlSchemaGetPropNode(node, "ref");
7639 if (attr == NULL) { 7639 if (attr == NULL) {
7640 xmlSchemaPMissingAttrErr(pctxt, 7640 xmlSchemaPMissingAttrErr(pctxt,
7641 XML_SCHEMAP_S4S_ATTR_MISSING, 7641 XML_SCHEMAP_S4S_ATTR_MISSING,
7642 NULL, node, "ref", NULL); 7642 NULL, node, "ref", NULL);
7643 return (NULL); 7643 return (NULL);
7644 }» 7644 }
7645 xmlSchemaPValAttrNodeQName(pctxt, schema, 7645 xmlSchemaPValAttrNodeQName(pctxt, schema,
7646 NULL, attr, &refNs, &ref); 7646 NULL, attr, &refNs, &ref);
7647 if (xmlSchemaCheckReference(pctxt, schema, node, attr, refNs) != 0) 7647 if (xmlSchemaCheckReference(pctxt, schema, node, attr, refNs) != 0)
7648 return(NULL); 7648 return(NULL);
7649 7649
7650 /* 7650 /*
7651 * Check for illegal attributes. 7651 * Check for illegal attributes.
7652 */ 7652 */
7653 attr = node->properties; 7653 attr = node->properties;
7654 while (attr != NULL) { 7654 while (attr != NULL) {
7655 if (attr->ns == NULL) { 7655 if (attr->ns == NULL) {
7656 if ((!xmlStrEqual(attr->name, BAD_CAST "ref")) && 7656 if ((!xmlStrEqual(attr->name, BAD_CAST "ref")) &&
7657 (!xmlStrEqual(attr->name, BAD_CAST "id"))) 7657 (!xmlStrEqual(attr->name, BAD_CAST "id")))
7658 { 7658 {
7659 xmlSchemaPIllegalAttrErr(pctxt, 7659 xmlSchemaPIllegalAttrErr(pctxt,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
7691 */ 7691 */
7692 if (pctxt->isRedefine && pctxt->redef && 7692 if (pctxt->isRedefine && pctxt->redef &&
7693 (pctxt->redef->item->type == 7693 (pctxt->redef->item->type ==
7694 XML_SCHEMA_TYPE_ATTRIBUTEGROUP) && 7694 XML_SCHEMA_TYPE_ATTRIBUTEGROUP) &&
7695 (ref == pctxt->redef->refName) && 7695 (ref == pctxt->redef->refName) &&
7696 (refNs == pctxt->redef->refTargetNs)) 7696 (refNs == pctxt->redef->refTargetNs))
7697 { 7697 {
7698 /* 7698 /*
7699 * SPEC src-redefine: 7699 * SPEC src-redefine:
7700 * (7.1) "If it has an <attributeGroup> among its contents 7700 * (7.1) "If it has an <attributeGroup> among its contents
7701 » * the ·actual value· of whose ref [attribute] is the same 7701 » * the �actual value� of whose ref [attribute] is the same
7702 » * as the ·actual value· of its own name attribute plus 7702 » * as the �actual value� of its own name attribute plus
7703 * target namespace, then it must have exactly one such group." 7703 * target namespace, then it must have exactly one such group."
7704 */ 7704 */
7705 if (pctxt->redefCounter != 0) { 7705 if (pctxt->redefCounter != 0) {
7706 xmlChar *str = NULL; 7706 xmlChar *str = NULL;
7707 » 7707
7708 xmlSchemaCustomErr(ACTXT_CAST pctxt, 7708 xmlSchemaCustomErr(ACTXT_CAST pctxt,
7709 XML_SCHEMAP_SRC_REDEFINE, node, NULL, 7709 XML_SCHEMAP_SRC_REDEFINE, node, NULL,
7710 "The redefining attribute group definition " 7710 "The redefining attribute group definition "
7711 "'%s' must not contain more than one " 7711 "'%s' must not contain more than one "
7712 "reference to the redefined definition", 7712 "reference to the redefined definition",
7713 xmlSchemaFormatQName(&str, refNs, ref), NULL); 7713 xmlSchemaFormatQName(&str, refNs, ref), NULL);
7714 FREE_AND_NULL(str); 7714 FREE_AND_NULL(str);
7715 return(NULL); 7715 return(NULL);
7716 } 7716 }
7717 pctxt->redefCounter++; 7717 pctxt->redefCounter++;
(...skipping 13 matching lines...) Expand all
7731 * component for the attribute uses of the referenced attribute group 7731 * component for the attribute uses of the referenced attribute group
7732 * definition. 7732 * definition.
7733 */ 7733 */
7734 ret = xmlSchemaNewQNameRef(pctxt, 7734 ret = xmlSchemaNewQNameRef(pctxt,
7735 XML_SCHEMA_TYPE_ATTRIBUTEGROUP, ref, refNs); 7735 XML_SCHEMA_TYPE_ATTRIBUTEGROUP, ref, refNs);
7736 if (ret == NULL) 7736 if (ret == NULL)
7737 return(NULL); 7737 return(NULL);
7738 ret->node = node; 7738 ret->node = node;
7739 /* Add to pending items, to be able to resolve the reference. */ 7739 /* Add to pending items, to be able to resolve the reference. */
7740 WXS_ADD_PENDING(pctxt, ret); 7740 WXS_ADD_PENDING(pctxt, ret);
7741 } 7741 }
7742 return (ret); 7742 return (ret);
7743 } 7743 }
7744 7744
7745 /** 7745 /**
7746 * xmlSchemaParseAttributeGroupDefinition: 7746 * xmlSchemaParseAttributeGroupDefinition:
7747 * @pctxt: a schema validation context 7747 * @pctxt: a schema validation context
7748 * @schema: the schema being built 7748 * @schema: the schema being built
7749 * @node: a subtree containing XML Schema informations 7749 * @node: a subtree containing XML Schema informations
7750 * 7750 *
7751 * parse a XML schema Attribute Group declaration 7751 * parse a XML schema Attribute Group declaration
(...skipping 26 matching lines...) Expand all
7778 * The name is crucial, exit if invalid. 7778 * The name is crucial, exit if invalid.
7779 */ 7779 */
7780 if (xmlSchemaPValAttrNode(pctxt, 7780 if (xmlSchemaPValAttrNode(pctxt,
7781 NULL, attr, 7781 NULL, attr,
7782 xmlSchemaGetBuiltInType(XML_SCHEMAS_NCNAME), &name) != 0) { 7782 xmlSchemaGetBuiltInType(XML_SCHEMAS_NCNAME), &name) != 0) {
7783 return (NULL); 7783 return (NULL);
7784 } 7784 }
7785 ret = xmlSchemaAddAttributeGroupDefinition(pctxt, schema, 7785 ret = xmlSchemaAddAttributeGroupDefinition(pctxt, schema,
7786 name, pctxt->targetNamespace, node); 7786 name, pctxt->targetNamespace, node);
7787 if (ret == NULL) 7787 if (ret == NULL)
7788 » return (NULL);» 7788 » return (NULL);
7789 /* 7789 /*
7790 * Check for illegal attributes. 7790 * Check for illegal attributes.
7791 */ 7791 */
7792 attr = node->properties; 7792 attr = node->properties;
7793 while (attr != NULL) { 7793 while (attr != NULL) {
7794 if (attr->ns == NULL) { 7794 if (attr->ns == NULL) {
7795 if ((!xmlStrEqual(attr->name, BAD_CAST "name")) && 7795 if ((!xmlStrEqual(attr->name, BAD_CAST "name")) &&
7796 (!xmlStrEqual(attr->name, BAD_CAST "id"))) 7796 (!xmlStrEqual(attr->name, BAD_CAST "id")))
7797 { 7797 {
7798 xmlSchemaPIllegalAttrErr(pctxt, 7798 xmlSchemaPIllegalAttrErr(pctxt,
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
8178 * @ctxt: a schema validation context 8178 * @ctxt: a schema validation context
8179 * @schema: the schema being built 8179 * @schema: the schema being built
8180 * @node: a subtree containing XML Schema informations 8180 * @node: a subtree containing XML Schema informations
8181 * 8181 *
8182 * Parses a XML Schema identity-contraint definition's 8182 * Parses a XML Schema identity-contraint definition's
8183 * <selector> and <field> elements. 8183 * <selector> and <field> elements.
8184 * 8184 *
8185 * Returns the parsed identity-constraint definition. 8185 * Returns the parsed identity-constraint definition.
8186 */ 8186 */
8187 static xmlSchemaIDCSelectPtr 8187 static xmlSchemaIDCSelectPtr
8188 xmlSchemaParseIDCSelectorAndField(xmlSchemaParserCtxtPtr ctxt,» » » 8188 xmlSchemaParseIDCSelectorAndField(xmlSchemaParserCtxtPtr ctxt,
8189 xmlSchemaIDCPtr idc, 8189 xmlSchemaIDCPtr idc,
8190 xmlNodePtr node, 8190 xmlNodePtr node,
8191 int isField) 8191 int isField)
8192 { 8192 {
8193 xmlSchemaIDCSelectPtr item; 8193 xmlSchemaIDCSelectPtr item;
8194 xmlNodePtr child = NULL; 8194 xmlNodePtr child = NULL;
8195 xmlAttrPtr attr; 8195 xmlAttrPtr attr;
8196 8196
8197 /* 8197 /*
8198 * Check for illegal attributes. 8198 * Check for illegal attributes.
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
8841 if ((ctxt == NULL) || (schema == NULL) || (node == NULL)) 8841 if ((ctxt == NULL) || (schema == NULL) || (node == NULL))
8842 return (-1); 8842 return (-1);
8843 /* Not a component, don't create it. */ 8843 /* Not a component, don't create it. */
8844 type = ctxt->ctxtType; 8844 type = ctxt->ctxtType;
8845 /* 8845 /*
8846 * Mark the simple type as being of variety "union". 8846 * Mark the simple type as being of variety "union".
8847 */ 8847 */
8848 type->flags |= XML_SCHEMAS_TYPE_VARIETY_UNION; 8848 type->flags |= XML_SCHEMAS_TYPE_VARIETY_UNION;
8849 /* 8849 /*
8850 * SPEC (Base type) (2) "If the <list> or <union> alternative is chosen, 8850 * SPEC (Base type) (2) "If the <list> or <union> alternative is chosen,
8851 * then the ·simple ur-type definition·." 8851 * then the �simple ur-type definition�."
8852 */ 8852 */
8853 type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYSIMPLETYPE); 8853 type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYSIMPLETYPE);
8854 /* 8854 /*
8855 * Check for illegal attributes. 8855 * Check for illegal attributes.
8856 */ 8856 */
8857 attr = node->properties; 8857 attr = node->properties;
8858 while (attr != NULL) { 8858 while (attr != NULL) {
8859 if (attr->ns == NULL) { 8859 if (attr->ns == NULL) {
8860 if ((!xmlStrEqual(attr->name, BAD_CAST "id")) && 8860 if ((!xmlStrEqual(attr->name, BAD_CAST "id")) &&
8861 (!xmlStrEqual(attr->name, BAD_CAST "memberTypes"))) { 8861 (!xmlStrEqual(attr->name, BAD_CAST "memberTypes"))) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
9009 if ((ctxt == NULL) || (schema == NULL) || (node == NULL)) 9009 if ((ctxt == NULL) || (schema == NULL) || (node == NULL))
9010 return (NULL); 9010 return (NULL);
9011 /* Not a component, don't create it. */ 9011 /* Not a component, don't create it. */
9012 type = ctxt->ctxtType; 9012 type = ctxt->ctxtType;
9013 /* 9013 /*
9014 * Mark the type as being of variety "list". 9014 * Mark the type as being of variety "list".
9015 */ 9015 */
9016 type->flags |= XML_SCHEMAS_TYPE_VARIETY_LIST; 9016 type->flags |= XML_SCHEMAS_TYPE_VARIETY_LIST;
9017 /* 9017 /*
9018 * SPEC (Base type) (2) "If the <list> or <union> alternative is chosen, 9018 * SPEC (Base type) (2) "If the <list> or <union> alternative is chosen,
9019 * then the ·simple ur-type definition·." 9019 * then the �simple ur-type definition�."
9020 */ 9020 */
9021 type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYSIMPLETYPE); 9021 type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYSIMPLETYPE);
9022 /* 9022 /*
9023 * Check for illegal attributes. 9023 * Check for illegal attributes.
9024 */ 9024 */
9025 attr = node->properties; 9025 attr = node->properties;
9026 while (attr != NULL) { 9026 while (attr != NULL) {
9027 if (attr->ns == NULL) { 9027 if (attr->ns == NULL) {
9028 if ((!xmlStrEqual(attr->name, BAD_CAST "id")) && 9028 if ((!xmlStrEqual(attr->name, BAD_CAST "id")) &&
9029 (!xmlStrEqual(attr->name, BAD_CAST "itemType"))) { 9029 (!xmlStrEqual(attr->name, BAD_CAST "itemType"))) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
9154 return(NULL); 9154 return(NULL);
9155 } 9155 }
9156 biType = xmlSchemaGetPredefinedType(attrValue, xmlSchemaNs); 9156 biType = xmlSchemaGetPredefinedType(attrValue, xmlSchemaNs);
9157 if (biType != NULL) 9157 if (biType != NULL)
9158 return (biType); 9158 return (biType);
9159 } 9159 }
9160 } 9160 }
9161 } 9161 }
9162 /* 9162 /*
9163 * TargetNamespace: 9163 * TargetNamespace:
9164 * SPEC "The ·actual value· of the targetNamespace [attribute] 9164 * SPEC "The �actual value� of the targetNamespace [attribute]
9165 * of the <schema> ancestor element information item if present, 9165 * of the <schema> ancestor element information item if present,
9166 * otherwise ·absent·. 9166 * otherwise �absent�.
9167 */ 9167 */
9168 if (topLevel == 0) { 9168 if (topLevel == 0) {
9169 #ifdef ENABLE_NAMED_LOCALS 9169 #ifdef ENABLE_NAMED_LOCALS
9170 char buf[40]; 9170 char buf[40];
9171 #endif 9171 #endif
9172 /* 9172 /*
9173 * Parse as local simple type definition. 9173 * Parse as local simple type definition.
9174 */ 9174 */
9175 #ifdef ENABLE_NAMED_LOCALS 9175 #ifdef ENABLE_NAMED_LOCALS
9176 snprintf(buf, 39, "#ST%d", ctxt->counter++ + 1); 9176 snprintf(buf, 39, "#ST%d", ctxt->counter++ + 1);
(...skipping 11 matching lines...) Expand all
9188 type->type = XML_SCHEMA_TYPE_SIMPLE; 9188 type->type = XML_SCHEMA_TYPE_SIMPLE;
9189 type->contentType = XML_SCHEMA_CONTENT_SIMPLE; 9189 type->contentType = XML_SCHEMA_CONTENT_SIMPLE;
9190 /* 9190 /*
9191 * Check for illegal attributes. 9191 * Check for illegal attributes.
9192 */ 9192 */
9193 attr = node->properties; 9193 attr = node->properties;
9194 while (attr != NULL) { 9194 while (attr != NULL) {
9195 if (attr->ns == NULL) { 9195 if (attr->ns == NULL) {
9196 if (!xmlStrEqual(attr->name, BAD_CAST "id")) { 9196 if (!xmlStrEqual(attr->name, BAD_CAST "id")) {
9197 xmlSchemaPIllegalAttrErr(ctxt, 9197 xmlSchemaPIllegalAttrErr(ctxt,
9198 » » » XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); 9198 » » » XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
9199 } 9199 }
9200 } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) { 9200 } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) {
9201 xmlSchemaPIllegalAttrErr(ctxt, 9201 xmlSchemaPIllegalAttrErr(ctxt,
9202 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); 9202 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
9203 } 9203 }
9204 attr = attr->next; 9204 attr = attr->next;
9205 } 9205 }
9206 } else { 9206 } else {
9207 /* 9207 /*
9208 * Parse as global simple type definition. 9208 * Parse as global simple type definition.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
9259 attrValue, NULL, NULL, NULL); 9259 attrValue, NULL, NULL, NULL);
9260 } 9260 }
9261 } 9261 }
9262 } 9262 }
9263 type->targetNamespace = ctxt->targetNamespace; 9263 type->targetNamespace = ctxt->targetNamespace;
9264 xmlSchemaPValAttrID(ctxt, node, BAD_CAST "id"); 9264 xmlSchemaPValAttrID(ctxt, node, BAD_CAST "id");
9265 /* 9265 /*
9266 * And now for the children... 9266 * And now for the children...
9267 */ 9267 */
9268 oldCtxtType = ctxt->ctxtType; 9268 oldCtxtType = ctxt->ctxtType;
9269 9269
9270 ctxt->ctxtType = type; 9270 ctxt->ctxtType = type;
9271 9271
9272 child = node->children; 9272 child = node->children;
9273 if (IS_SCHEMA(child, "annotation")) { 9273 if (IS_SCHEMA(child, "annotation")) {
9274 type->annot = xmlSchemaParseAnnotation(ctxt, child, 1); 9274 type->annot = xmlSchemaParseAnnotation(ctxt, child, 1);
9275 child = child->next; 9275 child = child->next;
9276 } 9276 }
9277 if (child == NULL) { 9277 if (child == NULL) {
9278 xmlSchemaPContentErr(ctxt, XML_SCHEMAP_S4S_ELEM_MISSING, 9278 xmlSchemaPContentErr(ctxt, XML_SCHEMAP_S4S_ELEM_MISSING,
9279 NULL, node, child, NULL, 9279 NULL, node, child, NULL,
9280 "(annotation?, (restriction | list | union))"); 9280 "(annotation?, (restriction | list | union))");
9281 } else if (IS_SCHEMA(child, "restriction")) {» 9281 } else if (IS_SCHEMA(child, "restriction")) {
9282 xmlSchemaParseRestriction(ctxt, schema, child, 9282 xmlSchemaParseRestriction(ctxt, schema, child,
9283 » XML_SCHEMA_TYPE_SIMPLE);» 9283 » XML_SCHEMA_TYPE_SIMPLE);
9284 » hasRestriction = 1;» 9284 » hasRestriction = 1;
9285 child = child->next; 9285 child = child->next;
9286 } else if (IS_SCHEMA(child, "list")) { 9286 } else if (IS_SCHEMA(child, "list")) {
9287 xmlSchemaParseList(ctxt, schema, child); 9287 xmlSchemaParseList(ctxt, schema, child);
9288 child = child->next; 9288 child = child->next;
9289 } else if (IS_SCHEMA(child, "union")) { 9289 } else if (IS_SCHEMA(child, "union")) {
9290 xmlSchemaParseUnion(ctxt, schema, child); 9290 xmlSchemaParseUnion(ctxt, schema, child);
9291 child = child->next; 9291 child = child->next;
9292 } 9292 }
9293 if (child != NULL) { 9293 if (child != NULL) {
9294 xmlSchemaPContentErr(ctxt, XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, 9294 xmlSchemaPContentErr(ctxt, XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED,
9295 NULL, node, child, NULL, 9295 NULL, node, child, NULL,
9296 "(annotation?, (restriction | list | union))"); 9296 "(annotation?, (restriction | list | union))");
9297 } 9297 }
9298 /* 9298 /*
9299 * REDEFINE: SPEC src-redefine (5) 9299 * REDEFINE: SPEC src-redefine (5)
9300 * "Within the [children], each <simpleType> must have a 9300 * "Within the [children], each <simpleType> must have a
9301 * <restriction> among its [children] ... the ·actual value· of whose 9301 * <restriction> among its [children] ... the �actual value� of whose
9302 * base [attribute] must be the same as the ·actual value· of its own 9302 * base [attribute] must be the same as the �actual value� of its own
9303 * name attribute plus target namespace;" 9303 * name attribute plus target namespace;"
9304 */ 9304 */
9305 if (topLevel && ctxt->isRedefine && (! hasRestriction)) { 9305 if (topLevel && ctxt->isRedefine && (! hasRestriction)) {
9306 xmlSchemaPCustomErr(ctxt, XML_SCHEMAP_SRC_REDEFINE, 9306 xmlSchemaPCustomErr(ctxt, XML_SCHEMAP_SRC_REDEFINE,
9307 NULL, node, "This is a redefinition, thus the " 9307 NULL, node, "This is a redefinition, thus the "
9308 "<simpleType> must have a <restriction> child", NULL); 9308 "<simpleType> must have a <restriction> child", NULL);
9309 } 9309 }
9310 9310
9311 ctxt->ctxtType = oldCtxtType; 9311 ctxt->ctxtType = oldCtxtType;
9312 return (type); 9312 return (type);
9313 } 9313 }
9314 9314
9315 /** 9315 /**
9316 * xmlSchemaParseModelGroupDefRef: 9316 * xmlSchemaParseModelGroupDefRef:
9317 * @ctxt: the parser context 9317 * @ctxt: the parser context
9318 * @schema: the schema being built 9318 * @schema: the schema being built
9319 * @node: the node 9319 * @node: the node
9320 * 9320 *
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
9366 } 9366 }
9367 } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) { 9367 } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) {
9368 xmlSchemaPIllegalAttrErr(ctxt, 9368 xmlSchemaPIllegalAttrErr(ctxt,
9369 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); 9369 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
9370 } 9370 }
9371 attr = attr->next; 9371 attr = attr->next;
9372 } 9372 }
9373 xmlSchemaPValAttrID(ctxt, node, BAD_CAST "id"); 9373 xmlSchemaPValAttrID(ctxt, node, BAD_CAST "id");
9374 item = xmlSchemaAddParticle(ctxt, node, min, max); 9374 item = xmlSchemaAddParticle(ctxt, node, min, max);
9375 if (item == NULL) 9375 if (item == NULL)
9376 » return (NULL); 9376 » return (NULL);
9377 /* 9377 /*
9378 * Create a qname-reference and set as the term; it will be substituted 9378 * Create a qname-reference and set as the term; it will be substituted
9379 * for the model group after the reference has been resolved. 9379 * for the model group after the reference has been resolved.
9380 */ 9380 */
9381 item->children = (xmlSchemaTreeItemPtr) 9381 item->children = (xmlSchemaTreeItemPtr)
9382 » xmlSchemaNewQNameRef(ctxt, XML_SCHEMA_TYPE_GROUP, ref, refNs); 9382 » xmlSchemaNewQNameRef(ctxt, XML_SCHEMA_TYPE_GROUP, ref, refNs);
9383 xmlSchemaPCheckParticleCorrect_2(ctxt, item, node, min, max); 9383 xmlSchemaPCheckParticleCorrect_2(ctxt, item, node, min, max);
9384 /* 9384 /*
9385 * And now for the children... 9385 * And now for the children...
9386 */ 9386 */
9387 child = node->children; 9387 child = node->children;
9388 /* TODO: Is annotation even allowed for a model group reference? */ 9388 /* TODO: Is annotation even allowed for a model group reference? */
9389 if (IS_SCHEMA(child, "annotation")) { 9389 if (IS_SCHEMA(child, "annotation")) {
9390 /* 9390 /*
9391 * TODO: What to do exactly with the annotation? 9391 * TODO: What to do exactly with the annotation?
9392 */ 9392 */
(...skipping 19 matching lines...) Expand all
9412 * xmlSchemaParseModelGroupDefinition: 9412 * xmlSchemaParseModelGroupDefinition:
9413 * @ctxt: a schema validation context 9413 * @ctxt: a schema validation context
9414 * @schema: the schema being built 9414 * @schema: the schema being built
9415 * @node: a subtree containing XML Schema informations 9415 * @node: a subtree containing XML Schema informations
9416 * 9416 *
9417 * Parses a XML schema model group definition. 9417 * Parses a XML schema model group definition.
9418 * 9418 *
9419 * Note that the contraint src-redefine (6.2) can't be applied until 9419 * Note that the contraint src-redefine (6.2) can't be applied until
9420 * references have been resolved. So we will do this at the 9420 * references have been resolved. So we will do this at the
9421 * component fixup level. 9421 * component fixup level.
9422 * 9422 *
9423 * *WARNING* this interface is highly subject to change 9423 * *WARNING* this interface is highly subject to change
9424 * 9424 *
9425 * Returns -1 in case of error, 0 if the declaration is improper and 9425 * Returns -1 in case of error, 0 if the declaration is improper and
9426 * 1 in case of success. 9426 * 1 in case of success.
9427 */ 9427 */
9428 static xmlSchemaModelGroupDefPtr 9428 static xmlSchemaModelGroupDefPtr
9429 xmlSchemaParseModelGroupDefinition(xmlSchemaParserCtxtPtr ctxt, 9429 xmlSchemaParseModelGroupDefinition(xmlSchemaParserCtxtPtr ctxt,
9430 xmlSchemaPtr schema, 9430 xmlSchemaPtr schema,
9431 xmlNodePtr node) 9431 xmlNodePtr node)
9432 { 9432 {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
9486 } else if (IS_SCHEMA(child, "choice")) { 9486 } else if (IS_SCHEMA(child, "choice")) {
9487 item->children = xmlSchemaParseModelGroup(ctxt, schema, child, 9487 item->children = xmlSchemaParseModelGroup(ctxt, schema, child,
9488 XML_SCHEMA_TYPE_CHOICE, 0); 9488 XML_SCHEMA_TYPE_CHOICE, 0);
9489 child = child->next; 9489 child = child->next;
9490 } else if (IS_SCHEMA(child, "sequence")) { 9490 } else if (IS_SCHEMA(child, "sequence")) {
9491 item->children = xmlSchemaParseModelGroup(ctxt, schema, child, 9491 item->children = xmlSchemaParseModelGroup(ctxt, schema, child,
9492 XML_SCHEMA_TYPE_SEQUENCE, 0); 9492 XML_SCHEMA_TYPE_SEQUENCE, 0);
9493 child = child->next; 9493 child = child->next;
9494 } 9494 }
9495 9495
9496 9496
9497 9497
9498 if (child != NULL) { 9498 if (child != NULL) {
9499 xmlSchemaPContentErr(ctxt, 9499 xmlSchemaPContentErr(ctxt,
9500 XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, 9500 XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED,
9501 NULL, node, child, NULL, 9501 NULL, node, child, NULL,
9502 "(annotation?, (all | choice | sequence)?)"); 9502 "(annotation?, (all | choice | sequence)?)");
9503 } 9503 }
9504 return (item); 9504 return (item);
9505 } 9505 }
9506 9506
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
9624 HFAILURE; 9624 HFAILURE;
9625 9625
9626 /* 9626 /*
9627 * Since the version is of type xs:token, we won't bother to 9627 * Since the version is of type xs:token, we won't bother to
9628 * check it. 9628 * check it.
9629 */ 9629 */
9630 /* REMOVED: 9630 /* REMOVED:
9631 attr = xmlSchemaGetPropNode(node, "version"); 9631 attr = xmlSchemaGetPropNode(node, "version");
9632 if (attr != NULL) { 9632 if (attr != NULL) {
9633 res = xmlSchemaPValAttrNode(ctxt, NULL, NULL, attr, 9633 res = xmlSchemaPValAttrNode(ctxt, NULL, NULL, attr,
9634 » xmlSchemaGetBuiltInType(XML_SCHEMAS_TOKEN), &val); 9634 » xmlSchemaGetBuiltInType(XML_SCHEMAS_TOKEN), &val);
9635 HFAILURE; 9635 HFAILURE;
9636 } 9636 }
9637 */ 9637 */
9638 attr = xmlSchemaGetPropNode(node, "targetNamespace"); 9638 attr = xmlSchemaGetPropNode(node, "targetNamespace");
9639 if (attr != NULL) { 9639 if (attr != NULL) {
9640 res = xmlSchemaPValAttrNode(ctxt, NULL, attr, 9640 res = xmlSchemaPValAttrNode(ctxt, NULL, attr,
9641 xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYURI), NULL); 9641 xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYURI), NULL);
9642 HFAILURE; 9642 HFAILURE;
9643 if (res != 0) { 9643 if (res != 0) {
9644 ctxt->stop = XML_SCHEMAP_S4S_ATTR_INVALID_VALUE; 9644 ctxt->stop = XML_SCHEMAP_S4S_ATTR_INVALID_VALUE;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
9684 if (res != 0) { 9684 if (res != 0) {
9685 xmlSchemaPSimpleTypeErr(ctxt, 9685 xmlSchemaPSimpleTypeErr(ctxt,
9686 XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, 9686 XML_SCHEMAP_S4S_ATTR_INVALID_VALUE,
9687 NULL, (xmlNodePtr) attr, NULL, 9687 NULL, (xmlNodePtr) attr, NULL,
9688 "(#all | List of (extension | restriction | list | union))", 9688 "(#all | List of (extension | restriction | list | union))",
9689 val, NULL, NULL, NULL); 9689 val, NULL, NULL, NULL);
9690 } 9690 }
9691 } 9691 }
9692 attr = xmlSchemaGetPropNode(node, "blockDefault"); 9692 attr = xmlSchemaGetPropNode(node, "blockDefault");
9693 if (attr != NULL) { 9693 if (attr != NULL) {
9694 » val = xmlSchemaGetNodeContent(ctxt, (xmlNodePtr) attr);» 9694 » val = xmlSchemaGetNodeContent(ctxt, (xmlNodePtr) attr);
9695 res = xmlSchemaPValAttrBlockFinal(val, &(schema->flags), -1, 9695 res = xmlSchemaPValAttrBlockFinal(val, &(schema->flags), -1,
9696 XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION, 9696 XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION,
9697 XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION, 9697 XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION,
9698 XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION, -1, -1); 9698 XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION, -1, -1);
9699 HFAILURE; 9699 HFAILURE;
9700 if (res != 0) { 9700 if (res != 0) {
9701 xmlSchemaPSimpleTypeErr(ctxt, 9701 xmlSchemaPSimpleTypeErr(ctxt,
9702 XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, 9702 XML_SCHEMAP_S4S_ATTR_INVALID_VALUE,
9703 NULL, (xmlNodePtr) attr, NULL, 9703 NULL, (xmlNodePtr) attr, NULL,
9704 "(#all | List of (extension | restriction | substitution))", 9704 "(#all | List of (extension | restriction | substitution))",
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
9745 if (schema->annot == NULL) 9745 if (schema->annot == NULL)
9746 schema->annot = annot; 9746 schema->annot = annot;
9747 else 9747 else
9748 xmlSchemaFreeAnnot(annot); 9748 xmlSchemaFreeAnnot(annot);
9749 } else if (IS_SCHEMA(child, "import")) { 9749 } else if (IS_SCHEMA(child, "import")) {
9750 tmpOldErrs = ctxt->nberrors; 9750 tmpOldErrs = ctxt->nberrors;
9751 res = xmlSchemaParseImport(ctxt, schema, child); 9751 res = xmlSchemaParseImport(ctxt, schema, child);
9752 HFAILURE; 9752 HFAILURE;
9753 HSTOP(ctxt); 9753 HSTOP(ctxt);
9754 if (tmpOldErrs != ctxt->nberrors) 9754 if (tmpOldErrs != ctxt->nberrors)
9755 » » goto exit;» 9755 » » goto exit;
9756 } else if (IS_SCHEMA(child, "include")) { 9756 } else if (IS_SCHEMA(child, "include")) {
9757 tmpOldErrs = ctxt->nberrors; 9757 tmpOldErrs = ctxt->nberrors;
9758 res = xmlSchemaParseInclude(ctxt, schema, child); 9758 res = xmlSchemaParseInclude(ctxt, schema, child);
9759 HFAILURE; 9759 HFAILURE;
9760 HSTOP(ctxt); 9760 HSTOP(ctxt);
9761 if (tmpOldErrs != ctxt->nberrors) 9761 if (tmpOldErrs != ctxt->nberrors)
9762 » » goto exit;» 9762 » » goto exit;
9763 } else if (IS_SCHEMA(child, "redefine")) { 9763 } else if (IS_SCHEMA(child, "redefine")) {
9764 tmpOldErrs = ctxt->nberrors; 9764 tmpOldErrs = ctxt->nberrors;
9765 res = xmlSchemaParseRedefine(ctxt, schema, child); 9765 res = xmlSchemaParseRedefine(ctxt, schema, child);
9766 HFAILURE; 9766 HFAILURE;
9767 HSTOP(ctxt); 9767 HSTOP(ctxt);
9768 if (tmpOldErrs != ctxt->nberrors) 9768 if (tmpOldErrs != ctxt->nberrors)
9769 goto exit; 9769 goto exit;
9770 } 9770 }
9771 child = child->next; 9771 child = child->next;
9772 } 9772 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
9877 if (con->substGroups != NULL) 9877 if (con->substGroups != NULL)
9878 xmlHashFree(con->substGroups, 9878 xmlHashFree(con->substGroups,
9879 (xmlHashDeallocator) xmlSchemaSubstGroupFree); 9879 (xmlHashDeallocator) xmlSchemaSubstGroupFree);
9880 if (con->redefs != NULL) 9880 if (con->redefs != NULL)
9881 xmlSchemaRedefListFree(con->redefs); 9881 xmlSchemaRedefListFree(con->redefs);
9882 if (con->dict != NULL) 9882 if (con->dict != NULL)
9883 xmlDictFree(con->dict); 9883 xmlDictFree(con->dict);
9884 xmlFree(con); 9884 xmlFree(con);
9885 } 9885 }
9886 9886
9887 static xmlSchemaConstructionCtxtPtr 9887 static xmlSchemaConstructionCtxtPtr
9888 xmlSchemaConstructionCtxtCreate(xmlDictPtr dict) 9888 xmlSchemaConstructionCtxtCreate(xmlDictPtr dict)
9889 { 9889 {
9890 xmlSchemaConstructionCtxtPtr ret; 9890 xmlSchemaConstructionCtxtPtr ret;
9891 9891
9892 ret = (xmlSchemaConstructionCtxtPtr) 9892 ret = (xmlSchemaConstructionCtxtPtr)
9893 xmlMalloc(sizeof(xmlSchemaConstructionCtxt)); 9893 xmlMalloc(sizeof(xmlSchemaConstructionCtxt));
9894 if (ret == NULL) { 9894 if (ret == NULL) {
9895 xmlSchemaPErrMemory(NULL, 9895 xmlSchemaPErrMemory(NULL,
9896 "allocating schema construction context", NULL); 9896 "allocating schema construction context", NULL);
9897 return (NULL); 9897 return (NULL);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
9947 * to contain an XML Schemas file. 9947 * to contain an XML Schemas file.
9948 * 9948 *
9949 * Returns the parser context or NULL in case of error 9949 * Returns the parser context or NULL in case of error
9950 */ 9950 */
9951 static xmlSchemaParserCtxtPtr 9951 static xmlSchemaParserCtxtPtr
9952 xmlSchemaNewParserCtxtUseDict(const char *URL, xmlDictPtr dict) 9952 xmlSchemaNewParserCtxtUseDict(const char *URL, xmlDictPtr dict)
9953 { 9953 {
9954 xmlSchemaParserCtxtPtr ret; 9954 xmlSchemaParserCtxtPtr ret;
9955 9955
9956 ret = xmlSchemaParserCtxtCreate(); 9956 ret = xmlSchemaParserCtxtCreate();
9957 if (ret == NULL) 9957 if (ret == NULL)
9958 return (NULL); 9958 return (NULL);
9959 ret->dict = dict; 9959 ret->dict = dict;
9960 xmlDictReference(dict); 9960 xmlDictReference(dict);
9961 if (URL != NULL) 9961 if (URL != NULL)
9962 ret->URL = xmlDictLookup(dict, (const xmlChar *) URL, -1); 9962 ret->URL = xmlDictLookup(dict, (const xmlChar *) URL, -1);
9963 return (ret); 9963 return (ret);
9964 } 9964 }
9965 9965
9966 static int 9966 static int
9967 xmlSchemaCreatePCtxtOnVCtxt(xmlSchemaValidCtxtPtr vctxt) 9967 xmlSchemaCreatePCtxtOnVCtxt(xmlSchemaValidCtxtPtr vctxt)
9968 { 9968 {
9969 if (vctxt->pctxt == NULL) { 9969 if (vctxt->pctxt == NULL) {
9970 if (vctxt->schema != NULL) 9970 if (vctxt->schema != NULL)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
10075 static int 10075 static int
10076 xmlSchemaParseNewDocWithContext(xmlSchemaParserCtxtPtr pctxt, 10076 xmlSchemaParseNewDocWithContext(xmlSchemaParserCtxtPtr pctxt,
10077 xmlSchemaPtr schema, 10077 xmlSchemaPtr schema,
10078 xmlSchemaBucketPtr bucket) 10078 xmlSchemaBucketPtr bucket)
10079 { 10079 {
10080 int oldFlags; 10080 int oldFlags;
10081 xmlDocPtr oldDoc; 10081 xmlDocPtr oldDoc;
10082 xmlNodePtr node; 10082 xmlNodePtr node;
10083 int ret, oldErrs; 10083 int ret, oldErrs;
10084 xmlSchemaBucketPtr oldbucket = pctxt->constructor->bucket; 10084 xmlSchemaBucketPtr oldbucket = pctxt->constructor->bucket;
10085 10085
10086 /* 10086 /*
10087 * Save old values; reset the *main* schema. 10087 * Save old values; reset the *main* schema.
10088 * URGENT TODO: This is not good; move the per-document information 10088 * URGENT TODO: This is not good; move the per-document information
10089 * to the parser. Get rid of passing the main schema to the 10089 * to the parser. Get rid of passing the main schema to the
10090 * parsing functions. 10090 * parsing functions.
10091 */ 10091 */
10092 oldFlags = schema->flags; 10092 oldFlags = schema->flags;
10093 oldDoc = schema->doc; 10093 oldDoc = schema->doc;
10094 if (schema->flags != 0) 10094 if (schema->flags != 0)
10095 xmlSchemaClearSchemaDefaults(schema); 10095 xmlSchemaClearSchemaDefaults(schema);
10096 schema->doc = bucket->doc; 10096 schema->doc = bucket->doc;
10097 pctxt->schema = schema; 10097 pctxt->schema = schema;
10098 /* 10098 /*
10099 * Keep the current target namespace on the parser *not* on the 10099 * Keep the current target namespace on the parser *not* on the
10100 * main schema. 10100 * main schema.
10101 */ 10101 */
10102 pctxt->targetNamespace = bucket->targetNamespace; 10102 pctxt->targetNamespace = bucket->targetNamespace;
10103 WXS_CONSTRUCTOR(pctxt)->bucket = bucket; 10103 WXS_CONSTRUCTOR(pctxt)->bucket = bucket;
10104 10104
10105 if ((bucket->targetNamespace != NULL) && 10105 if ((bucket->targetNamespace != NULL) &&
10106 xmlStrEqual(bucket->targetNamespace, xmlSchemaNs)) { 10106 xmlStrEqual(bucket->targetNamespace, xmlSchemaNs)) {
10107 /* 10107 /*
10108 * We are parsing the schema for schemas! 10108 * We are parsing the schema for schemas!
10109 */ 10109 */
10110 pctxt->isS4S = 1; 10110 pctxt->isS4S = 1;
10111 } 10111 }
10112 /* Mark it as parsed, even if parsing fails. */ 10112 /* Mark it as parsed, even if parsing fails. */
10113 bucket->parsed++; 10113 bucket->parsed++;
10114 /* Compile the schema doc. */ 10114 /* Compile the schema doc. */
10115 node = xmlDocGetRootElement(bucket->doc); 10115 node = xmlDocGetRootElement(bucket->doc);
10116 ret = xmlSchemaParseSchemaElement(pctxt, schema, node); 10116 ret = xmlSchemaParseSchemaElement(pctxt, schema, node);
10117 if (ret != 0) 10117 if (ret != 0)
10118 goto exit; 10118 goto exit;
10119 /* An empty schema; just get out. */ 10119 /* An empty schema; just get out. */
10120 if (node->children == NULL) 10120 if (node->children == NULL)
10121 goto exit; 10121 goto exit;
10122 oldErrs = pctxt->nberrors; 10122 oldErrs = pctxt->nberrors;
10123 ret = xmlSchemaParseSchemaTopLevel(pctxt, schema, node->children); 10123 ret = xmlSchemaParseSchemaTopLevel(pctxt, schema, node->children);
10124 if (ret != 0) 10124 if (ret != 0)
10125 goto exit; 10125 goto exit;
10126 /* 10126 /*
10127 * TODO: Not nice, but I'm not 100% sure we will get always an error 10127 * TODO: Not nice, but I'm not 100% sure we will get always an error
10128 * as a result of the obove functions; so better rely on pctxt->err 10128 * as a result of the obove functions; so better rely on pctxt->err
10129 * as well. 10129 * as well.
10130 */ 10130 */
10131 if ((ret == 0) && (oldErrs != pctxt->nberrors)) { 10131 if ((ret == 0) && (oldErrs != pctxt->nberrors)) {
10132 ret = pctxt->err; 10132 ret = pctxt->err;
10133 goto exit; 10133 goto exit;
10134 } 10134 }
10135 10135
10136 exit: 10136 exit:
10137 WXS_CONSTRUCTOR(pctxt)->bucket = oldbucket; 10137 WXS_CONSTRUCTOR(pctxt)->bucket = oldbucket;
10138 /* Restore schema values. */ 10138 /* Restore schema values. */
10139 schema->doc = oldDoc; 10139 schema->doc = oldDoc;
10140 schema->flags = oldFlags; 10140 schema->flags = oldFlags;
10141 return(ret); 10141 return(ret);
10142 } 10142 }
10143 10143
10144 static int 10144 static int
10145 xmlSchemaParseNewDoc(xmlSchemaParserCtxtPtr pctxt, 10145 xmlSchemaParseNewDoc(xmlSchemaParserCtxtPtr pctxt,
(...skipping 12 matching lines...) Expand all
10158 } 10158 }
10159 if (bucket->doc == NULL) { 10159 if (bucket->doc == NULL) {
10160 PERROR_INT("xmlSchemaParseNewDoc", 10160 PERROR_INT("xmlSchemaParseNewDoc",
10161 "parsing a schema doc, but there's no doc"); 10161 "parsing a schema doc, but there's no doc");
10162 return(-1); 10162 return(-1);
10163 } 10163 }
10164 if (pctxt->constructor == NULL) { 10164 if (pctxt->constructor == NULL) {
10165 PERROR_INT("xmlSchemaParseNewDoc", 10165 PERROR_INT("xmlSchemaParseNewDoc",
10166 "no constructor"); 10166 "no constructor");
10167 return(-1); 10167 return(-1);
10168 } 10168 }
10169 /* Create and init the temporary parser context. */ 10169 /* Create and init the temporary parser context. */
10170 newpctxt = xmlSchemaNewParserCtxtUseDict( 10170 newpctxt = xmlSchemaNewParserCtxtUseDict(
10171 (const char *) bucket->schemaLocation, pctxt->dict); 10171 (const char *) bucket->schemaLocation, pctxt->dict);
10172 if (newpctxt == NULL) 10172 if (newpctxt == NULL)
10173 return(-1); 10173 return(-1);
10174 newpctxt->constructor = pctxt->constructor; 10174 newpctxt->constructor = pctxt->constructor;
10175 /* 10175 /*
10176 * TODO: Can we avoid that the parser knows about the main schema? 10176 * TODO: Can we avoid that the parser knows about the main schema?
10177 * It would be better if he knows about the current schema bucket 10177 * It would be better if he knows about the current schema bucket
10178 * only. 10178 * only.
10179 */ 10179 */
10180 newpctxt->schema = schema; 10180 newpctxt->schema = schema;
10181 xmlSchemaSetParserErrors(newpctxt, pctxt->error, pctxt->warning, 10181 xmlSchemaSetParserErrors(newpctxt, pctxt->error, pctxt->warning,
10182 pctxt->errCtxt); 10182 pctxt->errCtxt);
10183 xmlSchemaSetParserStructuredErrors(newpctxt, pctxt->serror, 10183 xmlSchemaSetParserStructuredErrors(newpctxt, pctxt->serror,
10184 pctxt->errCtxt); 10184 pctxt->errCtxt);
10185 newpctxt->counter = pctxt->counter; 10185 newpctxt->counter = pctxt->counter;
10186 10186
10187 10187
10188 res = xmlSchemaParseNewDocWithContext(newpctxt, schema, bucket); 10188 res = xmlSchemaParseNewDocWithContext(newpctxt, schema, bucket);
10189 10189
10190 /* Channel back errors and cleanup the temporary parser context. */ 10190 /* Channel back errors and cleanup the temporary parser context. */
10191 if (res != 0) 10191 if (res != 0)
10192 pctxt->err = res; 10192 pctxt->err = res;
10193 pctxt->nberrors += newpctxt->nberrors; 10193 pctxt->nberrors += newpctxt->nberrors;
10194 pctxt->counter = newpctxt->counter; 10194 pctxt->counter = newpctxt->counter;
10195 newpctxt->constructor = NULL; 10195 newpctxt->constructor = NULL;
10196 /* Free the parser context. */ 10196 /* Free the parser context. */
10197 xmlSchemaFreeParserCtxt(newpctxt); 10197 xmlSchemaFreeParserCtxt(newpctxt);
10198 return(res); 10198 return(res);
10199 } 10199 }
10200 10200
10201 static void 10201 static void
10202 xmlSchemaSchemaRelationAddChild(xmlSchemaBucketPtr bucket, 10202 xmlSchemaSchemaRelationAddChild(xmlSchemaBucketPtr bucket,
10203 xmlSchemaSchemaRelationPtr rel) 10203 xmlSchemaSchemaRelationPtr rel)
10204 { 10204 {
10205 xmlSchemaSchemaRelationPtr cur = bucket->relations; 10205 xmlSchemaSchemaRelationPtr cur = bucket->relations;
10206 10206
10207 if (cur == NULL) { 10207 if (cur == NULL) {
10208 bucket->relations = rel; 10208 bucket->relations = rel;
10209 return; 10209 return;
10210 } 10210 }
10211 while (cur->next != NULL) 10211 while (cur->next != NULL)
10212 cur = cur->next; 10212 cur = cur->next;
10213 cur->next = rel; 10213 cur->next = rel;
10214 } 10214 }
10215 10215
10216 10216
10217 static const xmlChar * 10217 static const xmlChar *
10218 xmlSchemaBuildAbsoluteURI(xmlDictPtr dict, const xmlChar* location, 10218 xmlSchemaBuildAbsoluteURI(xmlDictPtr dict, const xmlChar* location,
10219 xmlNodePtr ctxtNode) 10219 xmlNodePtr ctxtNode)
10220 { 10220 {
10221 /* 10221 /*
10222 * Build an absolue location URI. 10222 * Build an absolue location URI.
10223 */ 10223 */
10224 if (location != NULL) {» 10224 if (location != NULL) {
10225 if (ctxtNode == NULL) 10225 if (ctxtNode == NULL)
10226 return(location); 10226 return(location);
10227 else { 10227 else {
10228 xmlChar *base, *URI; 10228 xmlChar *base, *URI;
10229 const xmlChar *ret = NULL; 10229 const xmlChar *ret = NULL;
10230 10230
10231 base = xmlNodeGetBase(ctxtNode->doc, ctxtNode); 10231 base = xmlNodeGetBase(ctxtNode->doc, ctxtNode);
10232 if (base == NULL) { 10232 if (base == NULL) {
10233 URI = xmlBuildURI(location, ctxtNode->doc->URL); 10233 URI = xmlBuildURI(location, ctxtNode->doc->URL);
10234 } else { 10234 } else {
10235 URI = xmlBuildURI(location, base); 10235 URI = xmlBuildURI(location, base);
10236 xmlFree(base); 10236 xmlFree(base);
10237 } 10237 }
10238 if (URI != NULL) { 10238 if (URI != NULL) {
10239 ret = xmlDictLookup(dict, URI, -1); 10239 ret = xmlDictLookup(dict, URI, -1);
10240 xmlFree(URI); 10240 xmlFree(URI);
10241 return(ret); 10241 return(ret);
10242 } 10242 }
10243 } 10243 }
10244 } 10244 }
10245 return(NULL); 10245 return(NULL);
10246 } 10246 }
10247 10247
10248 10248
10249 10249
10250 /** 10250 /**
10251 * xmlSchemaAddSchemaDoc: 10251 * xmlSchemaAddSchemaDoc:
10252 * @pctxt: a schema validation context 10252 * @pctxt: a schema validation context
10253 * @schema: the schema being built 10253 * @schema: the schema being built
10254 * @node: a subtree containing XML Schema informations 10254 * @node: a subtree containing XML Schema informations
10255 * 10255 *
10256 * Parse an included (and to-be-redefined) XML schema document. 10256 * Parse an included (and to-be-redefined) XML schema document.
10257 * 10257 *
10258 * Returns 0 on success, a positive error code on errors and 10258 * Returns 0 on success, a positive error code on errors and
10259 * -1 in case of an internal or API error. 10259 * -1 in case of an internal or API error.
10260 */ 10260 */
10261 10261
10262 static int 10262 static int
10263 xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt, 10263 xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
10264 int type, /* import or include or redefine */ 10264 int type, /* import or include or redefine */
10265 const xmlChar *schemaLocation, 10265 const xmlChar *schemaLocation,
10266 xmlDocPtr schemaDoc, 10266 xmlDocPtr schemaDoc,
10267 const char *schemaBuffer, 10267 const char *schemaBuffer,
10268 int schemaBufferLen, 10268 int schemaBufferLen,
10269 xmlNodePtr invokingNode, 10269 xmlNodePtr invokingNode,
10270 » » const xmlChar *sourceTargetNamespace,» » 10270 » » const xmlChar *sourceTargetNamespace,
10271 » » const xmlChar *importNamespace,» 10271 » » const xmlChar *importNamespace,
10272 xmlSchemaBucketPtr *bucket) 10272 xmlSchemaBucketPtr *bucket)
10273 { 10273 {
10274 const xmlChar *targetNamespace = NULL; 10274 const xmlChar *targetNamespace = NULL;
10275 xmlSchemaSchemaRelationPtr relation = NULL; 10275 xmlSchemaSchemaRelationPtr relation = NULL;
10276 xmlDocPtr doc = NULL; 10276 xmlDocPtr doc = NULL;
10277 int res = 0, err = 0, located = 0, preserveDoc = 0; 10277 int res = 0, err = 0, located = 0, preserveDoc = 0;
10278 xmlSchemaBucketPtr bkt = NULL; 10278 xmlSchemaBucketPtr bkt = NULL;
10279 10279
10280 if (bucket != NULL) 10280 if (bucket != NULL)
10281 *bucket = NULL; 10281 *bucket = NULL;
10282 10282
10283 switch (type) { 10283 switch (type) {
10284 case XML_SCHEMA_SCHEMA_IMPORT: 10284 case XML_SCHEMA_SCHEMA_IMPORT:
10285 case XML_SCHEMA_SCHEMA_MAIN: 10285 case XML_SCHEMA_SCHEMA_MAIN:
10286 err = XML_SCHEMAP_SRC_IMPORT; 10286 err = XML_SCHEMAP_SRC_IMPORT;
10287 break; 10287 break;
10288 case XML_SCHEMA_SCHEMA_INCLUDE: 10288 case XML_SCHEMA_SCHEMA_INCLUDE:
10289 err = XML_SCHEMAP_SRC_INCLUDE; 10289 err = XML_SCHEMAP_SRC_INCLUDE;
10290 break; 10290 break;
10291 case XML_SCHEMA_SCHEMA_REDEFINE: 10291 case XML_SCHEMA_SCHEMA_REDEFINE:
10292 err = XML_SCHEMAP_SRC_REDEFINE; 10292 err = XML_SCHEMAP_SRC_REDEFINE;
10293 break; 10293 break;
10294 } 10294 }
10295 10295
10296 10296
10297 /* Special handling for the main schema: 10297 /* Special handling for the main schema:
10298 * skip the location and relation logic and just parse the doc. 10298 * skip the location and relation logic and just parse the doc.
10299 * We need just a bucket to be returned in this case. 10299 * We need just a bucket to be returned in this case.
10300 */ 10300 */
10301 if ((type == XML_SCHEMA_SCHEMA_MAIN) || (! WXS_HAS_BUCKETS(pctxt))) 10301 if ((type == XML_SCHEMA_SCHEMA_MAIN) || (! WXS_HAS_BUCKETS(pctxt)))
10302 » goto doc_load;» 10302 » goto doc_load;
10303 10303
10304 /* Note that we expect the location to be an absulute URI. */ 10304 /* Note that we expect the location to be an absulute URI. */
10305 if (schemaLocation != NULL) { 10305 if (schemaLocation != NULL) {
10306 bkt = xmlSchemaGetSchemaBucket(pctxt, schemaLocation); 10306 bkt = xmlSchemaGetSchemaBucket(pctxt, schemaLocation);
10307 if ((bkt != NULL) && 10307 if ((bkt != NULL) &&
10308 (pctxt->constructor->bucket == bkt)) { 10308 (pctxt->constructor->bucket == bkt)) {
10309 /* Report self-imports/inclusions/redefinitions. */ 10309 /* Report self-imports/inclusions/redefinitions. */
10310 » 10310
10311 xmlSchemaCustomErr(ACTXT_CAST pctxt, err, 10311 xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
10312 invokingNode, NULL, 10312 invokingNode, NULL,
10313 "The schema must not import/include/redefine itself", 10313 "The schema must not import/include/redefine itself",
10314 NULL, NULL); 10314 NULL, NULL);
10315 goto exit; 10315 goto exit;
10316 } 10316 }
10317 } 10317 }
10318 /* 10318 /*
10319 * Create a relation for the graph of schemas. 10319 * Create a relation for the graph of schemas.
10320 */ 10320 */
10321 relation = xmlSchemaSchemaRelationCreate(); 10321 relation = xmlSchemaSchemaRelationCreate();
10322 if (relation == NULL) 10322 if (relation == NULL)
10323 » return(-1); 10323 » return(-1);
10324 xmlSchemaSchemaRelationAddChild(pctxt->constructor->bucket, 10324 xmlSchemaSchemaRelationAddChild(pctxt->constructor->bucket,
10325 relation); 10325 relation);
10326 relation->type = type; 10326 relation->type = type;
10327 10327
10328 /* 10328 /*
10329 * Save the namespace import information. 10329 * Save the namespace import information.
10330 */ 10330 */
10331 if (WXS_IS_BUCKET_IMPMAIN(type)) { 10331 if (WXS_IS_BUCKET_IMPMAIN(type)) {
10332 » relation->importNamespace = importNamespace;» 10332 » relation->importNamespace = importNamespace;
10333 if (schemaLocation == NULL) { 10333 if (schemaLocation == NULL) {
10334 /* 10334 /*
10335 * No location; this is just an import of the namespace. 10335 * No location; this is just an import of the namespace.
10336 * Note that we don't assign a bucket to the relation 10336 * Note that we don't assign a bucket to the relation
10337 * in this case. 10337 * in this case.
10338 */ 10338 */
10339 goto exit; 10339 goto exit;
10340 } 10340 }
10341 targetNamespace = importNamespace; 10341 targetNamespace = importNamespace;
10342 } 10342 }
10343 10343
10344 /* Did we already fetch the doc? */ 10344 /* Did we already fetch the doc? */
10345 if (bkt != NULL) {» » 10345 if (bkt != NULL) {
10346 » /* TODO: The following nasty cases will produce an error. */
10347 if ((WXS_IS_BUCKET_IMPMAIN(type)) && (! bkt->imported)) { 10346 if ((WXS_IS_BUCKET_IMPMAIN(type)) && (! bkt->imported)) {
10348 » /* We included/redefined and then try to import a schema. */ 10347 » /*
10348 » * We included/redefined and then try to import a schema,
10349 » * but the new location provided for import was different.
10350 » */
10349 if (schemaLocation == NULL) 10351 if (schemaLocation == NULL)
10350 schemaLocation = BAD_CAST "in_memory_buffer"; 10352 schemaLocation = BAD_CAST "in_memory_buffer";
10351 » xmlSchemaCustomErr(ACTXT_CAST pctxt, err, 10353 » if (!xmlStrEqual(schemaLocation,
10352 » » invokingNode, NULL, 10354 » » bkt->schemaLocation)) {
10353 » » "The schema document '%s' cannot be imported, since " 10355 » » xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
10354 » » "it was already included or redefined", 10356 » » invokingNode, NULL,
10355 » » schemaLocation, NULL); 10357 » » "The schema document '%s' cannot be imported, since "
10356 » goto exit; 10358 » » "it was already included or redefined",
10359 » » schemaLocation, NULL);
10360 » » goto exit;
10361 » }
10357 } else if ((! WXS_IS_BUCKET_IMPMAIN(type)) && (bkt->imported)) { 10362 } else if ((! WXS_IS_BUCKET_IMPMAIN(type)) && (bkt->imported)) {
10358 » /* We imported and then try to include/redefine a schema. */ 10363 » /*
10364 » * We imported and then try to include/redefine a schema,
10365 » * but the new location provided for the include/redefine
10366 » * was different.
10367 » */
10359 if (schemaLocation == NULL) 10368 if (schemaLocation == NULL)
10360 schemaLocation = BAD_CAST "in_memory_buffer"; 10369 schemaLocation = BAD_CAST "in_memory_buffer";
10361 » xmlSchemaCustomErr(ACTXT_CAST pctxt, err, 10370 » if (!xmlStrEqual(schemaLocation,
10362 » » invokingNode, NULL, 10371 » » bkt->schemaLocation)) {
10363 » » "The schema document '%s' cannot be included or " 10372 » » xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
10364 » » "redefined, since it was already imported", 10373 » » invokingNode, NULL,
10365 » » schemaLocation, NULL); 10374 » » "The schema document '%s' cannot be included or "
10366 » goto exit; 10375 » » "redefined, since it was already imported",
10367 » }» 10376 » » schemaLocation, NULL);
10377 » » goto exit;
10378 » }
10379 » }
10368 } 10380 }
10369 » 10381
10370 if (WXS_IS_BUCKET_IMPMAIN(type)) { 10382 if (WXS_IS_BUCKET_IMPMAIN(type)) {
10371 /* 10383 /*
10372 * Given that the schemaLocation [attribute] is only a hint, it is open 10384 * Given that the schemaLocation [attribute] is only a hint, it is open
10373 * to applications to ignore all but the first <import> for a given 10385 * to applications to ignore all but the first <import> for a given
10374 » * namespace, regardless of the ·actual value· of schemaLocation, but 10386 » * namespace, regardless of the �actual value� of schemaLocation, but
10375 * such a strategy risks missing useful information when new 10387 * such a strategy risks missing useful information when new
10376 * schemaLocations are offered. 10388 * schemaLocations are offered.
10377 * 10389 *
10378 * We will use the first <import> that comes with a location. 10390 * We will use the first <import> that comes with a location.
10379 * Further <import>s *with* a location, will result in an error. 10391 * Further <import>s *with* a location, will result in an error.
10380 * TODO: Better would be to just report a warning here, but 10392 * TODO: Better would be to just report a warning here, but
10381 * we'll try it this way until someone complains. 10393 * we'll try it this way until someone complains.
10382 * 10394 *
10383 * Schema Document Location Strategy: 10395 * Schema Document Location Strategy:
10384 * 3 Based on the namespace name, identify an existing schema document, 10396 * 3 Based on the namespace name, identify an existing schema document,
10385 * either as a resource which is an XML document or a <schema> element 10397 * either as a resource which is an XML document or a <schema> element
10386 * information item, in some local schema repository; 10398 * information item, in some local schema repository;
10387 * 5 Attempt to resolve the namespace name to locate such a resource. 10399 * 5 Attempt to resolve the namespace name to locate such a resource.
10388 * 10400 *
10389 * NOTE: (3) and (5) are not supported. 10401 * NOTE: (3) and (5) are not supported.
10390 » */» 10402 » */
10391 if (bkt != NULL) { 10403 if (bkt != NULL) {
10392 relation->bucket = bkt; 10404 relation->bucket = bkt;
10393 goto exit; 10405 goto exit;
10394 } 10406 }
10395 bkt = xmlSchemaGetSchemaBucketByTNS(pctxt, 10407 bkt = xmlSchemaGetSchemaBucketByTNS(pctxt,
10396 importNamespace, 1); 10408 importNamespace, 1);
10397 10409
10398 » if (bkt != NULL) {» 10410 » if (bkt != NULL) {
10399 relation->bucket = bkt; 10411 relation->bucket = bkt;
10400 if (bkt->schemaLocation == NULL) { 10412 if (bkt->schemaLocation == NULL) {
10401 /* First given location of the schema; load the doc. */ 10413 /* First given location of the schema; load the doc. */
10402 bkt->schemaLocation = schemaLocation; 10414 bkt->schemaLocation = schemaLocation;
10403 } else { 10415 } else {
10404 if (!xmlStrEqual(schemaLocation, 10416 if (!xmlStrEqual(schemaLocation,
10405 bkt->schemaLocation)) { 10417 bkt->schemaLocation)) {
10406 /* 10418 /*
10407 * Additional location given; just skip it. 10419 * Additional location given; just skip it.
10408 * URGENT TODO: We should report a warning here. 10420 * URGENT TODO: We should report a warning here.
10409 * res = XML_SCHEMAP_SRC_IMPORT; 10421 * res = XML_SCHEMAP_SRC_IMPORT;
10410 */ 10422 */
10411 if (schemaLocation == NULL) 10423 if (schemaLocation == NULL)
10412 schemaLocation = BAD_CAST "in_memory_buffer"; 10424 schemaLocation = BAD_CAST "in_memory_buffer";
10413 10425
10414 xmlSchemaCustomWarning(ACTXT_CAST pctxt, 10426 xmlSchemaCustomWarning(ACTXT_CAST pctxt,
10415 XML_SCHEMAP_WARN_SKIP_SCHEMA, 10427 XML_SCHEMAP_WARN_SKIP_SCHEMA,
10416 invokingNode, NULL, 10428 invokingNode, NULL,
10417 "Skipping import of schema located at '%s' for the " 10429 "Skipping import of schema located at '%s' for the "
10418 "namespace '%s', since this namespace was already " 10430 "namespace '%s', since this namespace was already "
10419 "imported with the schema located at '%s'", 10431 "imported with the schema located at '%s'",
10420 schemaLocation, importNamespace, bkt->schemaLocation); 10432 schemaLocation, importNamespace, bkt->schemaLocation);
10421 } 10433 }
10422 goto exit; 10434 goto exit;
10423 } 10435 }
10424 » }» 10436 » }
10425 » /* 10437 » /*
10426 * No bucket + first location: load the doc and create a 10438 * No bucket + first location: load the doc and create a
10427 * bucket. 10439 * bucket.
10428 */ 10440 */
10429 } else { 10441 } else {
10430 /* <include> and <redefine> */ 10442 /* <include> and <redefine> */
10431 if (bkt != NULL) { 10443 if (bkt != NULL) {
10432 » » 10444
10433 if ((bkt->origTargetNamespace == NULL) && 10445 if ((bkt->origTargetNamespace == NULL) &&
10434 (bkt->targetNamespace != sourceTargetNamespace)) { 10446 (bkt->targetNamespace != sourceTargetNamespace)) {
10435 xmlSchemaBucketPtr chamel; 10447 xmlSchemaBucketPtr chamel;
10436 » » 10448
10437 /* 10449 /*
10438 * Chameleon include/redefine: skip loading only if it was 10450 * Chameleon include/redefine: skip loading only if it was
10439 * aleady build for the targetNamespace of the including 10451 * aleady build for the targetNamespace of the including
10440 * schema. 10452 * schema.
10441 */ 10453 */
10442 /* 10454 /*
10443 * URGENT TODO: If the schema is a chameleon-include then copy 10455 * URGENT TODO: If the schema is a chameleon-include then copy
10444 * the components into the including schema and modify the 10456 * the components into the including schema and modify the
10445 * targetNamespace of those components, do nothing otherwise. 10457 * targetNamespace of those components, do nothing otherwise.
10446 * NOTE: This is currently worked-around by compiling the 10458 * NOTE: This is currently worked-around by compiling the
10447 * chameleon for every destinct including targetNamespace; thus 10459 * chameleon for every destinct including targetNamespace; thus
10448 * not performant at the moment. 10460 * not performant at the moment.
10449 * TODO: Check when the namespace in wildcards for chameleons 10461 * TODO: Check when the namespace in wildcards for chameleons
10450 * needs to be converted: before we built wildcard intersections 10462 * needs to be converted: before we built wildcard intersections
10451 * or after. 10463 * or after.
10452 * Answer: after! 10464 * Answer: after!
10453 */ 10465 */
10454 chamel = xmlSchemaGetChameleonSchemaBucket(pctxt, 10466 chamel = xmlSchemaGetChameleonSchemaBucket(pctxt,
10455 schemaLocation, sourceTargetNamespace); 10467 schemaLocation, sourceTargetNamespace);
10456 if (chamel != NULL) { 10468 if (chamel != NULL) {
10457 /* A fitting chameleon was already parsed; NOP. */ 10469 /* A fitting chameleon was already parsed; NOP. */
10458 relation->bucket = chamel; 10470 relation->bucket = chamel;
10459 goto exit; 10471 goto exit;
10460 } 10472 }
10461 » » /* 10473 » » /*
10462 * We need to parse the chameleon again for a different 10474 * We need to parse the chameleon again for a different
10463 * targetNamespace. 10475 * targetNamespace.
10464 * CHAMELEON TODO: Optimize this by only parsing the 10476 * CHAMELEON TODO: Optimize this by only parsing the
10465 * chameleon once, and then copying the components to 10477 * chameleon once, and then copying the components to
10466 * the new targetNamespace. 10478 * the new targetNamespace.
10467 */ 10479 */
10468 bkt = NULL; 10480 bkt = NULL;
10469 } else { 10481 } else {
10470 relation->bucket = bkt; 10482 relation->bucket = bkt;
10471 goto exit; 10483 goto exit;
10472 » }» 10484 » }
10473 } 10485 }
10474 } 10486 }
10475 if ((bkt != NULL) && (bkt->doc != NULL)) { 10487 if ((bkt != NULL) && (bkt->doc != NULL)) {
10476 PERROR_INT("xmlSchemaAddSchemaDoc", 10488 PERROR_INT("xmlSchemaAddSchemaDoc",
10477 "trying to load a schema doc, but a doc is already " 10489 "trying to load a schema doc, but a doc is already "
10478 "assigned to the schema bucket"); 10490 "assigned to the schema bucket");
10479 goto exit_failure; 10491 goto exit_failure;
10480 } 10492 }
10481 10493
10482 doc_load: 10494 doc_load:
(...skipping 29 matching lines...) Expand all
10512 xmlDictReference(parserCtxt->dict); 10524 xmlDictReference(parserCtxt->dict);
10513 } 10525 }
10514 if (schemaLocation != NULL) { 10526 if (schemaLocation != NULL) {
10515 /* Parse from file. */ 10527 /* Parse from file. */
10516 doc = xmlCtxtReadFile(parserCtxt, (const char *) schemaLocation, 10528 doc = xmlCtxtReadFile(parserCtxt, (const char *) schemaLocation,
10517 NULL, SCHEMAS_PARSE_OPTIONS); 10529 NULL, SCHEMAS_PARSE_OPTIONS);
10518 } else if (schemaBuffer != NULL) { 10530 } else if (schemaBuffer != NULL) {
10519 /* Parse from memory buffer. */ 10531 /* Parse from memory buffer. */
10520 doc = xmlCtxtReadMemory(parserCtxt, schemaBuffer, schemaBufferLen, 10532 doc = xmlCtxtReadMemory(parserCtxt, schemaBuffer, schemaBufferLen,
10521 NULL, NULL, SCHEMAS_PARSE_OPTIONS); 10533 NULL, NULL, SCHEMAS_PARSE_OPTIONS);
10522 » schemaLocation = xmlStrdup(BAD_CAST "in_memory_buffer"); 10534 » schemaLocation = BAD_CAST "in_memory_buffer";
10523 if (doc != NULL) 10535 if (doc != NULL)
10524 » » doc->URL = schemaLocation;» 10536 » » doc->URL = xmlStrdup(schemaLocation);
10525 } 10537 }
10526 /* 10538 /*
10527 * For <import>: 10539 * For <import>:
10528 * 2.1 The referent is (a fragment of) a resource which is an 10540 * 2.1 The referent is (a fragment of) a resource which is an
10529 * XML document (see clause 1.1), which in turn corresponds to 10541 * XML document (see clause 1.1), which in turn corresponds to
10530 * a <schema> element information item in a well-formed information 10542 * a <schema> element information item in a well-formed information
10531 * set, which in turn corresponds to a valid schema. 10543 * set, which in turn corresponds to a valid schema.
10532 * TODO: (2.1) fragments of XML documents are not supported. 10544 * TODO: (2.1) fragments of XML documents are not supported.
10533 * 10545 *
10534 * 2.2 The referent is a <schema> element information item in 10546 * 2.2 The referent is a <schema> element information item in
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
10568 "given schema parser context.\n", 10580 "given schema parser context.\n",
10569 NULL, NULL); 10581 NULL, NULL);
10570 goto exit_failure; 10582 goto exit_failure;
10571 } 10583 }
10572 /* 10584 /*
10573 * Preprocess the document. 10585 * Preprocess the document.
10574 */ 10586 */
10575 if (doc != NULL) { 10587 if (doc != NULL) {
10576 xmlNodePtr docElem = NULL; 10588 xmlNodePtr docElem = NULL;
10577 10589
10578 » located = 1;» 10590 » located = 1;
10579 docElem = xmlDocGetRootElement(doc); 10591 docElem = xmlDocGetRootElement(doc);
10580 if (docElem == NULL) { 10592 if (docElem == NULL) {
10581 xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_NOROOT, 10593 xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_NOROOT,
10582 » » invokingNode, NULL, 10594 » » invokingNode, NULL,
10583 "The document '%s' has no document element", 10595 "The document '%s' has no document element",
10584 schemaLocation, NULL); 10596 schemaLocation, NULL);
10585 goto exit_error; 10597 goto exit_error;
10586 } 10598 }
10587 /* 10599 /*
10588 * Remove all the blank text nodes. 10600 * Remove all the blank text nodes.
10589 */ 10601 */
10590 xmlSchemaCleanupDoc(pctxt, docElem); 10602 xmlSchemaCleanupDoc(pctxt, docElem);
10591 /* 10603 /*
10592 * Check the schema's top level element. 10604 * Check the schema's top level element.
10593 */ 10605 */
10594 if (!IS_SCHEMA(docElem, "schema")) { 10606 if (!IS_SCHEMA(docElem, "schema")) {
10595 xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_NOT_SCHEMA, 10607 xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_NOT_SCHEMA,
10596 invokingNode, NULL, 10608 invokingNode, NULL,
10597 "The XML document '%s' is not a schema document", 10609 "The XML document '%s' is not a schema document",
10598 schemaLocation, NULL); 10610 schemaLocation, NULL);
10599 goto exit_error; 10611 goto exit_error;
10600 } 10612 }
10601 » /* 10613 » /*
10602 * Note that we don't apply a type check for the 10614 * Note that we don't apply a type check for the
10603 * targetNamespace value here. 10615 * targetNamespace value here.
10604 */ 10616 */
10605 targetNamespace = xmlSchemaGetProp(pctxt, docElem, 10617 targetNamespace = xmlSchemaGetProp(pctxt, docElem,
10606 "targetNamespace"); 10618 "targetNamespace");
10607 } 10619 }
10608 10620
10609 /* after_doc_loading: */ 10621 /* after_doc_loading: */
10610 if ((bkt == NULL) && located) { 10622 if ((bkt == NULL) && located) {
10611 /* Only create a bucket if the schema was located. */ 10623 /* Only create a bucket if the schema was located. */
10612 bkt = xmlSchemaBucketCreate(pctxt, type, 10624 bkt = xmlSchemaBucketCreate(pctxt, type,
10613 targetNamespace); 10625 targetNamespace);
10614 if (bkt == NULL) 10626 if (bkt == NULL)
10615 goto exit_failure; 10627 goto exit_failure;
10616 } 10628 }
10617 if (bkt != NULL) { 10629 if (bkt != NULL) {
10618 bkt->schemaLocation = schemaLocation; 10630 bkt->schemaLocation = schemaLocation;
10619 bkt->located = located; 10631 bkt->located = located;
10620 if (doc != NULL) { 10632 if (doc != NULL) {
10621 bkt->doc = doc; 10633 bkt->doc = doc;
10622 bkt->targetNamespace = targetNamespace; 10634 bkt->targetNamespace = targetNamespace;
10623 bkt->origTargetNamespace = targetNamespace; 10635 bkt->origTargetNamespace = targetNamespace;
10624 if (preserveDoc) 10636 if (preserveDoc)
10625 bkt->preserveDoc = 1; 10637 bkt->preserveDoc = 1;
10626 } 10638 }
10627 if (WXS_IS_BUCKET_IMPMAIN(type)) 10639 if (WXS_IS_BUCKET_IMPMAIN(type))
10628 bkt->imported++; 10640 bkt->imported++;
10629 /* 10641 /*
10630 * Add it to the graph of schemas. 10642 * Add it to the graph of schemas.
10631 */ 10643 */
10632 if (relation != NULL) 10644 if (relation != NULL)
10633 relation->bucket = bkt; 10645 relation->bucket = bkt;
10634 } 10646 }
10635 10647
10636 exit: 10648 exit:
10637 /* 10649 /*
10638 * Return the bucket explicitely; this is needed for the 10650 * Return the bucket explicitely; this is needed for the
10639 * main schema. 10651 * main schema.
10640 */ 10652 */
10641 if (bucket != NULL) 10653 if (bucket != NULL)
10642 » *bucket = bkt; 10654 » *bucket = bkt;
10643 return (0); 10655 return (0);
10644 10656
10645 exit_error: 10657 exit_error:
10646 if ((doc != NULL) && (! preserveDoc)) { 10658 if ((doc != NULL) && (! preserveDoc)) {
10647 xmlFreeDoc(doc); 10659 xmlFreeDoc(doc);
10648 if (bkt != NULL) 10660 if (bkt != NULL)
10649 bkt->doc = NULL; 10661 bkt->doc = NULL;
10650 } 10662 }
10651 return(pctxt->err); 10663 return(pctxt->err);
10652 10664
10653 exit_failure: 10665 exit_failure:
10654 if ((doc != NULL) && (! preserveDoc)) { 10666 if ((doc != NULL) && (! preserveDoc)) {
10655 xmlFreeDoc(doc); 10667 xmlFreeDoc(doc);
10656 if (bkt != NULL) 10668 if (bkt != NULL)
10657 bkt->doc = NULL; 10669 bkt->doc = NULL;
10658 } 10670 }
10659 return (-1); 10671 return (-1);
10660 } 10672 }
10661 10673
10662 /** 10674 /**
10663 * xmlSchemaParseImport: 10675 * xmlSchemaParseImport:
10664 * @ctxt: a schema validation context 10676 * @ctxt: a schema validation context
10665 * @schema: the schema being built 10677 * @schema: the schema being built
10666 * @node: a subtree containing XML Schema informations 10678 * @node: a subtree containing XML Schema informations
10667 * 10679 *
10668 * parse a XML schema Import definition 10680 * parse a XML schema Import definition
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
10748 * Apply additional constraints. 10760 * Apply additional constraints.
10749 * 10761 *
10750 * Note that it is important to use the original @targetNamespace 10762 * Note that it is important to use the original @targetNamespace
10751 * (or none at all), to rule out imports of schemas _with_ a 10763 * (or none at all), to rule out imports of schemas _with_ a
10752 * @targetNamespace if the importing schema is a chameleon schema 10764 * @targetNamespace if the importing schema is a chameleon schema
10753 * (with no @targetNamespace). 10765 * (with no @targetNamespace).
10754 */ 10766 */
10755 thisTargetNamespace = WXS_BUCKET(pctxt)->origTargetNamespace; 10767 thisTargetNamespace = WXS_BUCKET(pctxt)->origTargetNamespace;
10756 if (namespaceName != NULL) { 10768 if (namespaceName != NULL) {
10757 /* 10769 /*
10758 » * 1.1 If the namespace [attribute] is present, then its ·actual value· 10770 » * 1.1 If the namespace [attribute] is present, then its �actual valueï ¿½
10759 » * must not match the ·actual value· of the enclosing <schema>'s 10771 » * must not match the �actual value� of the enclosing <schema>'s
10760 * targetNamespace [attribute]. 10772 * targetNamespace [attribute].
10761 */ 10773 */
10762 if (xmlStrEqual(thisTargetNamespace, namespaceName)) { 10774 if (xmlStrEqual(thisTargetNamespace, namespaceName)) {
10763 xmlSchemaPCustomErr(pctxt, 10775 xmlSchemaPCustomErr(pctxt,
10764 XML_SCHEMAP_SRC_IMPORT_1_1, 10776 XML_SCHEMAP_SRC_IMPORT_1_1,
10765 NULL, node, 10777 NULL, node,
10766 "The value of the attribute 'namespace' must not match " 10778 "The value of the attribute 'namespace' must not match "
10767 "the target namespace '%s' of the importing schema", 10779 "the target namespace '%s' of the importing schema",
10768 thisTargetNamespace); 10780 thisTargetNamespace);
10769 return (pctxt->err); 10781 return (pctxt->err);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
10803 * Note that we will get no bucket if the schema could not be 10815 * Note that we will get no bucket if the schema could not be
10804 * located or if there was no schemaLocation. 10816 * located or if there was no schemaLocation.
10805 */ 10817 */
10806 if ((bucket == NULL) && (schemaLocation != NULL)) { 10818 if ((bucket == NULL) && (schemaLocation != NULL)) {
10807 xmlSchemaCustomWarning(ACTXT_CAST pctxt, 10819 xmlSchemaCustomWarning(ACTXT_CAST pctxt,
10808 XML_SCHEMAP_WARN_UNLOCATED_SCHEMA, 10820 XML_SCHEMAP_WARN_UNLOCATED_SCHEMA,
10809 node, NULL, 10821 node, NULL,
10810 "Failed to locate a schema at location '%s'. " 10822 "Failed to locate a schema at location '%s'. "
10811 "Skipping the import", schemaLocation, NULL, NULL); 10823 "Skipping the import", schemaLocation, NULL, NULL);
10812 } 10824 }
10813 10825
10814 if ((bucket != NULL) && CAN_PARSE_SCHEMA(bucket)) {» 10826 if ((bucket != NULL) && CAN_PARSE_SCHEMA(bucket)) {
10815 ret = xmlSchemaParseNewDoc(pctxt, schema, bucket); 10827 ret = xmlSchemaParseNewDoc(pctxt, schema, bucket);
10816 } 10828 }
10817 10829
10818 return (ret); 10830 return (ret);
10819 } 10831 }
10820 10832
10821 static int 10833 static int
10822 xmlSchemaParseIncludeOrRedefineAttrs(xmlSchemaParserCtxtPtr pctxt, 10834 xmlSchemaParseIncludeOrRedefineAttrs(xmlSchemaParserCtxtPtr pctxt,
10823 xmlSchemaPtr schema, 10835 xmlSchemaPtr schema,
10824 xmlNodePtr node, 10836 xmlNodePtr node,
10825 xmlChar **schemaLocation, 10837 xmlChar **schemaLocation,
10826 int type) 10838 int type)
10827 { 10839 {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
10889 } 10901 }
10890 /* 10902 /*
10891 * Report self-inclusion and self-redefinition. 10903 * Report self-inclusion and self-redefinition.
10892 */ 10904 */
10893 if (xmlStrEqual(*schemaLocation, pctxt->URL)) { 10905 if (xmlStrEqual(*schemaLocation, pctxt->URL)) {
10894 if (type == XML_SCHEMA_SCHEMA_REDEFINE) { 10906 if (type == XML_SCHEMA_SCHEMA_REDEFINE) {
10895 xmlSchemaPCustomErr(pctxt, 10907 xmlSchemaPCustomErr(pctxt,
10896 XML_SCHEMAP_SRC_REDEFINE, 10908 XML_SCHEMAP_SRC_REDEFINE,
10897 NULL, node, 10909 NULL, node,
10898 "The schema document '%s' cannot redefine itself.", 10910 "The schema document '%s' cannot redefine itself.",
10899 » » *schemaLocation);» 10911 » » *schemaLocation);
10900 } else { 10912 } else {
10901 xmlSchemaPCustomErr(pctxt, 10913 xmlSchemaPCustomErr(pctxt,
10902 XML_SCHEMAP_SRC_INCLUDE, 10914 XML_SCHEMAP_SRC_INCLUDE,
10903 NULL, node, 10915 NULL, node,
10904 "The schema document '%s' cannot include itself.", 10916 "The schema document '%s' cannot include itself.",
10905 *schemaLocation); 10917 *schemaLocation);
10906 } 10918 }
10907 goto exit_error; 10919 goto exit_error;
10908 } 10920 }
10909 10921
10910 return(0); 10922 return(0);
10911 exit_error: 10923 exit_error:
10912 return(pctxt->err); 10924 return(pctxt->err);
10913 exit_failure: 10925 exit_failure:
10914 return(-1); 10926 return(-1);
10915 } 10927 }
10916 10928
10917 static int 10929 static int
10918 xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt, 10930 xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
10919 xmlSchemaPtr schema, 10931 xmlSchemaPtr schema,
10920 xmlNodePtr node, 10932 xmlNodePtr node,
10921 int type) 10933 int type)
10922 { 10934 {
10923 xmlNodePtr child = NULL; 10935 xmlNodePtr child = NULL;
10924 const xmlChar *schemaLocation = NULL; 10936 const xmlChar *schemaLocation = NULL;
10925 int res = 0; /* hasRedefinitions = 0 */ 10937 int res = 0; /* hasRedefinitions = 0 */
10926 int isChameleon = 0, wasChameleon = 0; 10938 int isChameleon = 0, wasChameleon = 0;
10927 xmlSchemaBucketPtr bucket = NULL; 10939 xmlSchemaBucketPtr bucket = NULL;
10928 10940
10929 if ((pctxt == NULL) || (schema == NULL) || (node == NULL)) 10941 if ((pctxt == NULL) || (schema == NULL) || (node == NULL))
10930 return (-1); 10942 return (-1);
10931 10943
10932 /* 10944 /*
10933 * Parse attributes. Note that the returned schemaLocation will 10945 * Parse attributes. Note that the returned schemaLocation will
10934 * be already converted to an absolute URI. 10946 * be already converted to an absolute URI.
10935 */ 10947 */
10936 res = xmlSchemaParseIncludeOrRedefineAttrs(pctxt, schema, 10948 res = xmlSchemaParseIncludeOrRedefineAttrs(pctxt, schema,
10937 node, (xmlChar **) (&schemaLocation), type); 10949 node, (xmlChar **) (&schemaLocation), type);
10938 if (res != 0) 10950 if (res != 0)
10939 » return(res); » 10951 » return(res);
10940 /* 10952 /*
10941 * Load and add the schema document. 10953 * Load and add the schema document.
10942 */ 10954 */
10943 res = xmlSchemaAddSchemaDoc(pctxt, type, schemaLocation, NULL, 10955 res = xmlSchemaAddSchemaDoc(pctxt, type, schemaLocation, NULL,
10944 NULL, 0, node, pctxt->targetNamespace, NULL, &bucket); 10956 NULL, 0, node, pctxt->targetNamespace, NULL, &bucket);
10945 if (res != 0) 10957 if (res != 0)
10946 » return(res); 10958 » return(res);
10947 /* 10959 /*
10948 * If we get no schema bucket back, then this means that the schema 10960 * If we get no schema bucket back, then this means that the schema
10949 * document could not be located or was broken XML or was not 10961 * document could not be located or was broken XML or was not
10950 * a schema document. 10962 * a schema document.
10951 */ 10963 */
10952 if ((bucket == NULL) || (bucket->doc == NULL)) { 10964 if ((bucket == NULL) || (bucket->doc == NULL)) {
10953 if (type == XML_SCHEMA_SCHEMA_INCLUDE) { 10965 if (type == XML_SCHEMA_SCHEMA_INCLUDE) {
10954 /* 10966 /*
10955 * WARNING for <include>: 10967 * WARNING for <include>:
10956 * We will raise an error if the schema cannot be located 10968 * We will raise an error if the schema cannot be located
10957 * for inclusions, since the that was the feedback from the 10969 * for inclusions, since the that was the feedback from the
10958 * schema people. I.e. the following spec piece will *not* be 10970 * schema people. I.e. the following spec piece will *not* be
10959 * satisfied: 10971 * satisfied:
10960 » * SPEC src-include: "It is not an error for the ·actual value· of th e 10972 » * SPEC src-include: "It is not an error for the �actual value� o f the
10961 * schemaLocation [attribute] to fail to resolve it all, in which 10973 * schemaLocation [attribute] to fail to resolve it all, in which
10962 * case no corresponding inclusion is performed. 10974 * case no corresponding inclusion is performed.
10963 * So do we need a warning report here?" 10975 * So do we need a warning report here?"
10964 */ 10976 */
10965 res = XML_SCHEMAP_SRC_INCLUDE; 10977 res = XML_SCHEMAP_SRC_INCLUDE;
10966 xmlSchemaCustomErr(ACTXT_CAST pctxt, res, 10978 xmlSchemaCustomErr(ACTXT_CAST pctxt, res,
10967 node, NULL, 10979 node, NULL,
10968 "Failed to load the document '%s' for inclusion", 10980 "Failed to load the document '%s' for inclusion",
10969 schemaLocation, NULL); 10981 schemaLocation, NULL);
10970 } else { 10982 } else {
10971 /* 10983 /*
10972 * NOTE: This was changed to raise an error even if no redefinitions 10984 * NOTE: This was changed to raise an error even if no redefinitions
10973 * are specified. 10985 * are specified.
10974 * 10986 *
10975 * SPEC src-redefine (1) 10987 * SPEC src-redefine (1)
10976 * "If there are any element information items among the [children] 10988 * "If there are any element information items among the [children]
10977 » * other than <annotation> then the ·actual value· of the 10989 » * other than <annotation> then the �actual value� of the
10978 * schemaLocation [attribute] must successfully resolve." 10990 * schemaLocation [attribute] must successfully resolve."
10979 * TODO: Ask the WG if a the location has always to resolve 10991 * TODO: Ask the WG if a the location has always to resolve
10980 * here as well! 10992 * here as well!
10981 */ 10993 */
10982 res = XML_SCHEMAP_SRC_REDEFINE; 10994 res = XML_SCHEMAP_SRC_REDEFINE;
10983 xmlSchemaCustomErr(ACTXT_CAST pctxt, res, 10995 xmlSchemaCustomErr(ACTXT_CAST pctxt, res,
10984 node, NULL, 10996 node, NULL,
10985 "Failed to load the document '%s' for redefinition", 10997 "Failed to load the document '%s' for redefinition",
10986 schemaLocation, NULL); 10998 schemaLocation, NULL);
10987 } 10999 }
10988 } else { 11000 } else {
10989 /* 11001 /*
10990 * Check targetNamespace sanity before parsing the new schema. 11002 * Check targetNamespace sanity before parsing the new schema.
10991 * TODO: Note that we won't check further content if the 11003 * TODO: Note that we won't check further content if the
10992 * targetNamespace was bad. 11004 * targetNamespace was bad.
10993 » */ 11005 » */
10994 » if (bucket->origTargetNamespace != NULL) {» 11006 » if (bucket->origTargetNamespace != NULL) {
10995 /* 11007 /*
10996 * SPEC src-include (2.1) 11008 * SPEC src-include (2.1)
10997 » * "SII has a targetNamespace [attribute], and its ·actual 11009 » * "SII has a targetNamespace [attribute], and its �actual
10998 » * value· is identical to the ·actual value· of the targetNamespace 11010 » * value� is identical to the �actual value� of the targetNames pace
10999 » * [attribute] of SIIÂ’ (which must have such an [attribute])." 11011 » * [attribute] of SII� (which must have such an [attribute])."
11000 */ 11012 */
11001 if (pctxt->targetNamespace == NULL) { 11013 if (pctxt->targetNamespace == NULL) {
11002 xmlSchemaCustomErr(ACTXT_CAST pctxt, 11014 xmlSchemaCustomErr(ACTXT_CAST pctxt,
11003 XML_SCHEMAP_SRC_INCLUDE, 11015 XML_SCHEMAP_SRC_INCLUDE,
11004 node, NULL, 11016 node, NULL,
11005 "The target namespace of the included/redefined schema " 11017 "The target namespace of the included/redefined schema "
11006 "'%s' has to be absent, since the including/redefining " 11018 "'%s' has to be absent, since the including/redefining "
11007 "schema has no target namespace", 11019 "schema has no target namespace",
11008 schemaLocation, NULL); 11020 schemaLocation, NULL);
11009 goto exit_error; 11021 goto exit_error;
11010 } else if (!xmlStrEqual(bucket->origTargetNamespace, 11022 } else if (!xmlStrEqual(bucket->origTargetNamespace,
11011 pctxt->targetNamespace)) { 11023 pctxt->targetNamespace)) {
11012 /* TODO: Change error function. */ 11024 /* TODO: Change error function. */
11013 xmlSchemaPCustomErrExt(pctxt, 11025 xmlSchemaPCustomErrExt(pctxt,
11014 XML_SCHEMAP_SRC_INCLUDE, 11026 XML_SCHEMAP_SRC_INCLUDE,
11015 NULL, node, 11027 NULL, node,
11016 "The target namespace '%s' of the included/redefined " 11028 "The target namespace '%s' of the included/redefined "
11017 "schema '%s' differs from '%s' of the " 11029 "schema '%s' differs from '%s' of the "
11018 "including/redefining schema", 11030 "including/redefining schema",
11019 bucket->origTargetNamespace, schemaLocation, 11031 bucket->origTargetNamespace, schemaLocation,
11020 pctxt->targetNamespace); 11032 pctxt->targetNamespace);
11021 goto exit_error; 11033 goto exit_error;
11022 } 11034 }
11023 » } else if (pctxt->targetNamespace != NULL) {» 11035 » } else if (pctxt->targetNamespace != NULL) {
11024 /* 11036 /*
11025 * Chameleons: the original target namespace will 11037 * Chameleons: the original target namespace will
11026 * differ from the resulting namespace. 11038 * differ from the resulting namespace.
11027 */ 11039 */
11028 isChameleon = 1; 11040 isChameleon = 1;
11029 if (bucket->parsed && 11041 if (bucket->parsed &&
11030 » » (bucket->targetNamespace != pctxt->targetNamespace)) { 11042 » » bucket->origTargetNamespace != NULL) {
11031 » » /* 11043 » » xmlSchemaCustomErr(ACTXT_CAST pctxt,
11032 » » * This is a sanity check, I dunno yet if this can happen. 11044 » » XML_SCHEMAP_SRC_INCLUDE,
11033 » » */ 11045 » » node, NULL,
11034 » » PERROR_INT("xmlSchemaParseIncludeOrRedefine", 11046 » » "The target namespace of the included/redefined schema "
11035 » » "trying to use an already parsed schema for a " 11047 » » "'%s' has to be absent or the same as the "
11036 » » "different targetNamespace"); 11048 » » "including/redefining schema's target namespace",
11037 » » return(-1); 11049 » » schemaLocation, NULL);
11050 » » goto exit_error;
11038 } 11051 }
11039 bucket->targetNamespace = pctxt->targetNamespace; 11052 bucket->targetNamespace = pctxt->targetNamespace;
11040 } 11053 }
11041 } 11054 }
11042 /* 11055 /*
11043 * Parse the schema. 11056 * Parse the schema.
11044 */ 11057 */
11045 if (bucket && (!bucket->parsed) && (bucket->doc != NULL)) { 11058 if (bucket && (!bucket->parsed) && (bucket->doc != NULL)) {
11046 if (isChameleon) { 11059 if (isChameleon) {
11047 /* TODO: Get rid of this flag on the schema itself. */ 11060 /* TODO: Get rid of this flag on the schema itself. */
11048 if ((schema->flags & XML_SCHEMAS_INCLUDING_CONVERT_NS) == 0) { 11061 if ((schema->flags & XML_SCHEMAS_INCLUDING_CONVERT_NS) == 0) {
11049 schema->flags |= XML_SCHEMAS_INCLUDING_CONVERT_NS; 11062 schema->flags |= XML_SCHEMAS_INCLUDING_CONVERT_NS;
11050 } else 11063 } else
11051 wasChameleon = 1; 11064 wasChameleon = 1;
11052 } 11065 }
11053 xmlSchemaParseNewDoc(pctxt, schema, bucket); 11066 xmlSchemaParseNewDoc(pctxt, schema, bucket);
11054 /* Restore chameleon flag. */ 11067 /* Restore chameleon flag. */
11055 if (isChameleon && (!wasChameleon)) 11068 if (isChameleon && (!wasChameleon))
11056 schema->flags ^= XML_SCHEMAS_INCLUDING_CONVERT_NS; 11069 schema->flags ^= XML_SCHEMAS_INCLUDING_CONVERT_NS;
11057 } 11070 }
11058 /* 11071 /*
11059 * And now for the children... 11072 * And now for the children...
11060 */ 11073 */
11061 child = node->children; 11074 child = node->children;
11062 if (type == XML_SCHEMA_SCHEMA_REDEFINE) {» 11075 if (type == XML_SCHEMA_SCHEMA_REDEFINE) {
11063 /* 11076 /*
11064 * Parse (simpleType | complexType | group | attributeGroup))* 11077 * Parse (simpleType | complexType | group | attributeGroup))*
11065 */ 11078 */
11066 pctxt->redefined = bucket; 11079 pctxt->redefined = bucket;
11067 /* 11080 /*
11068 * How to proceed if the redefined schema was not located? 11081 * How to proceed if the redefined schema was not located?
11069 */ 11082 */
11070 pctxt->isRedefine = 1; 11083 pctxt->isRedefine = 1;
11071 while (IS_SCHEMA(child, "annotation") || 11084 while (IS_SCHEMA(child, "annotation") ||
11072 IS_SCHEMA(child, "simpleType") || 11085 IS_SCHEMA(child, "simpleType") ||
11073 IS_SCHEMA(child, "complexType") || 11086 IS_SCHEMA(child, "complexType") ||
11074 IS_SCHEMA(child, "group") || 11087 IS_SCHEMA(child, "group") ||
11075 IS_SCHEMA(child, "attributeGroup")) { 11088 IS_SCHEMA(child, "attributeGroup")) {
11076 if (IS_SCHEMA(child, "annotation")) { 11089 if (IS_SCHEMA(child, "annotation")) {
11077 /* 11090 /*
11078 * TODO: discard or not? 11091 * TODO: discard or not?
11079 */ 11092 */
11080 } else if (IS_SCHEMA(child, "simpleType")) { 11093 } else if (IS_SCHEMA(child, "simpleType")) {
11081 xmlSchemaParseSimpleType(pctxt, schema, child, 1); 11094 xmlSchemaParseSimpleType(pctxt, schema, child, 1);
11082 } else if (IS_SCHEMA(child, "complexType")) { 11095 } else if (IS_SCHEMA(child, "complexType")) {
11083 xmlSchemaParseComplexType(pctxt, schema, child, 1); 11096 xmlSchemaParseComplexType(pctxt, schema, child, 1);
11084 /* hasRedefinitions = 1; */ 11097 /* hasRedefinitions = 1; */
11085 » } else if (IS_SCHEMA(child, "group")) {» » 11098 » } else if (IS_SCHEMA(child, "group")) {
11086 /* hasRedefinitions = 1; */ 11099 /* hasRedefinitions = 1; */
11087 xmlSchemaParseModelGroupDefinition(pctxt, 11100 xmlSchemaParseModelGroupDefinition(pctxt,
11088 schema, child); 11101 schema, child);
11089 } else if (IS_SCHEMA(child, "attributeGroup")) { 11102 } else if (IS_SCHEMA(child, "attributeGroup")) {
11090 /* hasRedefinitions = 1; */ 11103 /* hasRedefinitions = 1; */
11091 xmlSchemaParseAttributeGroupDefinition(pctxt, schema, 11104 xmlSchemaParseAttributeGroupDefinition(pctxt, schema,
11092 child); 11105 child);
11093 } 11106 }
11094 child = child->next; 11107 child = child->next;
11095 } 11108 }
11096 pctxt->redefined = NULL; 11109 pctxt->redefined = NULL;
11097 pctxt->isRedefine = 0; 11110 pctxt->isRedefine = 0;
11098 } else { 11111 } else {
11099 if (IS_SCHEMA(child, "annotation")) { 11112 if (IS_SCHEMA(child, "annotation")) {
11100 /* 11113 /*
11101 * TODO: discard or not? 11114 * TODO: discard or not?
11102 */ 11115 */
11103 child = child->next; 11116 child = child->next;
11104 } 11117 }
11105 } 11118 }
11106 if (child != NULL) { 11119 if (child != NULL) {
11107 res = XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED; 11120 res = XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED;
11108 if (type == XML_SCHEMA_SCHEMA_REDEFINE) { 11121 if (type == XML_SCHEMA_SCHEMA_REDEFINE) {
11109 xmlSchemaPContentErr(pctxt, res, 11122 xmlSchemaPContentErr(pctxt, res,
11110 NULL, node, child, NULL, 11123 NULL, node, child, NULL,
11111 "(annotation | (simpleType | complexType | group | attributeGrou p))*"); 11124 "(annotation | (simpleType | complexType | group | attributeGrou p))*");
11112 } else { 11125 } else {
11113 xmlSchemaPContentErr(pctxt, res, 11126 xmlSchemaPContentErr(pctxt, res,
11114 NULL, node, child, NULL, 11127 NULL, node, child, NULL,
11115 "(annotation?)"); 11128 "(annotation?)");
11116 » }» 11129 » }
11117 } 11130 }
11118 return(res); 11131 return(res);
11119 11132
11120 exit_error: 11133 exit_error:
11121 return(pctxt->err); 11134 return(pctxt->err);
11122 } 11135 }
11123 11136
11124 static int 11137 static int
11125 xmlSchemaParseRedefine(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPtr schema, 11138 xmlSchemaParseRedefine(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPtr schema,
11126 xmlNodePtr node) 11139 xmlNodePtr node)
11127 { 11140 {
(...skipping 29 matching lines...) Expand all
11157 * @node: a subtree containing XML Schema informations 11170 * @node: a subtree containing XML Schema informations
11158 * @type: the "compositor" type 11171 * @type: the "compositor" type
11159 * @particleNeeded: if a a model group with a particle 11172 * @particleNeeded: if a a model group with a particle
11160 * 11173 *
11161 * parse a XML schema Sequence definition. 11174 * parse a XML schema Sequence definition.
11162 * Applies parts of: 11175 * Applies parts of:
11163 * Schema Representation Constraint: 11176 * Schema Representation Constraint:
11164 * Redefinition Constraints and Semantics (src-redefine) 11177 * Redefinition Constraints and Semantics (src-redefine)
11165 * (6.1), (6.1.1), (6.1.2) 11178 * (6.1), (6.1.1), (6.1.2)
11166 * 11179 *
11167 * Schema Component Constraint: 11180 * Schema Component Constraint:
11168 * All Group Limited (cos-all-limited) (2) 11181 * All Group Limited (cos-all-limited) (2)
11169 * TODO: Actually this should go to component-level checks, 11182 * TODO: Actually this should go to component-level checks,
11170 * but is done here due to performance. Move it to an other layer 11183 * but is done here due to performance. Move it to an other layer
11171 * is schema construction via an API is implemented. 11184 * is schema construction via an API is implemented.
11172 * 11185 *
11173 * *WARNING* this interface is highly subject to change 11186 * *WARNING* this interface is highly subject to change
11174 * 11187 *
11175 * Returns -1 in case of error, 0 if the declaration is improper and 11188 * Returns -1 in case of error, 0 if the declaration is improper and
11176 * 1 in case of success. 11189 * 1 in case of success.
11177 */ 11190 */
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
11336 part && part->children) 11349 part && part->children)
11337 { 11350 {
11338 if ((xmlSchemaGetQNameRefName(part->children) == 11351 if ((xmlSchemaGetQNameRefName(part->children) ==
11339 ctxt->redef->refName) && 11352 ctxt->redef->refName) &&
11340 (xmlSchemaGetQNameRefTargetNs(part->children) == 11353 (xmlSchemaGetQNameRefTargetNs(part->children) ==
11341 ctxt->redef->refTargetNs)) 11354 ctxt->redef->refTargetNs))
11342 { 11355 {
11343 /* 11356 /*
11344 * SPEC src-redefine: 11357 * SPEC src-redefine:
11345 * (6.1) "If it has a <group> among its contents at 11358 * (6.1) "If it has a <group> among its contents at
11346 » » » * some level the ·actual value· of whose ref 11359 » » » * some level the �actual value� of whose ref
11347 » » » * [attribute] is the same as the ·actual value· of 11360 » » » * [attribute] is the same as the �actual value� of
11348 * its own name attribute plus target namespace, then 11361 * its own name attribute plus target namespace, then
11349 * all of the following must be true:" 11362 * all of the following must be true:"
11350 * (6.1.1) "It must have exactly one such group." 11363 * (6.1.1) "It must have exactly one such group."
11351 */ 11364 */
11352 if (ctxt->redefCounter != 0) { 11365 if (ctxt->redefCounter != 0) {
11353 xmlChar *str = NULL; 11366 xmlChar *str = NULL;
11354 11367
11355 xmlSchemaCustomErr(ACTXT_CAST ctxt, 11368 xmlSchemaCustomErr(ACTXT_CAST ctxt,
11356 XML_SCHEMAP_SRC_REDEFINE, child, NULL, 11369 XML_SCHEMAP_SRC_REDEFINE, child, NULL,
11357 "The redefining model group definition " 11370 "The redefining model group definition "
11358 "'%s' must not contain more than one " 11371 "'%s' must not contain more than one "
11359 "reference to the redefined definition", 11372 "reference to the redefined definition",
11360 xmlSchemaFormatQName(&str, 11373 xmlSchemaFormatQName(&str,
11361 ctxt->redef->refTargetNs, 11374 ctxt->redef->refTargetNs,
11362 ctxt->redef->refName), 11375 ctxt->redef->refName),
11363 NULL); 11376 NULL);
11364 FREE_AND_NULL(str) 11377 FREE_AND_NULL(str)
11365 part = NULL; 11378 part = NULL;
11366 } else if (((WXS_PARTICLE(part))->minOccurs != 1) || 11379 } else if (((WXS_PARTICLE(part))->minOccurs != 1) ||
11367 ((WXS_PARTICLE(part))->maxOccurs != 1)) 11380 ((WXS_PARTICLE(part))->maxOccurs != 1))
11368 { 11381 {
11369 xmlChar *str = NULL; 11382 xmlChar *str = NULL;
11370 /* 11383 /*
11371 * SPEC src-redefine: 11384 * SPEC src-redefine:
11372 » » » * (6.1.2) "The ·actual value· of both that 11385 » » » * (6.1.2) "The �actual value� of both that
11373 * group's minOccurs and maxOccurs [attribute] 11386 * group's minOccurs and maxOccurs [attribute]
11374 » » » * must be 1 (or ·absent·). 11387 » » » * must be 1 (or �absent�).
11375 */ 11388 */
11376 xmlSchemaCustomErr(ACTXT_CAST ctxt, 11389 xmlSchemaCustomErr(ACTXT_CAST ctxt,
11377 XML_SCHEMAP_SRC_REDEFINE, child, NULL, 11390 XML_SCHEMAP_SRC_REDEFINE, child, NULL,
11378 "The redefining model group definition " 11391 "The redefining model group definition "
11379 "'%s' must not contain a reference to the " 11392 "'%s' must not contain a reference to the "
11380 "redefined definition with a " 11393 "redefined definition with a "
11381 "maxOccurs/minOccurs other than 1", 11394 "maxOccurs/minOccurs other than 1",
11382 xmlSchemaFormatQName(&str, 11395 xmlSchemaFormatQName(&str,
11383 ctxt->redef->refTargetNs, 11396 ctxt->redef->refTargetNs,
11384 ctxt->redef->refName), 11397 ctxt->redef->refName),
11385 NULL); 11398 NULL);
11386 FREE_AND_NULL(str) 11399 FREE_AND_NULL(str)
11387 part = NULL; 11400 part = NULL;
11388 } 11401 }
11389 ctxt->redef->reference = WXS_BASIC_CAST part; 11402 ctxt->redef->reference = WXS_BASIC_CAST part;
11390 ctxt->redefCounter++; 11403 ctxt->redefCounter++;
11391 » » }» » » » 11404 » » }
11392 } 11405 }
11393 } else if (IS_SCHEMA(child, "any")) { 11406 } else if (IS_SCHEMA(child, "any")) {
11394 part = (xmlSchemaTreeItemPtr) 11407 part = (xmlSchemaTreeItemPtr)
11395 xmlSchemaParseAny(ctxt, schema, child); 11408 xmlSchemaParseAny(ctxt, schema, child);
11396 } else if (IS_SCHEMA(child, "choice")) { 11409 } else if (IS_SCHEMA(child, "choice")) {
11397 part = xmlSchemaParseModelGroup(ctxt, schema, child, 11410 part = xmlSchemaParseModelGroup(ctxt, schema, child,
11398 XML_SCHEMA_TYPE_CHOICE, 1); 11411 XML_SCHEMA_TYPE_CHOICE, 1);
11399 } else if (IS_SCHEMA(child, "sequence")) { 11412 } else if (IS_SCHEMA(child, "sequence")) {
11400 part = xmlSchemaParseModelGroup(ctxt, schema, child, 11413 part = xmlSchemaParseModelGroup(ctxt, schema, child,
11401 XML_SCHEMA_TYPE_SEQUENCE, 1); 11414 XML_SCHEMA_TYPE_SEQUENCE, 1);
(...skipping 16 matching lines...) Expand all
11418 } 11431 }
11419 if ((max == 0) && (min == 0)) 11432 if ((max == 0) && (min == 0))
11420 return (NULL); 11433 return (NULL);
11421 if (hasRefs) { 11434 if (hasRefs) {
11422 /* 11435 /*
11423 * We need to resolve references. 11436 * We need to resolve references.
11424 */ 11437 */
11425 WXS_ADD_PENDING(ctxt, item); 11438 WXS_ADD_PENDING(ctxt, item);
11426 } 11439 }
11427 if (withParticle) 11440 if (withParticle)
11428 » return ((xmlSchemaTreeItemPtr) particle);» 11441 » return ((xmlSchemaTreeItemPtr) particle);
11429 else 11442 else
11430 return ((xmlSchemaTreeItemPtr) item); 11443 return ((xmlSchemaTreeItemPtr) item);
11431 } 11444 }
11432 11445
11433 /** 11446 /**
11434 * xmlSchemaParseRestriction: 11447 * xmlSchemaParseRestriction:
11435 * @ctxt: a schema validation context 11448 * @ctxt: a schema validation context
11436 * @schema: the schema being built 11449 * @schema: the schema being built
11437 * @node: a subtree containing XML Schema informations 11450 * @node: a subtree containing XML Schema informations
11438 * 11451 *
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
11470 xmlSchemaPIllegalAttrErr(ctxt, 11483 xmlSchemaPIllegalAttrErr(ctxt,
11471 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); 11484 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
11472 } 11485 }
11473 attr = attr->next; 11486 attr = attr->next;
11474 } 11487 }
11475 /* 11488 /*
11476 * Extract and validate attributes. 11489 * Extract and validate attributes.
11477 */ 11490 */
11478 xmlSchemaPValAttrID(ctxt, node, BAD_CAST "id"); 11491 xmlSchemaPValAttrID(ctxt, node, BAD_CAST "id");
11479 /* 11492 /*
11480 * Attribute 11493 * Attribute
11481 */ 11494 */
11482 /* 11495 /*
11483 * Extract the base type. The "base" attribute is mandatory if inside 11496 * Extract the base type. The "base" attribute is mandatory if inside
11484 * a complex type or if redefining. 11497 * a complex type or if redefining.
11485 * 11498 *
11486 * SPEC (1.2) "...otherwise (<restriction> has no <simpleType> " 11499 * SPEC (1.2) "...otherwise (<restriction> has no <simpleType> "
11487 * among its [children]), the simple type definition which is 11500 * among its [children]), the simple type definition which is
11488 * the {content type} of the type definition ·resolved· to by 11501 * the {content type} of the type definition �resolved� to by
11489 * the ·actual value· of the base [attribute]" 11502 * the �actual value� of the base [attribute]"
11490 */ 11503 */
11491 if (xmlSchemaPValAttrQName(ctxt, schema, NULL, node, "base", 11504 if (xmlSchemaPValAttrQName(ctxt, schema, NULL, node, "base",
11492 &(type->baseNs), &(type->base)) == 0) 11505 &(type->baseNs), &(type->base)) == 0)
11493 { 11506 {
11494 if ((type->base == NULL) && (type->type == XML_SCHEMA_TYPE_COMPLEX)) { 11507 if ((type->base == NULL) && (type->type == XML_SCHEMA_TYPE_COMPLEX)) {
11495 xmlSchemaPMissingAttrErr(ctxt, 11508 xmlSchemaPMissingAttrErr(ctxt,
11496 XML_SCHEMAP_S4S_ATTR_MISSING, 11509 XML_SCHEMAP_S4S_ATTR_MISSING,
11497 NULL, node, "base", NULL); 11510 NULL, node, "base", NULL);
11498 } else if ((ctxt->isRedefine) && 11511 } else if ((ctxt->isRedefine) &&
11499 (type->flags & XML_SCHEMAS_TYPE_GLOBAL)) 11512 (type->flags & XML_SCHEMAS_TYPE_GLOBAL))
11500 { 11513 {
11501 if (type->base == NULL) { 11514 if (type->base == NULL) {
11502 xmlSchemaPMissingAttrErr(ctxt, 11515 xmlSchemaPMissingAttrErr(ctxt,
11503 XML_SCHEMAP_S4S_ATTR_MISSING, 11516 XML_SCHEMAP_S4S_ATTR_MISSING,
11504 NULL, node, "base", NULL); 11517 NULL, node, "base", NULL);
11505 } else if ((! xmlStrEqual(type->base, type->name)) || 11518 } else if ((! xmlStrEqual(type->base, type->name)) ||
11506 (! xmlStrEqual(type->baseNs, type->targetNamespace))) 11519 (! xmlStrEqual(type->baseNs, type->targetNamespace)))
11507 { 11520 {
11508 xmlChar *str1 = NULL, *str2 = NULL; 11521 xmlChar *str1 = NULL, *str2 = NULL;
11509 /* 11522 /*
11510 * REDEFINE: SPEC src-redefine (5) 11523 * REDEFINE: SPEC src-redefine (5)
11511 * "Within the [children], each <simpleType> must have a 11524 * "Within the [children], each <simpleType> must have a
11512 » » * <restriction> among its [children] ... the ·actual value· of 11525 » » * <restriction> among its [children] ... the �actual value� of
11513 » » * whose base [attribute] must be the same as the ·actual value· 11526 » » * whose base [attribute] must be the same as the �actual value �
11514 * of its own name attribute plus target namespace;" 11527 * of its own name attribute plus target namespace;"
11515 */ 11528 */
11516 xmlSchemaPCustomErrExt(ctxt, XML_SCHEMAP_SRC_REDEFINE, 11529 xmlSchemaPCustomErrExt(ctxt, XML_SCHEMAP_SRC_REDEFINE,
11517 NULL, node, "This is a redefinition, but the QName " 11530 NULL, node, "This is a redefinition, but the QName "
11518 "value '%s' of the 'base' attribute does not match the " 11531 "value '%s' of the 'base' attribute does not match the "
11519 "type's designation '%s'", 11532 "type's designation '%s'",
11520 xmlSchemaFormatQName(&str1, type->baseNs, type->base), 11533 xmlSchemaFormatQName(&str1, type->baseNs, type->base),
11521 xmlSchemaFormatQName(&str2, type->targetNamespace, 11534 xmlSchemaFormatQName(&str2, type->targetNamespace,
11522 type->name), NULL); 11535 type->name), NULL);
11523 FREE_AND_NULL(str1); 11536 FREE_AND_NULL(str1);
11524 FREE_AND_NULL(str2); 11537 FREE_AND_NULL(str2);
11525 /* Avoid confusion and erase the values. */ 11538 /* Avoid confusion and erase the values. */
11526 type->base = NULL; 11539 type->base = NULL;
11527 type->baseNs = NULL; 11540 type->baseNs = NULL;
11528 } 11541 }
11529 » }» » 11542 » }
11530 } 11543 }
11531 /* 11544 /*
11532 * And now for the children... 11545 * And now for the children...
11533 */ 11546 */
11534 child = node->children; 11547 child = node->children;
11535 if (IS_SCHEMA(child, "annotation")) { 11548 if (IS_SCHEMA(child, "annotation")) {
11536 /* 11549 /*
11537 * Add the annotation to the simple type ancestor. 11550 * Add the annotation to the simple type ancestor.
11538 */ 11551 */
11539 xmlSchemaAddAnnotation((xmlSchemaAnnotItemPtr) type, 11552 xmlSchemaAddAnnotation((xmlSchemaAnnotItemPtr) type,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
11586 schema, child, XML_SCHEMA_TYPE_CHOICE, 1); 11599 schema, child, XML_SCHEMA_TYPE_CHOICE, 1);
11587 child = child->next; 11600 child = child->next;
11588 } else if (IS_SCHEMA(child, "sequence")) { 11601 } else if (IS_SCHEMA(child, "sequence")) {
11589 type->subtypes = (xmlSchemaTypePtr) 11602 type->subtypes = (xmlSchemaTypePtr)
11590 xmlSchemaParseModelGroup(ctxt, schema, child, 11603 xmlSchemaParseModelGroup(ctxt, schema, child,
11591 XML_SCHEMA_TYPE_SEQUENCE, 1); 11604 XML_SCHEMA_TYPE_SEQUENCE, 1);
11592 child = child->next; 11605 child = child->next;
11593 /* 11606 /*
11594 * Model group reference <group>. 11607 * Model group reference <group>.
11595 */ 11608 */
11596 » } else if (IS_SCHEMA(child, "group")) {» 11609 » } else if (IS_SCHEMA(child, "group")) {
11597 type->subtypes = (xmlSchemaTypePtr) 11610 type->subtypes = (xmlSchemaTypePtr)
11598 xmlSchemaParseModelGroupDefRef(ctxt, schema, child); 11611 xmlSchemaParseModelGroupDefRef(ctxt, schema, child);
11599 /* 11612 /*
11600 * Note that the reference will be resolved in 11613 * Note that the reference will be resolved in
11601 * xmlSchemaResolveTypeReferences(); 11614 * xmlSchemaResolveTypeReferences();
11602 */ 11615 */
11603 child = child->next; 11616 child = child->next;
11604 } 11617 }
11605 } else if (parentType == XML_SCHEMA_TYPE_SIMPLE_CONTENT) { 11618 } else if (parentType == XML_SCHEMA_TYPE_SIMPLE_CONTENT) {
11606 /* 11619 /*
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
11924 * Add the annotation to the complex type ancestor. 11937 * Add the annotation to the complex type ancestor.
11925 */ 11938 */
11926 xmlSchemaAddAnnotation((xmlSchemaAnnotItemPtr) type, 11939 xmlSchemaAddAnnotation((xmlSchemaAnnotItemPtr) type,
11927 xmlSchemaParseAnnotation(ctxt, child, 1)); 11940 xmlSchemaParseAnnotation(ctxt, child, 1));
11928 child = child->next; 11941 child = child->next;
11929 } 11942 }
11930 if (child == NULL) { 11943 if (child == NULL) {
11931 xmlSchemaPContentErr(ctxt, 11944 xmlSchemaPContentErr(ctxt,
11932 XML_SCHEMAP_S4S_ELEM_MISSING, 11945 XML_SCHEMAP_S4S_ELEM_MISSING,
11933 NULL, node, NULL, NULL, 11946 NULL, node, NULL, NULL,
11934 » "(annotation?, (restriction | extension))");» 11947 » "(annotation?, (restriction | extension))");
11935 } 11948 }
11936 if (child == NULL) { 11949 if (child == NULL) {
11937 xmlSchemaPContentErr(ctxt, 11950 xmlSchemaPContentErr(ctxt,
11938 XML_SCHEMAP_S4S_ELEM_MISSING, 11951 XML_SCHEMAP_S4S_ELEM_MISSING,
11939 NULL, node, NULL, NULL, 11952 NULL, node, NULL, NULL,
11940 » "(annotation?, (restriction | extension))");» 11953 » "(annotation?, (restriction | extension))");
11941 } 11954 }
11942 if (IS_SCHEMA(child, "restriction")) { 11955 if (IS_SCHEMA(child, "restriction")) {
11943 xmlSchemaParseRestriction(ctxt, schema, child, 11956 xmlSchemaParseRestriction(ctxt, schema, child,
11944 XML_SCHEMA_TYPE_SIMPLE_CONTENT); 11957 XML_SCHEMA_TYPE_SIMPLE_CONTENT);
11945 (*hasRestrictionOrExtension) = 1; 11958 (*hasRestrictionOrExtension) = 1;
11946 child = child->next; 11959 child = child->next;
11947 } else if (IS_SCHEMA(child, "extension")) { 11960 } else if (IS_SCHEMA(child, "extension")) {
11948 xmlSchemaParseExtension(ctxt, schema, child, 11961 xmlSchemaParseExtension(ctxt, schema, child,
11949 XML_SCHEMA_TYPE_SIMPLE_CONTENT); 11962 XML_SCHEMA_TYPE_SIMPLE_CONTENT);
11950 (*hasRestrictionOrExtension) = 1; 11963 (*hasRestrictionOrExtension) = 1;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
12087 12100
12088 if (topLevel) { 12101 if (topLevel) {
12089 attr = xmlSchemaGetPropNode(node, "name"); 12102 attr = xmlSchemaGetPropNode(node, "name");
12090 if (attr == NULL) { 12103 if (attr == NULL) {
12091 xmlSchemaPMissingAttrErr(ctxt, 12104 xmlSchemaPMissingAttrErr(ctxt,
12092 XML_SCHEMAP_S4S_ATTR_MISSING, NULL, node, "name", NULL); 12105 XML_SCHEMAP_S4S_ATTR_MISSING, NULL, node, "name", NULL);
12093 return (NULL); 12106 return (NULL);
12094 } else if (xmlSchemaPValAttrNode(ctxt, NULL, attr, 12107 } else if (xmlSchemaPValAttrNode(ctxt, NULL, attr,
12095 xmlSchemaGetBuiltInType(XML_SCHEMAS_NCNAME), &name) != 0) { 12108 xmlSchemaGetBuiltInType(XML_SCHEMAS_NCNAME), &name) != 0) {
12096 return (NULL); 12109 return (NULL);
12097 » }» 12110 » }
12098 } 12111 }
12099 12112
12100 if (topLevel == 0) { 12113 if (topLevel == 0) {
12101 /* 12114 /*
12102 * Parse as local complex type definition. 12115 * Parse as local complex type definition.
12103 */ 12116 */
12104 #ifdef ENABLE_NAMED_LOCALS 12117 #ifdef ENABLE_NAMED_LOCALS
12105 snprintf(buf, 39, "#CT%d", ctxt->counter++ + 1); 12118 snprintf(buf, 39, "#CT%d", ctxt->counter++ + 1);
12106 type = xmlSchemaAddType(ctxt, schema, 12119 type = xmlSchemaAddType(ctxt, schema,
12107 XML_SCHEMA_TYPE_COMPLEX, 12120 XML_SCHEMA_TYPE_COMPLEX,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
12176 -1, 12189 -1,
12177 XML_SCHEMAS_TYPE_FINAL_EXTENSION, 12190 XML_SCHEMAS_TYPE_FINAL_EXTENSION,
12178 XML_SCHEMAS_TYPE_FINAL_RESTRICTION, 12191 XML_SCHEMAS_TYPE_FINAL_RESTRICTION,
12179 -1, -1, -1) != 0) 12192 -1, -1, -1) != 0)
12180 { 12193 {
12181 xmlSchemaPSimpleTypeErr(ctxt, 12194 xmlSchemaPSimpleTypeErr(ctxt,
12182 XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, 12195 XML_SCHEMAP_S4S_ATTR_INVALID_VALUE,
12183 NULL, (xmlNodePtr) attr, NULL, 12196 NULL, (xmlNodePtr) attr, NULL,
12184 "(#all | List of (extension | restriction))", 12197 "(#all | List of (extension | restriction))",
12185 attrValue, NULL, NULL, NULL); 12198 attrValue, NULL, NULL, NULL);
12186 » » } else 12199 » » } else
12187 final = 1; 12200 final = 1;
12188 } else if (xmlStrEqual(attr->name, BAD_CAST "block")) { 12201 } else if (xmlStrEqual(attr->name, BAD_CAST "block")) {
12189 /* 12202 /*
12190 * Attribute "block". 12203 * Attribute "block".
12191 */ 12204 */
12192 attrValue = xmlSchemaGetNodeContent(ctxt, 12205 attrValue = xmlSchemaGetNodeContent(ctxt,
12193 (xmlNodePtr) attr); 12206 (xmlNodePtr) attr);
12194 if (xmlSchemaPValAttrBlockFinal(attrValue, &(type->flags), 12207 if (xmlSchemaPValAttrBlockFinal(attrValue, &(type->flags),
12195 -1, 12208 -1,
12196 XML_SCHEMAS_TYPE_BLOCK_EXTENSION, 12209 XML_SCHEMAS_TYPE_BLOCK_EXTENSION,
12197 XML_SCHEMAS_TYPE_BLOCK_RESTRICTION, 12210 XML_SCHEMAS_TYPE_BLOCK_RESTRICTION,
12198 -1, -1, -1) != 0) { 12211 -1, -1, -1) != 0) {
12199 xmlSchemaPSimpleTypeErr(ctxt, 12212 xmlSchemaPSimpleTypeErr(ctxt,
12200 XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, 12213 XML_SCHEMAP_S4S_ATTR_INVALID_VALUE,
12201 NULL, (xmlNodePtr) attr, NULL, 12214 NULL, (xmlNodePtr) attr, NULL,
12202 "(#all | List of (extension | restriction)) ", 12215 "(#all | List of (extension | restriction)) ",
12203 attrValue, NULL, NULL, NULL); 12216 attrValue, NULL, NULL, NULL);
12204 » » } else 12217 » » } else
12205 block = 1; 12218 block = 1;
12206 } else { 12219 } else {
12207 xmlSchemaPIllegalAttrErr(ctxt, 12220 xmlSchemaPIllegalAttrErr(ctxt,
12208 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); 12221 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
12209 } 12222 }
12210 } else { 12223 } else {
12211 xmlSchemaPIllegalAttrErr(ctxt, 12224 xmlSchemaPIllegalAttrErr(ctxt,
12212 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); 12225 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
12213 } 12226 }
12214 } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) { 12227 } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) {
12215 » xmlSchemaPIllegalAttrErr(ctxt, 12228 » xmlSchemaPIllegalAttrErr(ctxt,
12216 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); 12229 XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
12217 } 12230 }
12218 attr = attr->next; 12231 attr = attr->next;
12219 } 12232 }
12220 if (! block) { 12233 if (! block) {
12221 /* 12234 /*
12222 * Apply default "block" values. 12235 * Apply default "block" values.
12223 */ 12236 */
12224 if (schema->flags & XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION) 12237 if (schema->flags & XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION)
12225 type->flags |= XML_SCHEMAS_TYPE_BLOCK_RESTRICTION; 12238 type->flags |= XML_SCHEMAS_TYPE_BLOCK_RESTRICTION;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
12264 xmlSchemaParseComplexContent(ctxt, schema, child, 12277 xmlSchemaParseComplexContent(ctxt, schema, child,
12265 &hasRestrictionOrExtension); 12278 &hasRestrictionOrExtension);
12266 child = child->next; 12279 child = child->next;
12267 } else { 12280 } else {
12268 /* 12281 /*
12269 * E.g <complexType><sequence>... or <complexType><attribute>... etc. 12282 * E.g <complexType><sequence>... or <complexType><attribute>... etc.
12270 * 12283 *
12271 * SPEC 12284 * SPEC
12272 * "...the third alternative (neither <simpleContent> nor 12285 * "...the third alternative (neither <simpleContent> nor
12273 * <complexContent>) is chosen. This case is understood as shorthand 12286 * <complexContent>) is chosen. This case is understood as shorthand
12274 » * for complex content restricting the ·ur-type definition·, and the 12287 » * for complex content restricting the �ur-type definition�, and the
12275 * details of the mappings should be modified as necessary. 12288 * details of the mappings should be modified as necessary.
12276 */ 12289 */
12277 type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYTYPE); 12290 type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYTYPE);
12278 type->flags |= XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION; 12291 type->flags |= XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION;
12279 /* 12292 /*
12280 * Parse model groups. 12293 * Parse model groups.
12281 */ 12294 */
12282 if (IS_SCHEMA(child, "all")) { 12295 if (IS_SCHEMA(child, "all")) {
12283 type->subtypes = (xmlSchemaTypePtr) 12296 type->subtypes = (xmlSchemaTypePtr)
12284 xmlSchemaParseModelGroup(ctxt, schema, child, 12297 xmlSchemaParseModelGroup(ctxt, schema, child,
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
12441 { 12454 {
12442 xmlSchemaParserCtxtPtr ret; 12455 xmlSchemaParserCtxtPtr ret;
12443 12456
12444 if ((buffer == NULL) || (size <= 0)) 12457 if ((buffer == NULL) || (size <= 0))
12445 return (NULL); 12458 return (NULL);
12446 ret = xmlSchemaParserCtxtCreate(); 12459 ret = xmlSchemaParserCtxtCreate();
12447 if (ret == NULL) 12460 if (ret == NULL)
12448 return(NULL); 12461 return(NULL);
12449 ret->buffer = buffer; 12462 ret->buffer = buffer;
12450 ret->size = size; 12463 ret->size = size;
12451 ret->dict = xmlDictCreate(); 12464 ret->dict = xmlDictCreate();
12452 return (ret); 12465 return (ret);
12453 } 12466 }
12454 12467
12455 /** 12468 /**
12456 * xmlSchemaNewDocParserCtxt: 12469 * xmlSchemaNewDocParserCtxt:
12457 * @doc: a preparsed document tree 12470 * @doc: a preparsed document tree
12458 * 12471 *
12459 * Create an XML Schemas parse context for that document. 12472 * Create an XML Schemas parse context for that document.
12460 * NB. The document may be modified during the parsing process. 12473 * NB. The document may be modified during the parsing process.
12461 * 12474 *
(...skipping 22 matching lines...) Expand all
12484 * @ctxt: the schema parser context 12497 * @ctxt: the schema parser context
12485 * 12498 *
12486 * Free the resources associated to the schema parser context 12499 * Free the resources associated to the schema parser context
12487 */ 12500 */
12488 void 12501 void
12489 xmlSchemaFreeParserCtxt(xmlSchemaParserCtxtPtr ctxt) 12502 xmlSchemaFreeParserCtxt(xmlSchemaParserCtxtPtr ctxt)
12490 { 12503 {
12491 if (ctxt == NULL) 12504 if (ctxt == NULL)
12492 return; 12505 return;
12493 if (ctxt->doc != NULL && !ctxt->preserve) 12506 if (ctxt->doc != NULL && !ctxt->preserve)
12494 xmlFreeDoc(ctxt->doc); 12507 xmlFreeDoc(ctxt->doc);
12495 if (ctxt->vctxt != NULL) { 12508 if (ctxt->vctxt != NULL) {
12496 xmlSchemaFreeValidCtxt(ctxt->vctxt); 12509 xmlSchemaFreeValidCtxt(ctxt->vctxt);
12497 } 12510 }
12498 if (ctxt->ownsConstructor && (ctxt->constructor != NULL)) { 12511 if (ctxt->ownsConstructor && (ctxt->constructor != NULL)) {
12499 xmlSchemaConstructionCtxtFree(ctxt->constructor); 12512 xmlSchemaConstructionCtxtFree(ctxt->constructor);
12500 ctxt->constructor = NULL; 12513 ctxt->constructor = NULL;
12501 ctxt->ownsConstructor = 0; 12514 ctxt->ownsConstructor = 0;
12502 } 12515 }
12503 if (ctxt->attrProhibs != NULL) 12516 if (ctxt->attrProhibs != NULL)
12504 xmlSchemaItemListFree(ctxt->attrProhibs); 12517 xmlSchemaItemListFree(ctxt->attrProhibs);
12505 xmlDictFree(ctxt->dict); 12518 xmlDictFree(ctxt->dict);
12506 xmlFree(ctxt); 12519 xmlFree(ctxt);
12507 } 12520 }
12508 12521
12509 /************************************************************************ 12522 /************************************************************************
12510 * * 12523 * *
12511 * Building the content models * 12524 * Building the content models *
12512 * * 12525 * *
12513 ************************************************************************/ 12526 ************************************************************************/
12514 12527
12515 static void 12528 /**
12529 * xmlSchemaBuildContentModelForSubstGroup:
12530 *
12531 * Returns 1 if nillable, 0 otherwise
12532 */
12533 static int
12516 xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt, 12534 xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt,
12517 xmlSchemaParticlePtr particle, int counter, xmlAutomataStatePtr end) 12535 xmlSchemaParticlePtr particle, int counter, xmlAutomataStatePtr end)
12518 { 12536 {
12519 xmlAutomataStatePtr start, tmp; 12537 xmlAutomataStatePtr start, tmp;
12520 xmlSchemaElementPtr elemDecl, member; 12538 xmlSchemaElementPtr elemDecl, member;
12521 xmlSchemaSubstGroupPtr substGroup; 12539 xmlSchemaSubstGroupPtr substGroup;
12522 int i; 12540 int i;
12541 int ret = 0;
12523 12542
12524 elemDecl = (xmlSchemaElementPtr) particle->children; 12543 elemDecl = (xmlSchemaElementPtr) particle->children;
12525 /* 12544 /*
12526 * Wrap the substitution group with a CHOICE. 12545 * Wrap the substitution group with a CHOICE.
12527 */ 12546 */
12528 start = pctxt->state; 12547 start = pctxt->state;
12529 if (end == NULL) 12548 if (end == NULL)
12530 end = xmlAutomataNewState(pctxt->am); 12549 end = xmlAutomataNewState(pctxt->am);
12531 substGroup = xmlSchemaSubstGroupGet(pctxt, elemDecl); 12550 substGroup = xmlSchemaSubstGroupGet(pctxt, elemDecl);
12532 if (substGroup == NULL) { 12551 if (substGroup == NULL) {
12533 xmlSchemaPErr(pctxt, WXS_ITEM_NODE(particle), 12552 xmlSchemaPErr(pctxt, WXS_ITEM_NODE(particle),
12534 XML_SCHEMAP_INTERNAL, 12553 XML_SCHEMAP_INTERNAL,
12535 "Internal error: xmlSchemaBuildContentModelForSubstGroup, " 12554 "Internal error: xmlSchemaBuildContentModelForSubstGroup, "
12536 "declaration is marked having a subst. group but none " 12555 "declaration is marked having a subst. group but none "
12537 "available.\n", elemDecl->name, NULL); 12556 "available.\n", elemDecl->name, NULL);
12538 » return; 12557 » return(0);
12539 } 12558 }
12540 if (counter >= 0) { 12559 if (counter >= 0) {
12541 /* 12560 /*
12542 * NOTE that we put the declaration in, even if it's abstract. 12561 * NOTE that we put the declaration in, even if it's abstract.
12543 * However, an error will be raised during *validation* if an element 12562 * However, an error will be raised during *validation* if an element
12544 * information item shall be validated against an abstract element 12563 * information item shall be validated against an abstract element
12545 * declaration. 12564 * declaration.
12546 */ 12565 */
12547 tmp = xmlAutomataNewCountedTrans(pctxt->am, start, NULL, counter); 12566 tmp = xmlAutomataNewCountedTrans(pctxt->am, start, NULL, counter);
12548 xmlAutomataNewTransition2(pctxt->am, tmp, end, 12567 xmlAutomataNewTransition2(pctxt->am, tmp, end,
(...skipping 17 matching lines...) Expand all
12566 /* 12585 /*
12567 * Add subst. group members. 12586 * Add subst. group members.
12568 */ 12587 */
12569 for (i = 0; i < substGroup->members->nbItems; i++) { 12588 for (i = 0; i < substGroup->members->nbItems; i++) {
12570 member = (xmlSchemaElementPtr) substGroup->members->items[i]; 12589 member = (xmlSchemaElementPtr) substGroup->members->items[i];
12571 /* 12590 /*
12572 * NOTE: This fixes bug #341150. xmlAutomataNewOnceTrans2() 12591 * NOTE: This fixes bug #341150. xmlAutomataNewOnceTrans2()
12573 * was incorrectly used instead of xmlAutomataNewTransition2() 12592 * was incorrectly used instead of xmlAutomataNewTransition2()
12574 * (seems like a copy&paste bug from the XML_SCHEMA_TYPE_ALL 12593 * (seems like a copy&paste bug from the XML_SCHEMA_TYPE_ALL
12575 * section in xmlSchemaBuildAContentModel() ). 12594 * section in xmlSchemaBuildAContentModel() ).
12576 » * TODO: Check if xmlAutomataNewOnceTrans2() was instead 12595 » * TODO: Check if xmlAutomataNewOnceTrans2() was instead
12577 * intended for the above "counter" section originally. I.e., 12596 * intended for the above "counter" section originally. I.e.,
12578 * check xs:all with subst-groups. 12597 * check xs:all with subst-groups.
12579 * 12598 *
12580 * tmp = xmlAutomataNewOnceTrans2(pctxt->am, start, NULL, 12599 * tmp = xmlAutomataNewOnceTrans2(pctxt->am, start, NULL,
12581 * member->name, member->targetNamespace, 12600 * member->name, member->targetNamespace,
12582 * 1, 1, member); 12601 * 1, 1, member);
12583 */ 12602 */
12584 tmp = xmlAutomataNewTransition2(pctxt->am, start, NULL, 12603 tmp = xmlAutomataNewTransition2(pctxt->am, start, NULL,
12585 » » member->name, member->targetNamespace, member);» 12604 » » member->name, member->targetNamespace, member);
12586 xmlAutomataNewEpsilon(pctxt->am, tmp, end); 12605 xmlAutomataNewEpsilon(pctxt->am, tmp, end);
12587 } 12606 }
12588 } else { 12607 } else {
12589 xmlAutomataStatePtr hop; 12608 xmlAutomataStatePtr hop;
12590 int maxOccurs = particle->maxOccurs == UNBOUNDED ? 12609 int maxOccurs = particle->maxOccurs == UNBOUNDED ?
12591 UNBOUNDED : particle->maxOccurs - 1; 12610 UNBOUNDED : particle->maxOccurs - 1;
12592 int minOccurs = particle->minOccurs < 1 ? 0 : particle->minOccurs - 1; 12611 int minOccurs = particle->minOccurs < 1 ? 0 : particle->minOccurs - 1;
12593 12612
12594 counter = 12613 counter =
12595 xmlAutomataNewCounter(pctxt->am, minOccurs, 12614 xmlAutomataNewCounter(pctxt->am, minOccurs,
(...skipping 12 matching lines...) Expand all
12608 member = (xmlSchemaElementPtr) substGroup->members->items[i]; 12627 member = (xmlSchemaElementPtr) substGroup->members->items[i];
12609 xmlAutomataNewEpsilon(pctxt->am, 12628 xmlAutomataNewEpsilon(pctxt->am,
12610 xmlAutomataNewTransition2(pctxt->am, 12629 xmlAutomataNewTransition2(pctxt->am,
12611 start, NULL, 12630 start, NULL,
12612 member->name, member->targetNamespace, member), 12631 member->name, member->targetNamespace, member),
12613 hop); 12632 hop);
12614 } 12633 }
12615 xmlAutomataNewCountedTrans(pctxt->am, hop, start, counter); 12634 xmlAutomataNewCountedTrans(pctxt->am, hop, start, counter);
12616 xmlAutomataNewCounterTrans(pctxt->am, hop, end, counter); 12635 xmlAutomataNewCounterTrans(pctxt->am, hop, end, counter);
12617 } 12636 }
12618 if (particle->minOccurs == 0) 12637 if (particle->minOccurs == 0) {
12619 xmlAutomataNewEpsilon(pctxt->am, start, end); 12638 xmlAutomataNewEpsilon(pctxt->am, start, end);
12639 ret = 1;
12640 }
12620 pctxt->state = end; 12641 pctxt->state = end;
12642 return(ret);
12621 } 12643 }
12622 12644
12623 static void 12645 /**
12646 * xmlSchemaBuildContentModelForElement:
12647 *
12648 * Returns 1 if nillable, 0 otherwise
12649 */
12650 static int
12624 xmlSchemaBuildContentModelForElement(xmlSchemaParserCtxtPtr ctxt, 12651 xmlSchemaBuildContentModelForElement(xmlSchemaParserCtxtPtr ctxt,
12625 xmlSchemaParticlePtr particle) 12652 xmlSchemaParticlePtr particle)
12626 { 12653 {
12654 int ret = 0;
12655
12627 if (((xmlSchemaElementPtr) particle->children)->flags & 12656 if (((xmlSchemaElementPtr) particle->children)->flags &
12628 XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD) { 12657 XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD) {
12629 /* 12658 /*
12630 * Substitution groups. 12659 * Substitution groups.
12631 */ 12660 */
12632 » xmlSchemaBuildContentModelForSubstGroup(ctxt, particle, -1, NULL); 12661 » ret = xmlSchemaBuildContentModelForSubstGroup(ctxt, particle, -1, NULL);
12633 } else { 12662 } else {
12634 xmlSchemaElementPtr elemDecl; 12663 xmlSchemaElementPtr elemDecl;
12635 xmlAutomataStatePtr start; 12664 xmlAutomataStatePtr start;
12636 12665
12637 elemDecl = (xmlSchemaElementPtr) particle->children; 12666 elemDecl = (xmlSchemaElementPtr) particle->children;
12638 12667
12639 if (elemDecl->flags & XML_SCHEMAS_ELEM_ABSTRACT) 12668 if (elemDecl->flags & XML_SCHEMAS_ELEM_ABSTRACT)
12640 » return; 12669 » return(0);
12641 if (particle->maxOccurs == 1) { 12670 if (particle->maxOccurs == 1) {
12642 start = ctxt->state; 12671 start = ctxt->state;
12643 ctxt->state = xmlAutomataNewTransition2(ctxt->am, start, NULL, 12672 ctxt->state = xmlAutomataNewTransition2(ctxt->am, start, NULL,
12644 elemDecl->name, elemDecl->targetNamespace, elemDecl); 12673 elemDecl->name, elemDecl->targetNamespace, elemDecl);
12645 } else if ((particle->maxOccurs >= UNBOUNDED) && 12674 } else if ((particle->maxOccurs >= UNBOUNDED) &&
12646 (particle->minOccurs < 2)) { 12675 (particle->minOccurs < 2)) {
12647 /* Special case. */ 12676 /* Special case. */
12648 » start = ctxt->state;» 12677 » start = ctxt->state;
12649 ctxt->state = xmlAutomataNewTransition2(ctxt->am, start, NULL, 12678 ctxt->state = xmlAutomataNewTransition2(ctxt->am, start, NULL,
12650 » » elemDecl->name, elemDecl->targetNamespace, elemDecl);» 12679 » » elemDecl->name, elemDecl->targetNamespace, elemDecl);
12651 ctxt->state = xmlAutomataNewTransition2(ctxt->am, ctxt->state, ctxt- >state, 12680 ctxt->state = xmlAutomataNewTransition2(ctxt->am, ctxt->state, ctxt- >state,
12652 » » elemDecl->name, elemDecl->targetNamespace, elemDecl);» 12681 » » elemDecl->name, elemDecl->targetNamespace, elemDecl);
12653 } else { 12682 } else {
12654 int counter; 12683 int counter;
12655 int maxOccurs = particle->maxOccurs == UNBOUNDED ? 12684 int maxOccurs = particle->maxOccurs == UNBOUNDED ?
12656 UNBOUNDED : particle->maxOccurs - 1; 12685 UNBOUNDED : particle->maxOccurs - 1;
12657 int minOccurs = particle->minOccurs < 1 ? 12686 int minOccurs = particle->minOccurs < 1 ?
12658 0 : particle->minOccurs - 1; 12687 0 : particle->minOccurs - 1;
12659 12688
12660 start = xmlAutomataNewEpsilon(ctxt->am, ctxt->state, NULL); 12689 start = xmlAutomataNewEpsilon(ctxt->am, ctxt->state, NULL);
12661 counter = xmlAutomataNewCounter(ctxt->am, minOccurs, maxOccurs); 12690 counter = xmlAutomataNewCounter(ctxt->am, minOccurs, maxOccurs);
12662 ctxt->state = xmlAutomataNewTransition2(ctxt->am, start, NULL, 12691 ctxt->state = xmlAutomataNewTransition2(ctxt->am, start, NULL,
12663 elemDecl->name, elemDecl->targetNamespace, elemDecl); 12692 elemDecl->name, elemDecl->targetNamespace, elemDecl);
12664 xmlAutomataNewCountedTrans(ctxt->am, ctxt->state, start, counter); 12693 xmlAutomataNewCountedTrans(ctxt->am, ctxt->state, start, counter);
12665 ctxt->state = xmlAutomataNewCounterTrans(ctxt->am, ctxt->state, 12694 ctxt->state = xmlAutomataNewCounterTrans(ctxt->am, ctxt->state,
12666 NULL, counter); 12695 NULL, counter);
12667 } 12696 }
12668 » if (particle->minOccurs == 0) 12697 » if (particle->minOccurs == 0) {
12669 xmlAutomataNewEpsilon(ctxt->am, start, ctxt->state); 12698 xmlAutomataNewEpsilon(ctxt->am, start, ctxt->state);
12699 ret = 1;
12700 }
12670 } 12701 }
12702 return(ret);
12671 } 12703 }
12672 12704
12673 /** 12705 /**
12674 * xmlSchemaBuildAContentModel: 12706 * xmlSchemaBuildAContentModel:
12675 * @ctxt: the schema parser context 12707 * @ctxt: the schema parser context
12676 * @particle: the particle component 12708 * @particle: the particle component
12677 * @name: the complex type's name whose content is being built 12709 * @name: the complex type's name whose content is being built
12678 * 12710 *
12679 * Create the automaton for the {content type} of a complex type. 12711 * Create the automaton for the {content type} of a complex type.
12680 * 12712 *
12713 * Returns 1 if the content is nillable, 0 otherwise
12681 */ 12714 */
12682 static void 12715 static int
12683 xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt, 12716 xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt,
12684 xmlSchemaParticlePtr particle) 12717 xmlSchemaParticlePtr particle)
12685 { 12718 {
12719 int ret = 0, tmp2;
12720
12686 if (particle == NULL) { 12721 if (particle == NULL) {
12687 » PERROR_INT("xmlSchemaBuildAContentModel", "particle is NULL");» 12722 » PERROR_INT("xmlSchemaBuildAContentModel", "particle is NULL");
12688 » return; 12723 » return(1);
12689 } 12724 }
12690 if (particle->children == NULL) { 12725 if (particle->children == NULL) {
12691 /* 12726 /*
12692 * Just return in this case. A missing "term" of the particle 12727 * Just return in this case. A missing "term" of the particle
12693 * might arise due to an invalid "term" component. 12728 * might arise due to an invalid "term" component.
12694 */ 12729 */
12695 » return; 12730 » return(1);
12696 } 12731 }
12697 12732
12698 switch (particle->children->type) { 12733 switch (particle->children->type) {
12699 case XML_SCHEMA_TYPE_ANY: { 12734 case XML_SCHEMA_TYPE_ANY: {
12700 xmlAutomataStatePtr start, end; 12735 xmlAutomataStatePtr start, end;
12701 xmlSchemaWildcardPtr wild; 12736 xmlSchemaWildcardPtr wild;
12702 xmlSchemaWildcardNsPtr ns; 12737 xmlSchemaWildcardNsPtr ns;
12703 12738
12704 wild = (xmlSchemaWildcardPtr) particle->children; 12739 wild = (xmlSchemaWildcardPtr) particle->children;
12705 12740
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
12737 12772
12738 } else if (wild->negNsSet != NULL) { 12773 } else if (wild->negNsSet != NULL) {
12739 pctxt->state = xmlAutomataNewNegTrans(pctxt->am, 12774 pctxt->state = xmlAutomataNewNegTrans(pctxt->am,
12740 start, end, BAD_CAST "*", wild->negNsSet->value, 12775 start, end, BAD_CAST "*", wild->negNsSet->value,
12741 wild); 12776 wild);
12742 } 12777 }
12743 } else { 12778 } else {
12744 int counter; 12779 int counter;
12745 xmlAutomataStatePtr hop; 12780 xmlAutomataStatePtr hop;
12746 int maxOccurs = 12781 int maxOccurs =
12747 » » particle->maxOccurs == UNBOUNDED ? UNBOUNDED : particle->max Occurs - 1; 12782 » » particle->maxOccurs == UNBOUNDED ? UNBOUNDED :
12783 particle->maxOccurs - 1;
12748 int minOccurs = 12784 int minOccurs =
12749 particle->minOccurs < 1 ? 0 : particle->minOccurs - 1; 12785 particle->minOccurs < 1 ? 0 : particle->minOccurs - 1;
12750 12786
12751 counter = xmlAutomataNewCounter(pctxt->am, minOccurs, maxOccurs) ; 12787 counter = xmlAutomataNewCounter(pctxt->am, minOccurs, maxOccurs) ;
12752 hop = xmlAutomataNewState(pctxt->am); 12788 hop = xmlAutomataNewState(pctxt->am);
12753 if (wild->any == 1) { 12789 if (wild->any == 1) {
12754 pctxt->state = 12790 pctxt->state =
12755 xmlAutomataNewTransition2(pctxt->am, 12791 xmlAutomataNewTransition2(pctxt->am,
12756 start, NULL, BAD_CAST "*", BAD_CAST "*", wild); 12792 start, NULL, BAD_CAST "*", BAD_CAST "*", wild);
12757 xmlAutomataNewEpsilon(pctxt->am, pctxt->state, hop); 12793 xmlAutomataNewEpsilon(pctxt->am, pctxt->state, hop);
(...skipping 14 matching lines...) Expand all
12772 } else if (wild->negNsSet != NULL) { 12808 } else if (wild->negNsSet != NULL) {
12773 pctxt->state = xmlAutomataNewNegTrans(pctxt->am, 12809 pctxt->state = xmlAutomataNewNegTrans(pctxt->am,
12774 start, hop, BAD_CAST "*", wild->negNsSet->value, 12810 start, hop, BAD_CAST "*", wild->negNsSet->value,
12775 wild); 12811 wild);
12776 } 12812 }
12777 xmlAutomataNewCountedTrans(pctxt->am, hop, start, counter); 12813 xmlAutomataNewCountedTrans(pctxt->am, hop, start, counter);
12778 xmlAutomataNewCounterTrans(pctxt->am, hop, end, counter); 12814 xmlAutomataNewCounterTrans(pctxt->am, hop, end, counter);
12779 } 12815 }
12780 if (particle->minOccurs == 0) { 12816 if (particle->minOccurs == 0) {
12781 xmlAutomataNewEpsilon(pctxt->am, start, end); 12817 xmlAutomataNewEpsilon(pctxt->am, start, end);
12818 ret = 1;
12782 } 12819 }
12783 pctxt->state = end; 12820 pctxt->state = end;
12784 break; 12821 break;
12785 } 12822 }
12786 case XML_SCHEMA_TYPE_ELEMENT: 12823 case XML_SCHEMA_TYPE_ELEMENT:
12787 » xmlSchemaBuildContentModelForElement(pctxt, particle); 12824 » ret = xmlSchemaBuildContentModelForElement(pctxt, particle);
12788 break; 12825 break;
12789 case XML_SCHEMA_TYPE_SEQUENCE:{ 12826 case XML_SCHEMA_TYPE_SEQUENCE:{
12790 xmlSchemaTreeItemPtr sub; 12827 xmlSchemaTreeItemPtr sub;
12791 12828
12792 /* 12829 ret = 1;
12793 * If max and min occurances are default (1) then 12830 /*
12794 * simply iterate over the particles of the <sequence>. 12831 * If max and min occurances are default (1) then
12795 */ 12832 * simply iterate over the particles of the <sequence>.
12796 if ((particle->minOccurs == 1) && (particle->maxOccurs == 1)) { 12833 */
12797 sub = particle->children->children; 12834 if ((particle->minOccurs == 1) && (particle->maxOccurs == 1)) {
12798 while (sub != NULL) { 12835 sub = particle->children->children;
12799 xmlSchemaBuildAContentModel(pctxt, 12836
12800 » » » (xmlSchemaParticlePtr) sub); 12837 while (sub != NULL) {
12801 sub = sub->next; 12838 tmp2 = xmlSchemaBuildAContentModel(pctxt,
12802 } 12839 (xmlSchemaParticlePtr) sub);
12803 } else { 12840 if (tmp2 != 1) ret = 0;
12804 xmlAutomataStatePtr oldstate = pctxt->state; 12841 sub = sub->next;
12805 12842 }
12806 if (particle->maxOccurs >= UNBOUNDED) { 12843 } else {
12807 if (particle->minOccurs > 1) { 12844 xmlAutomataStatePtr oldstate = pctxt->state;
12808 xmlAutomataStatePtr tmp; 12845
12809 int counter; 12846 if (particle->maxOccurs >= UNBOUNDED) {
12810 12847 if (particle->minOccurs > 1) {
12811 pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
12812 » » » » oldstate, NULL);
12813 oldstate = pctxt->state;
12814
12815 counter = xmlAutomataNewCounter(pctxt->am,
12816 » » » » particle->minOccurs - 1, UNBOUNDED);
12817
12818 sub = particle->children->children;
12819 while (sub != NULL) {
12820 xmlSchemaBuildAContentModel(pctxt,
12821 » » » » (xmlSchemaParticlePtr) sub);
12822 sub = sub->next;
12823 }
12824 tmp = pctxt->state;
12825 xmlAutomataNewCountedTrans(pctxt->am, tmp,
12826 oldstate, counter);
12827 pctxt->state =
12828 xmlAutomataNewCounterTrans(pctxt->am, tmp,
12829 NULL, counter);
12830
12831 } else {
12832 pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
12833 » » » » oldstate, NULL);
12834 oldstate = pctxt->state;
12835
12836 » » » sub = particle->children->children;
12837 while (sub != NULL) {
12838 xmlSchemaBuildAContentModel(pctxt,
12839 » » » » (xmlSchemaParticlePtr) sub);
12840 sub = sub->next;
12841 }
12842 xmlAutomataNewEpsilon(pctxt->am, pctxt->state,
12843 oldstate);
12844 » » » /*
12845 » » » * epsilon needed to block previous trans from
12846 » » » * being allowed to enter back from another
12847 » » » * construct
12848 » » » */
12849 » » » pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
12850 » » » » » » pctxt->state, NULL);
12851 if (particle->minOccurs == 0) {
12852 xmlAutomataNewEpsilon(pctxt->am,
12853 » » » » oldstate, pctxt->state);
12854 }
12855 }
12856 } else if ((particle->maxOccurs > 1)
12857 || (particle->minOccurs > 1)) {
12858 xmlAutomataStatePtr tmp; 12848 xmlAutomataStatePtr tmp;
12859 int counter; 12849 int counter;
12860 12850
12861 pctxt->state = xmlAutomataNewEpsilon(pctxt->am, 12851 pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
12862 » » » oldstate, NULL); 12852 oldstate, NULL);
12863 oldstate = pctxt->state; 12853 oldstate = pctxt->state;
12864 12854
12865 counter = xmlAutomataNewCounter(pctxt->am, 12855 counter = xmlAutomataNewCounter(pctxt->am,
12866 » » » particle->minOccurs - 1, 12856 particle->minOccurs - 1, UNBOUNDED);
12867 » » » particle->maxOccurs - 1);
12868 12857
12869 sub = particle->children->children; 12858 sub = particle->children->children;
12870 while (sub != NULL) { 12859 while (sub != NULL) {
12871 xmlSchemaBuildAContentModel(pctxt, 12860 tmp2 = xmlSchemaBuildAContentModel(pctxt,
12872 » » » » (xmlSchemaParticlePtr) sub); 12861 (xmlSchemaParticlePtr) sub);
12862 if (tmp2 != 1) ret = 0;
12873 sub = sub->next; 12863 sub = sub->next;
12874 } 12864 }
12875 tmp = pctxt->state; 12865 tmp = pctxt->state;
12876 xmlAutomataNewCountedTrans(pctxt->am, 12866 xmlAutomataNewCountedTrans(pctxt->am, tmp,
12877 » » » tmp, oldstate, counter); 12867 oldstate, counter);
12878 pctxt->state = 12868 pctxt->state =
12879 xmlAutomataNewCounterTrans(pctxt->am, tmp, NULL, 12869 xmlAutomataNewCounterTrans(pctxt->am, tmp,
12880 counter); 12870 NULL, counter);
12871 if (ret == 1)
12872 xmlAutomataNewEpsilon(pctxt->am,
12873 oldstate, pctxt->state);
12874
12875 } else {
12876 pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
12877 oldstate, NULL);
12878 oldstate = pctxt->state;
12879
12880 sub = particle->children->children;
12881 while (sub != NULL) {
12882 tmp2 = xmlSchemaBuildAContentModel(pctxt,
12883 (xmlSchemaParticlePtr) sub);
12884 if (tmp2 != 1) ret = 0;
12885 sub = sub->next;
12886 }
12887 xmlAutomataNewEpsilon(pctxt->am, pctxt->state,
12888 oldstate);
12889 /*
12890 * epsilon needed to block previous trans from
12891 * being allowed to enter back from another
12892 * construct
12893 */
12894 pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
12895 pctxt->state, NULL);
12881 if (particle->minOccurs == 0) { 12896 if (particle->minOccurs == 0) {
12882 xmlAutomataNewEpsilon(pctxt->am, 12897 xmlAutomataNewEpsilon(pctxt->am,
12883 » » » » oldstate, pctxt->state); 12898 oldstate, pctxt->state);
12899 ret = 1;
12884 } 12900 }
12885 } else { 12901 }
12886 sub = particle->children->children; 12902 } else if ((particle->maxOccurs > 1)
12887 while (sub != NULL) { 12903 || (particle->minOccurs > 1)) {
12888 xmlSchemaBuildAContentModel(pctxt, 12904 xmlAutomataStatePtr tmp;
12889 » » » » (xmlSchemaParticlePtr) sub); 12905 int counter;
12890 sub = sub->next; 12906
12891 } 12907 pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
12892 if (particle->minOccurs == 0) { 12908 oldstate, NULL);
12893 xmlAutomataNewEpsilon(pctxt->am, oldstate, 12909 oldstate = pctxt->state;
12894 pctxt->state); 12910
12895 } 12911 counter = xmlAutomataNewCounter(pctxt->am,
12896 } 12912 particle->minOccurs - 1,
12897 } 12913 particle->maxOccurs - 1);
12898 break; 12914
12899 } 12915 sub = particle->children->children;
12916 while (sub != NULL) {
12917 tmp2 = xmlSchemaBuildAContentModel(pctxt,
12918 (xmlSchemaParticlePtr) sub);
12919 if (tmp2 != 1) ret = 0;
12920 sub = sub->next;
12921 }
12922 tmp = pctxt->state;
12923 xmlAutomataNewCountedTrans(pctxt->am,
12924 tmp, oldstate, counter);
12925 pctxt->state =
12926 xmlAutomataNewCounterTrans(pctxt->am, tmp, NULL,
12927 counter);
12928 if ((particle->minOccurs == 0) || (ret == 1)) {
12929 xmlAutomataNewEpsilon(pctxt->am,
12930 oldstate, pctxt->state);
12931 ret = 1;
12932 }
12933 } else {
12934 sub = particle->children->children;
12935 while (sub != NULL) {
12936 tmp2 = xmlSchemaBuildAContentModel(pctxt,
12937 (xmlSchemaParticlePtr) sub);
12938 if (tmp2 != 1) ret = 0;
12939 sub = sub->next;
12940 }
12941 if (particle->minOccurs == 0) {
12942 xmlAutomataNewEpsilon(pctxt->am, oldstate,
12943 pctxt->state);
12944 ret = 1;
12945 }
12946 }
12947 }
12948 break;
12949 }
12900 case XML_SCHEMA_TYPE_CHOICE:{ 12950 case XML_SCHEMA_TYPE_CHOICE:{
12901 xmlSchemaTreeItemPtr sub; 12951 xmlSchemaTreeItemPtr sub;
12902 xmlAutomataStatePtr start, end; 12952 xmlAutomataStatePtr start, end;
12903 12953
12904 start = pctxt->state; 12954 ret = 0;
12905 end = xmlAutomataNewState(pctxt->am); 12955 start = pctxt->state;
12906 12956 end = xmlAutomataNewState(pctxt->am);
12907 /* 12957
12908 * iterate over the subtypes and remerge the end with an 12958 /*
12909 * epsilon transition 12959 * iterate over the subtypes and remerge the end with an
12910 */ 12960 * epsilon transition
12911 if (particle->maxOccurs == 1) { 12961 */
12912 » » sub = particle->children->children; 12962 if (particle->maxOccurs == 1) {
12913 while (sub != NULL) { 12963 sub = particle->children->children;
12914 pctxt->state = start;
12915 xmlSchemaBuildAContentModel(pctxt,
12916 » » » (xmlSchemaParticlePtr) sub);
12917 xmlAutomataNewEpsilon(pctxt->am, pctxt->state, end);
12918 sub = sub->next;
12919 }
12920 } else {
12921 int counter;
12922 xmlAutomataStatePtr hop, base;
12923 int maxOccurs = particle->maxOccurs == UNBOUNDED ?
12924 UNBOUNDED : particle->maxOccurs - 1;
12925 int minOccurs =
12926 particle->minOccurs < 1 ? 0 : particle->minOccurs - 1;
12927
12928 /*
12929 * use a counter to keep track of the number of transtions
12930 * which went through the choice.
12931 */
12932 counter =
12933 xmlAutomataNewCounter(pctxt->am, minOccurs, maxOccurs);
12934 hop = xmlAutomataNewState(pctxt->am);
12935 base = xmlAutomataNewState(pctxt->am);
12936
12937 » » sub = particle->children->children;
12938 while (sub != NULL) {
12939 pctxt->state = base;
12940 xmlSchemaBuildAContentModel(pctxt,
12941 » » » (xmlSchemaParticlePtr) sub);
12942 xmlAutomataNewEpsilon(pctxt->am, pctxt->state, hop);
12943 sub = sub->next;
12944 }
12945 xmlAutomataNewEpsilon(pctxt->am, start, base);
12946 » » xmlAutomataNewCountedTrans(pctxt->am, hop, base, counter);
12947 xmlAutomataNewCounterTrans(pctxt->am, hop, end, counter);
12948 }
12949 if (particle->minOccurs == 0) {
12950 xmlAutomataNewEpsilon(pctxt->am, start, end);
12951 }
12952 pctxt->state = end;
12953 break;
12954 }
12955 case XML_SCHEMA_TYPE_ALL:{
12956 xmlAutomataStatePtr start;
12957 » » xmlSchemaParticlePtr sub;
12958 » » xmlSchemaElementPtr elemDecl;
12959 int lax;
12960
12961 » » sub = (xmlSchemaParticlePtr) particle->children->children;
12962 if (sub == NULL)
12963 break;
12964 start = pctxt->state;
12965 while (sub != NULL) { 12964 while (sub != NULL) {
12966 pctxt->state = start; 12965 pctxt->state = start;
12967 12966 tmp2 = xmlSchemaBuildAContentModel(pctxt,
12968 » » elemDecl = (xmlSchemaElementPtr) sub->children; 12967 (xmlSchemaParticlePtr) sub);
12969 » » if (elemDecl == NULL) { 12968 if (tmp2 == 1) ret = 1;
12970 » » » PERROR_INT("xmlSchemaBuildAContentModel", 12969 xmlAutomataNewEpsilon(pctxt->am, pctxt->state, end);
12971 » » » "<element> particle has no term"); 12970 sub = sub->next;
12972 » » » return; 12971 }
12973 » » }; 12972 } else {
12974 » » /* 12973 int counter;
12975 » » * NOTE: The {max occurs} of all the particles in the 12974 xmlAutomataStatePtr hop, base;
12976 » » * {particles} of the group must be 0 or 1; this is 12975 int maxOccurs = particle->maxOccurs == UNBOUNDED ?
12977 » » * already ensured during the parse of the content of 12976 UNBOUNDED : particle->maxOccurs - 1;
12978 » » * <all>. 12977 int minOccurs =
12979 » » */ 12978 particle->minOccurs < 1 ? 0 : particle->minOccurs - 1;
12980 » » if (elemDecl->flags & XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD) { 12979
12981 » » » int counter; 12980 /*
12982 12981 * use a counter to keep track of the number of transtions
12983 » » /* 12982 * which went through the choice.
12984 » » » * This is an abstract group, we need to share 12983 */
12985 » » » * the same counter for all the element transitions 12984 counter =
12986 » » » * derived from the group 12985 xmlAutomataNewCounter(pctxt->am, minOccurs, maxOccurs);
12987 » » » */ 12986 hop = xmlAutomataNewState(pctxt->am);
12988 » » » counter = xmlAutomataNewCounter(pctxt->am, 12987 base = xmlAutomataNewState(pctxt->am);
12989 » » » sub->minOccurs, sub->maxOccurs); 12988
12990 » » » xmlSchemaBuildContentModelForSubstGroup(pctxt, 12989 sub = particle->children->children;
12991 » » » » » sub, counter, pctxt->state); 12990 while (sub != NULL) {
12992 » » } else { 12991 pctxt->state = base;
12993 » » » if ((sub->minOccurs == 1) && 12992 tmp2 = xmlSchemaBuildAContentModel(pctxt,
12994 » » » (sub->maxOccurs == 1)) { 12993 (xmlSchemaParticlePtr) sub);
12995 » » » xmlAutomataNewOnceTrans2(pctxt->am, pctxt->state, 12994 if (tmp2 == 1) ret = 1;
12996 » » » » » » pctxt->state, 12995 xmlAutomataNewEpsilon(pctxt->am, pctxt->state, hop);
12997 » » » » » » elemDecl->name, 12996 sub = sub->next;
12998 » » » » » » elemDecl->targetNamespace, 12997 }
12999 » » » » » » 1, 1, elemDecl); 12998 xmlAutomataNewEpsilon(pctxt->am, start, base);
13000 » » » } else if ((sub->minOccurs == 0) && 12999 xmlAutomataNewCountedTrans(pctxt->am, hop, base, counter);
13001 » » » (sub->maxOccurs == 1)) { 13000 xmlAutomataNewCounterTrans(pctxt->am, hop, end, counter);
13002 13001 if (ret == 1)
13003 » » » xmlAutomataNewCountTrans2(pctxt->am, pctxt->state, 13002 xmlAutomataNewEpsilon(pctxt->am, base, end);
13004 » » » » » » pctxt->state, 13003 }
13005 » » » » » » elemDecl->name, 13004 if (particle->minOccurs == 0) {
13006 » » » » » » elemDecl->targetNamespace, 13005 xmlAutomataNewEpsilon(pctxt->am, start, end);
13007 » » » » » » 0, 13006 ret = 1;
13008 » » » » » » 1, 13007 }
13009 » » » » » » elemDecl); 13008 pctxt->state = end;
13010 » » » } 13009 break;
13011 » » } 13010 }
13012 sub = (xmlSchemaParticlePtr) sub->next; 13011 case XML_SCHEMA_TYPE_ALL:{
13013 } 13012 xmlAutomataStatePtr start, tmp;
13014 lax = particle->minOccurs == 0; 13013 xmlSchemaParticlePtr sub;
13015 pctxt->state = 13014 xmlSchemaElementPtr elemDecl;
13016 xmlAutomataNewAllTrans(pctxt->am, pctxt->state, NULL, lax); 13015
13016 ret = 1;
13017
13018 sub = (xmlSchemaParticlePtr) particle->children->children;
13019 if (sub == NULL)
13017 break; 13020 break;
13018 } 13021
13022 ret = 0;
13023
13024 start = pctxt->state;
13025 tmp = xmlAutomataNewState(pctxt->am);
13026 xmlAutomataNewEpsilon(pctxt->am, pctxt->state, tmp);
13027 pctxt->state = tmp;
13028 while (sub != NULL) {
13029 pctxt->state = tmp;
13030
13031 elemDecl = (xmlSchemaElementPtr) sub->children;
13032 if (elemDecl == NULL) {
13033 PERROR_INT("xmlSchemaBuildAContentModel",
13034 "<element> particle has no term");
13035 return(ret);
13036 };
13037 /*
13038 * NOTE: The {max occurs} of all the particles in the
13039 * {particles} of the group must be 0 or 1; this is
13040 * already ensured during the parse of the content of
13041 * <all>.
13042 */
13043 if (elemDecl->flags & XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD) {
13044 int counter;
13045
13046 /*
13047 * This is an abstract group, we need to share
13048 * the same counter for all the element transitions
13049 * derived from the group
13050 */
13051 counter = xmlAutomataNewCounter(pctxt->am,
13052 sub->minOccurs, sub->maxOccurs);
13053 xmlSchemaBuildContentModelForSubstGroup(pctxt,
13054 sub, counter, pctxt->state);
13055 } else {
13056 if ((sub->minOccurs == 1) &&
13057 (sub->maxOccurs == 1)) {
13058 xmlAutomataNewOnceTrans2(pctxt->am, pctxt->state,
13059 pctxt->state,
13060 elemDecl->name,
13061 elemDecl->targetNamespace,
13062 1, 1, elemDecl);
13063 } else if ((sub->minOccurs == 0) &&
13064 (sub->maxOccurs == 1)) {
13065
13066 xmlAutomataNewCountTrans2(pctxt->am, pctxt->state,
13067 pctxt->state,
13068 elemDecl->name,
13069 elemDecl->targetNamespace,
13070 0,
13071 1,
13072 elemDecl);
13073 }
13074 }
13075 sub = (xmlSchemaParticlePtr) sub->next;
13076 }
13077 pctxt->state =
13078 xmlAutomataNewAllTrans(pctxt->am, pctxt->state, NULL, 0);
13079 if (particle->minOccurs == 0) {
13080 xmlAutomataNewEpsilon(pctxt->am, start, pctxt->state);
13081 ret = 1;
13082 }
13083 break;
13084 }
13019 case XML_SCHEMA_TYPE_GROUP: 13085 case XML_SCHEMA_TYPE_GROUP:
13020 /* 13086 /*
13021 * If we hit a model group definition, then this means that 13087 * If we hit a model group definition, then this means that
13022 * it was empty, thus was not substituted for the containing 13088 * it was empty, thus was not substituted for the containing
13023 * model group. Just do nothing in this case. 13089 * model group. Just do nothing in this case.
13024 * TODO: But the group should be substituted and not occur at 13090 * TODO: But the group should be substituted and not occur at
13025 * all in the content model at this point. Fix this. 13091 * all in the content model at this point. Fix this.
13026 */ 13092 */
13093 ret = 1;
13027 break; 13094 break;
13028 default: 13095 default:
13029 xmlSchemaInternalErr2(ACTXT_CAST pctxt, 13096 xmlSchemaInternalErr2(ACTXT_CAST pctxt,
13030 "xmlSchemaBuildAContentModel", 13097 "xmlSchemaBuildAContentModel",
13031 "found unexpected term of type '%s' in content model", 13098 "found unexpected term of type '%s' in content model",
13032 WXS_ITEM_TYPE_NAME(particle->children), NULL); 13099 WXS_ITEM_TYPE_NAME(particle->children), NULL);
13033 return; 13100 return(ret);
13034 } 13101 }
13102 return(ret);
13035 } 13103 }
13036 13104
13037 /** 13105 /**
13038 * xmlSchemaBuildContentModel: 13106 * xmlSchemaBuildContentModel:
13039 * @ctxt: the schema parser context 13107 * @ctxt: the schema parser context
13040 * @type: the complex type definition 13108 * @type: the complex type definition
13041 * @name: the element name 13109 * @name: the element name
13042 * 13110 *
13043 * Builds the content model of the complex type. 13111 * Builds the content model of the complex type.
13044 */ 13112 */
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
13108 { 13176 {
13109 if ((ctxt == NULL) || (elemDecl == NULL) || 13177 if ((ctxt == NULL) || (elemDecl == NULL) ||
13110 ((elemDecl != NULL) && 13178 ((elemDecl != NULL) &&
13111 (elemDecl->flags & XML_SCHEMAS_ELEM_INTERNAL_RESOLVED))) 13179 (elemDecl->flags & XML_SCHEMAS_ELEM_INTERNAL_RESOLVED)))
13112 return; 13180 return;
13113 elemDecl->flags |= XML_SCHEMAS_ELEM_INTERNAL_RESOLVED; 13181 elemDecl->flags |= XML_SCHEMAS_ELEM_INTERNAL_RESOLVED;
13114 13182
13115 if ((elemDecl->subtypes == NULL) && (elemDecl->namedType != NULL)) { 13183 if ((elemDecl->subtypes == NULL) && (elemDecl->namedType != NULL)) {
13116 xmlSchemaTypePtr type; 13184 xmlSchemaTypePtr type;
13117 13185
13118 » /* (type definition) ... otherwise the type definition ·resolved· 13186 » /* (type definition) ... otherwise the type definition �resolved�
13119 » * to by the ·actual value· of the type [attribute] ... 13187 » * to by the �actual value� of the type [attribute] ...
13120 */ 13188 */
13121 type = xmlSchemaGetType(ctxt->schema, elemDecl->namedType, 13189 type = xmlSchemaGetType(ctxt->schema, elemDecl->namedType,
13122 elemDecl->namedTypeNs); 13190 elemDecl->namedTypeNs);
13123 if (type == NULL) { 13191 if (type == NULL) {
13124 xmlSchemaPResCompAttrErr(ctxt, 13192 xmlSchemaPResCompAttrErr(ctxt,
13125 XML_SCHEMAP_SRC_RESOLVE, 13193 XML_SCHEMAP_SRC_RESOLVE,
13126 WXS_BASIC_CAST elemDecl, elemDecl->node, 13194 WXS_BASIC_CAST elemDecl, elemDecl->node,
13127 "type", elemDecl->namedType, elemDecl->namedTypeNs, 13195 "type", elemDecl->namedType, elemDecl->namedTypeNs,
13128 XML_SCHEMA_TYPE_BASIC, "type definition"); 13196 XML_SCHEMA_TYPE_BASIC, "type definition");
13129 } else 13197 } else
(...skipping 17 matching lines...) Expand all
13147 } else { 13215 } else {
13148 xmlSchemaResolveElementReferences(substHead, ctxt); 13216 xmlSchemaResolveElementReferences(substHead, ctxt);
13149 /* 13217 /*
13150 * Set the "substitution group affiliation". 13218 * Set the "substitution group affiliation".
13151 * NOTE that now we use the "refDecl" field for this. 13219 * NOTE that now we use the "refDecl" field for this.
13152 */ 13220 */
13153 WXS_SUBST_HEAD(elemDecl) = substHead; 13221 WXS_SUBST_HEAD(elemDecl) = substHead;
13154 /* 13222 /*
13155 * The type definitions is set to: 13223 * The type definitions is set to:
13156 * SPEC "...the {type definition} of the element 13224 * SPEC "...the {type definition} of the element
13157 » * declaration ·resolved· to by the ·actual value· 13225 » * declaration �resolved� to by the �actual value�
13158 * of the substitutionGroup [attribute], if present" 13226 * of the substitutionGroup [attribute], if present"
13159 */ 13227 */
13160 if (elemDecl->subtypes == NULL) 13228 if (elemDecl->subtypes == NULL)
13161 elemDecl->subtypes = substHead->subtypes; 13229 elemDecl->subtypes = substHead->subtypes;
13162 } 13230 }
13163 } 13231 }
13164 /* 13232 /*
13165 * SPEC "The definition of anyType serves as the default type definition 13233 * SPEC "The definition of anyType serves as the default type definition
13166 * for element declarations whose XML representation does not specify one." 13234 * for element declarations whose XML representation does not specify one."
13167 */ 13235 */
(...skipping 17 matching lines...) Expand all
13185 static int 13253 static int
13186 xmlSchemaResolveUnionMemberTypes(xmlSchemaParserCtxtPtr ctxt, 13254 xmlSchemaResolveUnionMemberTypes(xmlSchemaParserCtxtPtr ctxt,
13187 xmlSchemaTypePtr type) 13255 xmlSchemaTypePtr type)
13188 { 13256 {
13189 13257
13190 xmlSchemaTypeLinkPtr link, lastLink, newLink; 13258 xmlSchemaTypeLinkPtr link, lastLink, newLink;
13191 xmlSchemaTypePtr memberType; 13259 xmlSchemaTypePtr memberType;
13192 13260
13193 /* 13261 /*
13194 * SPEC (1) "If the <union> alternative is chosen, then [Definition:] 13262 * SPEC (1) "If the <union> alternative is chosen, then [Definition:]
13195 * define the explicit members as the type definitions ·resolved· 13263 * define the explicit members as the type definitions �resolved�
13196 * to by the items in the ·actual value· of the memberTypes [attribute], 13264 * to by the items in the �actual value� of the memberTypes [attribute],
13197 * if any, followed by the type definitions corresponding to the 13265 * if any, followed by the type definitions corresponding to the
13198 * <simpleType>s among the [children] of <union>, if any." 13266 * <simpleType>s among the [children] of <union>, if any."
13199 */ 13267 */
13200 /* 13268 /*
13201 * Resolve references. 13269 * Resolve references.
13202 */ 13270 */
13203 link = type->memberTypes; 13271 link = type->memberTypes;
13204 lastLink = NULL; 13272 lastLink = NULL;
13205 while (link != NULL) { 13273 while (link != NULL) {
13206 const xmlChar *name, *nsName; 13274 const xmlChar *name, *nsName;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
13299 return (0); 13367 return (0);
13300 if (type->type == XML_SCHEMA_TYPE_BASIC) { 13368 if (type->type == XML_SCHEMA_TYPE_BASIC) {
13301 if (type->builtInType == valType) 13369 if (type->builtInType == valType)
13302 return(1); 13370 return(1);
13303 return (0); 13371 return (0);
13304 } else 13372 } else
13305 return(xmlSchemaIsDerivedFromBuiltInType(type->subtypes, valType)); 13373 return(xmlSchemaIsDerivedFromBuiltInType(type->subtypes, valType));
13306 13374
13307 return (0); 13375 return (0);
13308 } 13376 }
13309 #endif
13310 13377
13311 static xmlSchemaTypePtr 13378 static xmlSchemaTypePtr
13312 xmlSchemaQueryBuiltInType(xmlSchemaTypePtr type) 13379 xmlSchemaQueryBuiltInType(xmlSchemaTypePtr type)
13313 { 13380 {
13314 if (type == NULL) 13381 if (type == NULL)
13315 return (NULL); 13382 return (NULL);
13316 if (WXS_IS_COMPLEX(type)) 13383 if (WXS_IS_COMPLEX(type))
13317 return (NULL); 13384 return (NULL);
13318 if (type->type == XML_SCHEMA_TYPE_BASIC) 13385 if (type->type == XML_SCHEMA_TYPE_BASIC)
13319 return(type); 13386 return(type);
13320 return(xmlSchemaQueryBuiltInType(type->subtypes)); 13387 return(xmlSchemaQueryBuiltInType(type->subtypes));
13321 } 13388 }
13389 #endif
13322 13390
13323 /** 13391 /**
13324 * xmlSchemaGetPrimitiveType: 13392 * xmlSchemaGetPrimitiveType:
13325 * @type: the simpleType definition 13393 * @type: the simpleType definition
13326 * 13394 *
13327 * Returns the primitive type of the given type or 13395 * Returns the primitive type of the given type or
13328 * NULL in case of error. 13396 * NULL in case of error.
13329 */ 13397 */
13330 static xmlSchemaTypePtr 13398 static xmlSchemaTypePtr
13331 xmlSchemaGetPrimitiveType(xmlSchemaTypePtr type) 13399 xmlSchemaGetPrimitiveType(xmlSchemaTypePtr type)
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
13481 completeWild->nsSet = NULL; 13549 completeWild->nsSet = NULL;
13482 } 13550 }
13483 if (completeWild->negNsSet != NULL) { 13551 if (completeWild->negNsSet != NULL) {
13484 xmlFree(completeWild->negNsSet); 13552 xmlFree(completeWild->negNsSet);
13485 completeWild->negNsSet = NULL; 13553 completeWild->negNsSet = NULL;
13486 } 13554 }
13487 } 13555 }
13488 return (0); 13556 return (0);
13489 } 13557 }
13490 /* 13558 /*
13491 * 3 If both O1 and O2 are sets of (namespace names or ·absent·), 13559 * 3 If both O1 and O2 are sets of (namespace names or �absent�),
13492 * then the union of those sets must be the value. 13560 * then the union of those sets must be the value.
13493 */ 13561 */
13494 if ((completeWild->nsSet != NULL) && (curWild->nsSet != NULL)) { 13562 if ((completeWild->nsSet != NULL) && (curWild->nsSet != NULL)) {
13495 int found; 13563 int found;
13496 xmlSchemaWildcardNsPtr start; 13564 xmlSchemaWildcardNsPtr start;
13497 13565
13498 cur = curWild->nsSet; 13566 cur = curWild->nsSet;
13499 start = completeWild->nsSet; 13567 start = completeWild->nsSet;
13500 while (cur != NULL) { 13568 while (cur != NULL) {
13501 found = 0; 13569 found = 0;
(...skipping 13 matching lines...) Expand all
13515 tmp->next = completeWild->nsSet; 13583 tmp->next = completeWild->nsSet;
13516 completeWild->nsSet = tmp; 13584 completeWild->nsSet = tmp;
13517 } 13585 }
13518 cur = cur->next; 13586 cur = cur->next;
13519 } 13587 }
13520 13588
13521 return(0); 13589 return(0);
13522 } 13590 }
13523 /* 13591 /*
13524 * 4 If the two are negations of different values (namespace names 13592 * 4 If the two are negations of different values (namespace names
13525 * or ·absent·), then a pair of not and ·absent· must be the value. 13593 * or �absent�), then a pair of not and �absent� must be the value.
13526 */ 13594 */
13527 if ((completeWild->negNsSet != NULL) && 13595 if ((completeWild->negNsSet != NULL) &&
13528 (curWild->negNsSet != NULL) && 13596 (curWild->negNsSet != NULL) &&
13529 (completeWild->negNsSet->value != curWild->negNsSet->value)) { 13597 (completeWild->negNsSet->value != curWild->negNsSet->value)) {
13530 completeWild->negNsSet->value = NULL; 13598 completeWild->negNsSet->value = NULL;
13531 13599
13532 return(0); 13600 return(0);
13533 } 13601 }
13534 /* 13602 /*
13535 * 5. 13603 * 5.
(...skipping 21 matching lines...) Expand all
13557 else if (cur->value == curB->value) 13625 else if (cur->value == curB->value)
13558 nsFound = 1; 13626 nsFound = 1;
13559 if (nsFound && absentFound) 13627 if (nsFound && absentFound)
13560 break; 13628 break;
13561 cur = cur->next; 13629 cur = cur->next;
13562 } 13630 }
13563 13631
13564 if (nsFound && absentFound) { 13632 if (nsFound && absentFound) {
13565 /* 13633 /*
13566 * 5.1 If the set S includes both the negated namespace 13634 * 5.1 If the set S includes both the negated namespace
13567 » * name and ·absent·, then any must be the value. 13635 » * name and �absent�, then any must be the value.
13568 */ 13636 */
13569 completeWild->any = 1; 13637 completeWild->any = 1;
13570 if (completeWild->nsSet != NULL) { 13638 if (completeWild->nsSet != NULL) {
13571 xmlSchemaFreeWildcardNsSet(completeWild->nsSet); 13639 xmlSchemaFreeWildcardNsSet(completeWild->nsSet);
13572 completeWild->nsSet = NULL; 13640 completeWild->nsSet = NULL;
13573 } 13641 }
13574 if (completeWild->negNsSet != NULL) { 13642 if (completeWild->negNsSet != NULL) {
13575 xmlFree(completeWild->negNsSet); 13643 xmlFree(completeWild->negNsSet);
13576 completeWild->negNsSet = NULL; 13644 completeWild->negNsSet = NULL;
13577 } 13645 }
13578 } else if (nsFound && (!absentFound)) { 13646 } else if (nsFound && (!absentFound)) {
13579 /* 13647 /*
13580 * 5.2 If the set S includes the negated namespace name 13648 * 5.2 If the set S includes the negated namespace name
13581 » * but not ·absent·, then a pair of not and ·absent· must 13649 » * but not �absent�, then a pair of not and �absent� must
13582 * be the value. 13650 * be the value.
13583 */ 13651 */
13584 if (completeWild->nsSet != NULL) { 13652 if (completeWild->nsSet != NULL) {
13585 xmlSchemaFreeWildcardNsSet(completeWild->nsSet); 13653 xmlSchemaFreeWildcardNsSet(completeWild->nsSet);
13586 completeWild->nsSet = NULL; 13654 completeWild->nsSet = NULL;
13587 } 13655 }
13588 if (completeWild->negNsSet == NULL) { 13656 if (completeWild->negNsSet == NULL) {
13589 completeWild->negNsSet = xmlSchemaNewWildcardNsConstraint(ctxt); 13657 completeWild->negNsSet = xmlSchemaNewWildcardNsConstraint(ctxt);
13590 if (completeWild->negNsSet == NULL) 13658 if (completeWild->negNsSet == NULL)
13591 return (-1); 13659 return (-1);
13592 } 13660 }
13593 completeWild->negNsSet->value = NULL; 13661 completeWild->negNsSet->value = NULL;
13594 } else if ((!nsFound) && absentFound) { 13662 } else if ((!nsFound) && absentFound) {
13595 /* 13663 /*
13596 » * 5.3 If the set S includes ·absent· but not the negated 13664 » * 5.3 If the set S includes �absent� but not the negated
13597 * namespace name, then the union is not expressible. 13665 * namespace name, then the union is not expressible.
13598 */ 13666 */
13599 xmlSchemaPErr(ctxt, completeWild->node, 13667 xmlSchemaPErr(ctxt, completeWild->node,
13600 XML_SCHEMAP_UNION_NOT_EXPRESSIBLE, 13668 XML_SCHEMAP_UNION_NOT_EXPRESSIBLE,
13601 "The union of the wilcard is not expressible.\n", 13669 "The union of the wilcard is not expressible.\n",
13602 NULL, NULL); 13670 NULL, NULL);
13603 return(XML_SCHEMAP_UNION_NOT_EXPRESSIBLE); 13671 return(XML_SCHEMAP_UNION_NOT_EXPRESSIBLE);
13604 } else if ((!nsFound) && (!absentFound)) { 13672 } else if ((!nsFound) && (!absentFound)) {
13605 /* 13673 /*
13606 * 5.4 If the set S does not include either the negated namespace 13674 * 5.4 If the set S does not include either the negated namespace
13607 » * name or ·absent·, then whichever of O1 or O2 is a pair of not 13675 » * name or �absent�, then whichever of O1 or O2 is a pair of not
13608 * and a namespace name must be the value. 13676 * and a namespace name must be the value.
13609 */ 13677 */
13610 if (completeWild->negNsSet == NULL) { 13678 if (completeWild->negNsSet == NULL) {
13611 if (completeWild->nsSet != NULL) { 13679 if (completeWild->nsSet != NULL) {
13612 xmlSchemaFreeWildcardNsSet(completeWild->nsSet); 13680 xmlSchemaFreeWildcardNsSet(completeWild->nsSet);
13613 completeWild->nsSet = NULL; 13681 completeWild->nsSet = NULL;
13614 } 13682 }
13615 completeWild->negNsSet = xmlSchemaNewWildcardNsConstraint(ctxt); 13683 completeWild->negNsSet = xmlSchemaNewWildcardNsConstraint(ctxt);
13616 if (completeWild->negNsSet == NULL) 13684 if (completeWild->negNsSet == NULL)
13617 return (-1); 13685 return (-1);
(...skipping 13 matching lines...) Expand all
13631 (completeWild->nsSet != NULL))) { 13699 (completeWild->nsSet != NULL))) {
13632 13700
13633 if (completeWild->nsSet != NULL) { 13701 if (completeWild->nsSet != NULL) {
13634 cur = completeWild->nsSet; 13702 cur = completeWild->nsSet;
13635 } else { 13703 } else {
13636 cur = curWild->nsSet; 13704 cur = curWild->nsSet;
13637 } 13705 }
13638 while (cur != NULL) { 13706 while (cur != NULL) {
13639 if (cur->value == NULL) { 13707 if (cur->value == NULL) {
13640 /* 13708 /*
13641 » » * 6.1 If the set S includes ·absent·, then any must be the 13709 » » * 6.1 If the set S includes �absent�, then any must be the
13642 * value. 13710 * value.
13643 */ 13711 */
13644 completeWild->any = 1; 13712 completeWild->any = 1;
13645 if (completeWild->nsSet != NULL) { 13713 if (completeWild->nsSet != NULL) {
13646 xmlSchemaFreeWildcardNsSet(completeWild->nsSet); 13714 xmlSchemaFreeWildcardNsSet(completeWild->nsSet);
13647 completeWild->nsSet = NULL; 13715 completeWild->nsSet = NULL;
13648 } 13716 }
13649 if (completeWild->negNsSet != NULL) { 13717 if (completeWild->negNsSet != NULL) {
13650 xmlFree(completeWild->negNsSet); 13718 xmlFree(completeWild->negNsSet);
13651 completeWild->negNsSet = NULL; 13719 completeWild->negNsSet = NULL;
13652 } 13720 }
13653 return (0); 13721 return (0);
13654 } 13722 }
13655 cur = cur->next; 13723 cur = cur->next;
13656 } 13724 }
13657 if (completeWild->negNsSet == NULL) { 13725 if (completeWild->negNsSet == NULL) {
13658 /* 13726 /*
13659 » * 6.2 If the set S does not include ·absent·, then a pair of not 13727 » * 6.2 If the set S does not include �absent�, then a pair of not
13660 » * and ·absent· must be the value. 13728 » * and �absent� must be the value.
13661 */ 13729 */
13662 if (completeWild->nsSet != NULL) { 13730 if (completeWild->nsSet != NULL) {
13663 xmlSchemaFreeWildcardNsSet(completeWild->nsSet); 13731 xmlSchemaFreeWildcardNsSet(completeWild->nsSet);
13664 completeWild->nsSet = NULL; 13732 completeWild->nsSet = NULL;
13665 } 13733 }
13666 completeWild->negNsSet = xmlSchemaNewWildcardNsConstraint(ctxt); 13734 completeWild->negNsSet = xmlSchemaNewWildcardNsConstraint(ctxt);
13667 if (completeWild->negNsSet == NULL) 13735 if (completeWild->negNsSet == NULL)
13668 return (-1); 13736 return (-1);
13669 completeWild->negNsSet->value = NULL; 13737 completeWild->negNsSet->value = NULL;
13670 } 13738 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
13733 /* 13801 /*
13734 * 2 If either O1 or O2 is any, then the other must be the value. 13802 * 2 If either O1 or O2 is any, then the other must be the value.
13735 */ 13803 */
13736 if ((completeWild->any != curWild->any) && (completeWild->any)) { 13804 if ((completeWild->any != curWild->any) && (completeWild->any)) {
13737 if (xmlSchemaCloneWildcardNsConstraints(ctxt, completeWild, curWild) == -1) 13805 if (xmlSchemaCloneWildcardNsConstraints(ctxt, completeWild, curWild) == -1)
13738 return(-1); 13806 return(-1);
13739 return(0); 13807 return(0);
13740 } 13808 }
13741 /* 13809 /*
13742 * 3 If either O1 or O2 is a pair of not and a value (a namespace 13810 * 3 If either O1 or O2 is a pair of not and a value (a namespace
13743 * name or ·absent·) and the other is a set of (namespace names or 13811 * name or �absent�) and the other is a set of (namespace names or
13744 * ·absent·), then that set, minus the negated value if it was in 13812 * �absent�), then that set, minus the negated value if it was in
13745 * the set, minus ·absent· if it was in the set, must be the value. 13813 * the set, minus �absent� if it was in the set, must be the value.
13746 */ 13814 */
13747 if (((completeWild->negNsSet != NULL) && (curWild->nsSet != NULL)) || 13815 if (((completeWild->negNsSet != NULL) && (curWild->nsSet != NULL)) ||
13748 ((curWild->negNsSet != NULL) && (completeWild->nsSet != NULL))) { 13816 ((curWild->negNsSet != NULL) && (completeWild->nsSet != NULL))) {
13749 const xmlChar *neg; 13817 const xmlChar *neg;
13750 13818
13751 if (completeWild->nsSet == NULL) { 13819 if (completeWild->nsSet == NULL) {
13752 neg = completeWild->negNsSet->value; 13820 neg = completeWild->negNsSet->value;
13753 if (xmlSchemaCloneWildcardNsConstraints(ctxt, completeWild, curWild) == -1) 13821 if (xmlSchemaCloneWildcardNsConstraints(ctxt, completeWild, curWild) == -1)
13754 return(-1); 13822 return(-1);
13755 } else 13823 } else
(...skipping 28 matching lines...) Expand all
13784 break; 13852 break;
13785 } 13853 }
13786 prev = cur; 13854 prev = cur;
13787 cur = cur->next; 13855 cur = cur->next;
13788 } 13856 }
13789 } 13857 }
13790 13858
13791 return(0); 13859 return(0);
13792 } 13860 }
13793 /* 13861 /*
13794 * 4 If both O1 and O2 are sets of (namespace names or ·absent·), 13862 * 4 If both O1 and O2 are sets of (namespace names or �absent�),
13795 * then the intersection of those sets must be the value. 13863 * then the intersection of those sets must be the value.
13796 */ 13864 */
13797 if ((completeWild->nsSet != NULL) && (curWild->nsSet != NULL)) { 13865 if ((completeWild->nsSet != NULL) && (curWild->nsSet != NULL)) {
13798 int found; 13866 int found;
13799 13867
13800 cur = completeWild->nsSet; 13868 cur = completeWild->nsSet;
13801 prev = NULL; 13869 prev = NULL;
13802 while (cur != NULL) { 13870 while (cur != NULL) {
13803 found = 0; 13871 found = 0;
13804 curB = curWild->nsSet; 13872 curB = curWild->nsSet;
(...skipping 29 matching lines...) Expand all
13834 (completeWild->negNsSet->value != NULL) && 13902 (completeWild->negNsSet->value != NULL) &&
13835 (curWild->negNsSet->value != NULL)) { 13903 (curWild->negNsSet->value != NULL)) {
13836 13904
13837 xmlSchemaPErr(ctxt, completeWild->node, XML_SCHEMAP_INTERSECTION_NOT_EXP RESSIBLE, 13905 xmlSchemaPErr(ctxt, completeWild->node, XML_SCHEMAP_INTERSECTION_NOT_EXP RESSIBLE,
13838 "The intersection of the wilcard is not expressible.\n", 13906 "The intersection of the wilcard is not expressible.\n",
13839 NULL, NULL); 13907 NULL, NULL);
13840 return(XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE); 13908 return(XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE);
13841 } 13909 }
13842 /* 13910 /*
13843 * 6 If the one is a negation of a namespace name and the other 13911 * 6 If the one is a negation of a namespace name and the other
13844 * is a negation of ·absent·, then the one which is the negation 13912 * is a negation of �absent�, then the one which is the negation
13845 * of a namespace name must be the value. 13913 * of a namespace name must be the value.
13846 */ 13914 */
13847 if ((completeWild->negNsSet != NULL) && (curWild->negNsSet != NULL) && 13915 if ((completeWild->negNsSet != NULL) && (curWild->negNsSet != NULL) &&
13848 (completeWild->negNsSet->value != curWild->negNsSet->value) && 13916 (completeWild->negNsSet->value != curWild->negNsSet->value) &&
13849 (completeWild->negNsSet->value == NULL)) { 13917 (completeWild->negNsSet->value == NULL)) {
13850 completeWild->negNsSet->value = curWild->negNsSet->value; 13918 completeWild->negNsSet->value = curWild->negNsSet->value;
13851 } 13919 }
13852 return(0); 13920 return(0);
13853 } 13921 }
13854 13922
(...skipping 11 matching lines...) Expand all
13866 static int 13934 static int
13867 xmlSchemaCheckCOSNSSubset(xmlSchemaWildcardPtr sub, 13935 xmlSchemaCheckCOSNSSubset(xmlSchemaWildcardPtr sub,
13868 xmlSchemaWildcardPtr super) 13936 xmlSchemaWildcardPtr super)
13869 { 13937 {
13870 /* 13938 /*
13871 * 1 super must be any. 13939 * 1 super must be any.
13872 */ 13940 */
13873 if (super->any) 13941 if (super->any)
13874 return (0); 13942 return (0);
13875 /* 13943 /*
13876 * 2.1 sub must be a pair of not and a namespace name or ·absent·. 13944 * 2.1 sub must be a pair of not and a namespace name or �absent�.
13877 * 2.2 super must be a pair of not and the same value. 13945 * 2.2 super must be a pair of not and the same value.
13878 */ 13946 */
13879 if ((sub->negNsSet != NULL) && 13947 if ((sub->negNsSet != NULL) &&
13880 (super->negNsSet != NULL) && 13948 (super->negNsSet != NULL) &&
13881 (sub->negNsSet->value == sub->negNsSet->value)) 13949 (sub->negNsSet->value == sub->negNsSet->value))
13882 return (0); 13950 return (0);
13883 /* 13951 /*
13884 * 3.1 sub must be a set whose members are either namespace names or ·absent· . 13952 * 3.1 sub must be a set whose members are either namespace names or �absen t�.
13885 */ 13953 */
13886 if (sub->nsSet != NULL) { 13954 if (sub->nsSet != NULL) {
13887 /* 13955 /*
13888 * 3.2.1 super must be the same set or a superset thereof. 13956 * 3.2.1 super must be the same set or a superset thereof.
13889 */ 13957 */
13890 if (super->nsSet != NULL) { 13958 if (super->nsSet != NULL) {
13891 xmlSchemaWildcardNsPtr cur, curB; 13959 xmlSchemaWildcardNsPtr cur, curB;
13892 int found = 0; 13960 int found = 0;
13893 13961
13894 cur = sub->nsSet; 13962 cur = sub->nsSet;
(...skipping 10 matching lines...) Expand all
13905 if (!found) 13973 if (!found)
13906 return (1); 13974 return (1);
13907 cur = cur->next; 13975 cur = cur->next;
13908 } 13976 }
13909 if (found) 13977 if (found)
13910 return (0); 13978 return (0);
13911 } else if (super->negNsSet != NULL) { 13979 } else if (super->negNsSet != NULL) {
13912 xmlSchemaWildcardNsPtr cur; 13980 xmlSchemaWildcardNsPtr cur;
13913 /* 13981 /*
13914 * 3.2.2 super must be a pair of not and a namespace name or 13982 * 3.2.2 super must be a pair of not and a namespace name or
13915 » * ·absent· and that value must not be in sub's set. 13983 » * �absent� and that value must not be in sub's set.
13916 */ 13984 */
13917 cur = sub->nsSet; 13985 cur = sub->nsSet;
13918 while (cur != NULL) { 13986 while (cur != NULL) {
13919 if (cur->value == super->negNsSet->value) 13987 if (cur->value == super->negNsSet->value)
13920 return (1); 13988 return (1);
13921 cur = cur->next; 13989 cur = cur->next;
13922 } 13990 }
13923 return (0); 13991 return (0);
13924 } 13992 }
13925 } 13993 }
13926 return (1); 13994 return (1);
13927 } 13995 }
13928 13996
13929 static int 13997 static int
13930 xmlSchemaGetEffectiveValueConstraint(xmlSchemaAttributeUsePtr attruse, 13998 xmlSchemaGetEffectiveValueConstraint(xmlSchemaAttributeUsePtr attruse,
13931 int *fixed, 13999 int *fixed,
13932 const xmlChar **value, 14000 const xmlChar **value,
13933 xmlSchemaValPtr *val) 14001 xmlSchemaValPtr *val)
13934 { 14002 {
13935 *fixed = 0; 14003 *fixed = 0;
13936 *value = NULL; 14004 *value = NULL;
13937 if (val != 0) 14005 if (val != 0)
13938 *val = NULL; 14006 *val = NULL;
13939 14007
13940 if (attruse->defValue != NULL) {» 14008 if (attruse->defValue != NULL) {
13941 *value = attruse->defValue; 14009 *value = attruse->defValue;
13942 if (val != NULL) 14010 if (val != NULL)
13943 *val = attruse->defVal; 14011 *val = attruse->defVal;
13944 if (attruse->flags & XML_SCHEMA_ATTR_USE_FIXED) 14012 if (attruse->flags & XML_SCHEMA_ATTR_USE_FIXED)
13945 *fixed = 1; 14013 *fixed = 1;
13946 return(1); 14014 return(1);
13947 } else if ((attruse->attrDecl != NULL) && 14015 } else if ((attruse->attrDecl != NULL) &&
13948 (attruse->attrDecl->defValue != NULL)) { 14016 (attruse->attrDecl->defValue != NULL)) {
13949 *value = attruse->attrDecl->defValue; 14017 *value = attruse->attrDecl->defValue;
13950 if (val != NULL) 14018 if (val != NULL)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
14010 */ 14078 */
14011 static int 14079 static int
14012 xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt, 14080 xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt,
14013 int action, 14081 int action,
14014 xmlSchemaBasicItemPtr item, 14082 xmlSchemaBasicItemPtr item,
14015 xmlSchemaBasicItemPtr baseItem, 14083 xmlSchemaBasicItemPtr baseItem,
14016 xmlSchemaItemListPtr uses, 14084 xmlSchemaItemListPtr uses,
14017 xmlSchemaItemListPtr baseUses, 14085 xmlSchemaItemListPtr baseUses,
14018 xmlSchemaWildcardPtr wild, 14086 xmlSchemaWildcardPtr wild,
14019 xmlSchemaWildcardPtr baseWild) 14087 xmlSchemaWildcardPtr baseWild)
14020 { 14088 {
14021 xmlSchemaAttributeUsePtr cur = NULL, bcur; 14089 xmlSchemaAttributeUsePtr cur = NULL, bcur;
14022 int i, j, found; /* err = 0; */ 14090 int i, j, found; /* err = 0; */
14023 const xmlChar *bEffValue; 14091 const xmlChar *bEffValue;
14024 int effFixed; 14092 int effFixed;
14025 14093
14026 if (uses != NULL) { 14094 if (uses != NULL) {
14027 for (i = 0; i < uses->nbItems; i++) { 14095 for (i = 0; i < uses->nbItems; i++) {
14028 cur = uses->items[i]; 14096 cur = uses->items[i];
14029 found = 0; 14097 found = 0;
14030 if (baseUses == NULL) 14098 if (baseUses == NULL)
14031 goto not_found; 14099 goto not_found;
14032 for (j = 0; j < baseUses->nbItems; j++) { 14100 for (j = 0; j < baseUses->nbItems; j++) {
14033 » » bcur = baseUses->items[j];» 14101 » » bcur = baseUses->items[j];
14034 if ((WXS_ATTRUSE_DECL_NAME(cur) == 14102 if ((WXS_ATTRUSE_DECL_NAME(cur) ==
14035 WXS_ATTRUSE_DECL_NAME(bcur)) && 14103 WXS_ATTRUSE_DECL_NAME(bcur)) &&
14036 (WXS_ATTRUSE_DECL_TNS(cur) == 14104 (WXS_ATTRUSE_DECL_TNS(cur) ==
14037 WXS_ATTRUSE_DECL_TNS(bcur))) 14105 WXS_ATTRUSE_DECL_TNS(bcur)))
14038 { 14106 {
14039 /* 14107 /*
14040 * (2.1) "If there is an attribute use in the {attribute 14108 * (2.1) "If there is an attribute use in the {attribute
14041 * uses} of the {base type definition} (call this B) whose 14109 * uses} of the {base type definition} (call this B) whose
14042 * {attribute declaration} has the same {name} and {target 14110 * {attribute declaration} has the same {name} and {target
14043 * namespace}, then all of the following must be true:" 14111 * namespace}, then all of the following must be true:"
14044 */ 14112 */
14045 found = 1; 14113 found = 1;
14046 » » 14114
14047 if ((cur->occurs == XML_SCHEMAS_ATTR_USE_OPTIONAL) && 14115 if ((cur->occurs == XML_SCHEMAS_ATTR_USE_OPTIONAL) &&
14048 (bcur->occurs == XML_SCHEMAS_ATTR_USE_REQUIRED)) 14116 (bcur->occurs == XML_SCHEMAS_ATTR_USE_REQUIRED))
14049 { 14117 {
14050 xmlChar *str = NULL; 14118 xmlChar *str = NULL;
14051 /* 14119 /*
14052 * (2.1.1) "one of the following must be true:" 14120 * (2.1.1) "one of the following must be true:"
14053 * (2.1.1.1) "B's {required} is false." 14121 * (2.1.1.1) "B's {required} is false."
14054 * (2.1.1.2) "R's {required} is true." 14122 * (2.1.1.2) "R's {required} is true."
14055 */ 14123 */
14056 xmlSchemaPAttrUseErr4(pctxt, 14124 xmlSchemaPAttrUseErr4(pctxt,
14057 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1, 14125 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1,
14058 WXS_ITEM_NODE(item), item, cur, 14126 WXS_ITEM_NODE(item), item, cur,
14059 "The 'optional' attribute use is inconsistent " 14127 "The 'optional' attribute use is inconsistent "
14060 "with the corresponding 'required' attribute use of " 14128 "with the corresponding 'required' attribute use of "
14061 "the %s %s", 14129 "the %s %s",
14062 WXS_ACTION_STR(action), 14130 WXS_ACTION_STR(action),
14063 xmlSchemaGetComponentDesignation(&str, baseItem), 14131 xmlSchemaGetComponentDesignation(&str, baseItem),
14064 NULL, NULL); 14132 NULL, NULL);
14065 FREE_AND_NULL(str); 14133 FREE_AND_NULL(str);
14066 /* err = pctxt->err; */ 14134 /* err = pctxt->err; */
14067 } else if (xmlSchemaCheckCOSSTDerivedOK(ACTXT_CAST pctxt, 14135 } else if (xmlSchemaCheckCOSSTDerivedOK(ACTXT_CAST pctxt,
14068 WXS_ATTRUSE_TYPEDEF(cur), 14136 WXS_ATTRUSE_TYPEDEF(cur),
14069 WXS_ATTRUSE_TYPEDEF(bcur), 0) != 0) 14137 WXS_ATTRUSE_TYPEDEF(bcur), 0) != 0)
14070 { 14138 {
14071 xmlChar *strA = NULL, *strB = NULL, *strC = NULL; 14139 xmlChar *strA = NULL, *strB = NULL, *strC = NULL;
14072 » » » 14140
14073 /* 14141 /*
14074 * SPEC (2.1.2) "R's {attribute declaration}'s 14142 * SPEC (2.1.2) "R's {attribute declaration}'s
14075 * {type definition} must be validly derived from 14143 * {type definition} must be validly derived from
14076 * B's {type definition} given the empty set as 14144 * B's {type definition} given the empty set as
14077 » » » * defined in Type Derivation OK (Simple) (§3.14.6)." 14145 » » » * defined in Type Derivation OK (Simple) (�3.14.6)."
14078 */ 14146 */
14079 xmlSchemaPAttrUseErr4(pctxt, 14147 xmlSchemaPAttrUseErr4(pctxt,
14080 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2, 14148 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2,
14081 WXS_ITEM_NODE(item), item, cur, 14149 WXS_ITEM_NODE(item), item, cur,
14082 "The attribute declaration's %s " 14150 "The attribute declaration's %s "
14083 "is not validly derived from " 14151 "is not validly derived from "
14084 "the corresponding %s of the " 14152 "the corresponding %s of the "
14085 "attribute declaration in the %s %s", 14153 "attribute declaration in the %s %s",
14086 xmlSchemaGetComponentDesignation(&strA, 14154 xmlSchemaGetComponentDesignation(&strA,
14087 WXS_ATTRUSE_TYPEDEF(cur)), 14155 WXS_ATTRUSE_TYPEDEF(cur)),
(...skipping 11 matching lines...) Expand all
14099 * 2.1.3 [Definition:] Let the effective value 14167 * 2.1.3 [Definition:] Let the effective value
14100 * constraint of an attribute use be its {value 14168 * constraint of an attribute use be its {value
14101 * constraint}, if present, otherwise its {attribute 14169 * constraint}, if present, otherwise its {attribute
14102 * declaration}'s {value constraint} . 14170 * declaration}'s {value constraint} .
14103 */ 14171 */
14104 xmlSchemaGetEffectiveValueConstraint(bcur, 14172 xmlSchemaGetEffectiveValueConstraint(bcur,
14105 &effFixed, &bEffValue, NULL); 14173 &effFixed, &bEffValue, NULL);
14106 /* 14174 /*
14107 * 2.1.3 ... one of the following must be true 14175 * 2.1.3 ... one of the following must be true
14108 * 14176 *
14109 » » » * 2.1.3.1 B's ·effective value constraint· is 14177 » » » * 2.1.3.1 B's �effective value constraint� is
14110 » » » * ·absent· or default. 14178 » » » * �absent� or default.
14111 */ 14179 */
14112 if ((bEffValue != NULL) && 14180 if ((bEffValue != NULL) &&
14113 (effFixed == 1)) { 14181 (effFixed == 1)) {
14114 const xmlChar *rEffValue = NULL; 14182 const xmlChar *rEffValue = NULL;
14115 » » » 14183
14116 xmlSchemaGetEffectiveValueConstraint(bcur, 14184 xmlSchemaGetEffectiveValueConstraint(bcur,
14117 &effFixed, &rEffValue, NULL); 14185 &effFixed, &rEffValue, NULL);
14118 /* 14186 /*
14119 » » » * 2.1.3.2 R's ·effective value constraint· is 14187 » » » * 2.1.3.2 R's �effective value constraint� is
14120 * fixed with the same string as B's. 14188 * fixed with the same string as B's.
14121 * MAYBE TODO: Compare the computed values. 14189 * MAYBE TODO: Compare the computed values.
14122 * Hmm, it says "same string" so 14190 * Hmm, it says "same string" so
14123 * string-equality might really be sufficient. 14191 * string-equality might really be sufficient.
14124 */ 14192 */
14125 if ((effFixed == 0) || 14193 if ((effFixed == 0) ||
14126 (! WXS_ARE_DEFAULT_STR_EQUAL(rEffValue, bEffValu e))) 14194 (! WXS_ARE_DEFAULT_STR_EQUAL(rEffValue, bEffValu e)))
14127 { 14195 {
14128 xmlChar *str = NULL; 14196 xmlChar *str = NULL;
14129 » » » » 14197
14130 xmlSchemaPAttrUseErr4(pctxt, 14198 xmlSchemaPAttrUseErr4(pctxt,
14131 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3, 14199 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3,
14132 WXS_ITEM_NODE(item), item, cur, 14200 WXS_ITEM_NODE(item), item, cur,
14133 "The effective value constraint of the " 14201 "The effective value constraint of the "
14134 "attribute use is inconsistent with " 14202 "attribute use is inconsistent with "
14135 "its correspondent in the %s %s", 14203 "its correspondent in the %s %s",
14136 WXS_ACTION_STR(action), 14204 WXS_ACTION_STR(action),
14137 xmlSchemaGetComponentDesignation(&str, 14205 xmlSchemaGetComponentDesignation(&str,
14138 baseItem), 14206 baseItem),
14139 NULL, NULL); 14207 NULL, NULL);
14140 FREE_AND_NULL(str); 14208 FREE_AND_NULL(str);
14141 /* err = pctxt->err; */ 14209 /* err = pctxt->err; */
14142 } 14210 }
14143 } 14211 }
14144 } 14212 }
14145 break; 14213 break;
14146 } 14214 }
14147 } 14215 }
14148 not_found:» 14216 not_found:
14149 if (!found) { 14217 if (!found) {
14150 /* 14218 /*
14151 * (2.2) "otherwise the {base type definition} must have an 14219 * (2.2) "otherwise the {base type definition} must have an
14152 * {attribute wildcard} and the {target namespace} of the 14220 * {attribute wildcard} and the {target namespace} of the
14153 » » * R's {attribute declaration} must be ·valid· with respect 14221 » » * R's {attribute declaration} must be �valid� with respect
14154 * to that wildcard, as defined in Wildcard allows Namespace 14222 * to that wildcard, as defined in Wildcard allows Namespace
14155 » » * Name (§3.10.4)." 14223 » » * Name (�3.10.4)."
14156 */ 14224 */
14157 if ((baseWild == NULL) || 14225 if ((baseWild == NULL) ||
14158 (xmlSchemaCheckCVCWildcardNamespace(baseWild, 14226 (xmlSchemaCheckCVCWildcardNamespace(baseWild,
14159 (WXS_ATTRUSE_DECL(cur))->targetNamespace) != 0)) 14227 (WXS_ATTRUSE_DECL(cur))->targetNamespace) != 0))
14160 { 14228 {
14161 xmlChar *str = NULL; 14229 xmlChar *str = NULL;
14162 » » 14230
14163 xmlSchemaPAttrUseErr4(pctxt, 14231 xmlSchemaPAttrUseErr4(pctxt,
14164 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2, 14232 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2,
14165 WXS_ITEM_NODE(item), item, cur, 14233 WXS_ITEM_NODE(item), item, cur,
14166 "Neither a matching attribute use, " 14234 "Neither a matching attribute use, "
14167 "nor a matching wildcard exists in the %s %s", 14235 "nor a matching wildcard exists in the %s %s",
14168 WXS_ACTION_STR(action), 14236 WXS_ACTION_STR(action),
14169 xmlSchemaGetComponentDesignation(&str, baseItem), 14237 xmlSchemaGetComponentDesignation(&str, baseItem),
14170 NULL, NULL); 14238 NULL, NULL);
14171 FREE_AND_NULL(str); 14239 FREE_AND_NULL(str);
14172 /* err = pctxt->err; */ 14240 /* err = pctxt->err; */
14173 } 14241 }
14174 } 14242 }
14175 } 14243 }
14176 } 14244 }
14177 /* 14245 /*
14178 * SPEC derivation-ok-restriction (3): 14246 * SPEC derivation-ok-restriction (3):
14179 * (3) "For each attribute use in the {attribute uses} of the {base type 14247 * (3) "For each attribute use in the {attribute uses} of the {base type
14180 * definition} whose {required} is true, there must be an attribute 14248 * definition} whose {required} is true, there must be an attribute
14181 * use with an {attribute declaration} with the same {name} and 14249 * use with an {attribute declaration} with the same {name} and
14182 * {target namespace} as its {attribute declaration} in the {attribute 14250 * {target namespace} as its {attribute declaration} in the {attribute
14183 * uses} of the complex type definition itself whose {required} is true. 14251 * uses} of the complex type definition itself whose {required} is true.
14184 */ 14252 */
14185 if (baseUses != NULL) { 14253 if (baseUses != NULL) {
14186 for (j = 0; j < baseUses->nbItems; j++) { 14254 for (j = 0; j < baseUses->nbItems; j++) {
14187 bcur = baseUses->items[j]; 14255 bcur = baseUses->items[j];
14188 if (bcur->occurs != XML_SCHEMAS_ATTR_USE_REQUIRED) 14256 if (bcur->occurs != XML_SCHEMAS_ATTR_USE_REQUIRED)
14189 continue; 14257 continue;
14190 found = 0; 14258 found = 0;
14191 if (uses != NULL) { 14259 if (uses != NULL) {
14192 for (i = 0; i < uses->nbItems; i++) { 14260 for (i = 0; i < uses->nbItems; i++) {
14193 » » cur = uses->items[i];» 14261 » » cur = uses->items[i];
14194 if ((WXS_ATTRUSE_DECL_NAME(cur) == 14262 if ((WXS_ATTRUSE_DECL_NAME(cur) ==
14195 WXS_ATTRUSE_DECL_NAME(bcur)) && 14263 WXS_ATTRUSE_DECL_NAME(bcur)) &&
14196 (WXS_ATTRUSE_DECL_TNS(cur) == 14264 (WXS_ATTRUSE_DECL_TNS(cur) ==
14197 WXS_ATTRUSE_DECL_TNS(bcur))) { 14265 WXS_ATTRUSE_DECL_TNS(bcur))) {
14198 found = 1; 14266 found = 1;
14199 break; 14267 break;
14200 } 14268 }
14201 } 14269 }
14202 } 14270 }
14203 if (!found) { 14271 if (!found) {
14204 xmlChar *strA = NULL, *strB = NULL; 14272 xmlChar *strA = NULL, *strB = NULL;
14205 » » 14273
14206 xmlSchemaCustomErr4(ACTXT_CAST pctxt, 14274 xmlSchemaCustomErr4(ACTXT_CAST pctxt,
14207 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3, 14275 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3,
14208 NULL, item, 14276 NULL, item,
14209 "A matching attribute use for the " 14277 "A matching attribute use for the "
14210 "'required' %s of the %s %s is missing", 14278 "'required' %s of the %s %s is missing",
14211 xmlSchemaGetComponentDesignation(&strA, bcur), 14279 xmlSchemaGetComponentDesignation(&strA, bcur),
14212 WXS_ACTION_STR(action), 14280 WXS_ACTION_STR(action),
14213 xmlSchemaGetComponentDesignation(&strB, baseItem), 14281 xmlSchemaGetComponentDesignation(&strB, baseItem),
14214 NULL); 14282 NULL);
14215 FREE_AND_NULL(strA); 14283 FREE_AND_NULL(strA);
14216 FREE_AND_NULL(strB); 14284 FREE_AND_NULL(strB);
14217 } 14285 }
14218 } 14286 }
14219 } 14287 }
14220 /* 14288 /*
14221 * derivation-ok-restriction (4) 14289 * derivation-ok-restriction (4)
14222 */ 14290 */
14223 if (wild != NULL) { 14291 if (wild != NULL) {
14224 /* 14292 /*
14225 * (4) "If there is an {attribute wildcard}, all of the 14293 * (4) "If there is an {attribute wildcard}, all of the
14226 * following must be true:" 14294 * following must be true:"
14227 » */ 14295 » */
14228 if (baseWild == NULL) { 14296 if (baseWild == NULL) {
14229 xmlChar *str = NULL; 14297 xmlChar *str = NULL;
14230 14298
14231 /* 14299 /*
14232 * (4.1) "The {base type definition} must also have one." 14300 * (4.1) "The {base type definition} must also have one."
14233 » */» 14301 » */
14234 xmlSchemaCustomErr4(ACTXT_CAST pctxt, 14302 xmlSchemaCustomErr4(ACTXT_CAST pctxt,
14235 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1, 14303 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1,
14236 NULL, item, 14304 NULL, item,
14237 "The %s has an attribute wildcard, " 14305 "The %s has an attribute wildcard, "
14238 "but the %s %s '%s' does not have one", 14306 "but the %s %s '%s' does not have one",
14239 » » WXS_ITEM_TYPE_NAME(item),» » 14307 » » WXS_ITEM_TYPE_NAME(item),
14240 WXS_ACTION_STR(action), 14308 WXS_ACTION_STR(action),
14241 WXS_ITEM_TYPE_NAME(baseItem), 14309 WXS_ITEM_TYPE_NAME(baseItem),
14242 xmlSchemaGetComponentQName(&str, baseItem)); 14310 xmlSchemaGetComponentQName(&str, baseItem));
14243 FREE_AND_NULL(str); 14311 FREE_AND_NULL(str);
14244 return(pctxt->err); 14312 return(pctxt->err);
14245 } else if ((baseWild->any == 0) && 14313 } else if ((baseWild->any == 0) &&
14246 xmlSchemaCheckCOSNSSubset(wild, baseWild)) 14314 xmlSchemaCheckCOSNSSubset(wild, baseWild))
14247 { 14315 {
14248 xmlChar *str = NULL; 14316 xmlChar *str = NULL;
14249 /* 14317 /*
14250 * (4.2) "The complex type definition's {attribute wildcard}'s 14318 * (4.2) "The complex type definition's {attribute wildcard}'s
14251 * {namespace constraint} must be a subset of the {base type 14319 * {namespace constraint} must be a subset of the {base type
14252 * definition}'s {attribute wildcard}'s {namespace constraint}, 14320 * definition}'s {attribute wildcard}'s {namespace constraint},
14253 » * as defined by Wildcard Subset (§3.10.6)." 14321 » * as defined by Wildcard Subset (�3.10.6)."
14254 */ 14322 */
14255 xmlSchemaCustomErr4(ACTXT_CAST pctxt, 14323 xmlSchemaCustomErr4(ACTXT_CAST pctxt,
14256 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2, 14324 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2,
14257 NULL, item, 14325 NULL, item,
14258 "The attribute wildcard is not a valid " 14326 "The attribute wildcard is not a valid "
14259 "subset of the wildcard in the %s %s '%s'", 14327 "subset of the wildcard in the %s %s '%s'",
14260 WXS_ACTION_STR(action), 14328 WXS_ACTION_STR(action),
14261 WXS_ITEM_TYPE_NAME(baseItem), 14329 WXS_ITEM_TYPE_NAME(baseItem),
14262 xmlSchemaGetComponentQName(&str, baseItem), 14330 xmlSchemaGetComponentQName(&str, baseItem),
14263 NULL); 14331 NULL);
14264 FREE_AND_NULL(str); 14332 FREE_AND_NULL(str);
14265 return(pctxt->err); 14333 return(pctxt->err);
14266 } 14334 }
14267 » /* 4.3 Unless the {base type definition} is the ·ur-type 14335 » /* 4.3 Unless the {base type definition} is the �ur-type
14268 » * definition·, the complex type definition's {attribute 14336 » * definition�, the complex type definition's {attribute
14269 * wildcard}'s {process contents} must be identical to or 14337 * wildcard}'s {process contents} must be identical to or
14270 * stronger than the {base type definition}'s {attribute 14338 * stronger than the {base type definition}'s {attribute
14271 * wildcard}'s {process contents}, where strict is stronger 14339 * wildcard}'s {process contents}, where strict is stronger
14272 * than lax is stronger than skip. 14340 * than lax is stronger than skip.
14273 */ 14341 */
14274 if ((! WXS_IS_ANYTYPE(baseItem)) && 14342 if ((! WXS_IS_ANYTYPE(baseItem)) &&
14275 (wild->processContents < baseWild->processContents)) { 14343 (wild->processContents < baseWild->processContents)) {
14276 xmlChar *str = NULL; 14344 xmlChar *str = NULL;
14277 xmlSchemaCustomErr4(ACTXT_CAST pctxt, 14345 xmlSchemaCustomErr4(ACTXT_CAST pctxt,
14278 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3, 14346 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3,
(...skipping 30 matching lines...) Expand all
14309 * ATTENTION TODO: Experimantally this uses pointer comparisons for 14377 * ATTENTION TODO: Experimantally this uses pointer comparisons for
14310 * strings, so recheck this if we start to hardcode some schemata, since 14378 * strings, so recheck this if we start to hardcode some schemata, since
14311 * they might not be in the same dict. 14379 * they might not be in the same dict.
14312 * NOTE: It is allowed to "extend" the xs:anyType type. 14380 * NOTE: It is allowed to "extend" the xs:anyType type.
14313 */ 14381 */
14314 static int 14382 static int
14315 xmlSchemaFixupTypeAttributeUses(xmlSchemaParserCtxtPtr pctxt, 14383 xmlSchemaFixupTypeAttributeUses(xmlSchemaParserCtxtPtr pctxt,
14316 xmlSchemaTypePtr type) 14384 xmlSchemaTypePtr type)
14317 { 14385 {
14318 xmlSchemaTypePtr baseType = NULL; 14386 xmlSchemaTypePtr baseType = NULL;
14319 xmlSchemaAttributeUsePtr use; 14387 xmlSchemaAttributeUsePtr use;
14320 xmlSchemaItemListPtr uses, baseUses, prohibs = NULL; 14388 xmlSchemaItemListPtr uses, baseUses, prohibs = NULL;
14321 14389
14322 if (type->baseType == NULL) { 14390 if (type->baseType == NULL) {
14323 PERROR_INT("xmlSchemaFixupTypeAttributeUses", 14391 PERROR_INT("xmlSchemaFixupTypeAttributeUses",
14324 "no base type"); 14392 "no base type");
14325 return (-1); 14393 return (-1);
14326 } 14394 }
14327 baseType = type->baseType; 14395 baseType = type->baseType;
14328 if (WXS_IS_TYPE_NOT_FIXED(baseType)) 14396 if (WXS_IS_TYPE_NOT_FIXED(baseType))
14329 if (xmlSchemaTypeFixup(baseType, ACTXT_CAST pctxt) == -1) 14397 if (xmlSchemaTypeFixup(baseType, ACTXT_CAST pctxt) == -1)
14330 return(-1); 14398 return(-1);
14331 14399
14332 uses = type->attrUses; 14400 uses = type->attrUses;
14333 baseUses = baseType->attrUses; 14401 baseUses = baseType->attrUses;
14334 /* 14402 /*
14335 * Expand attribute group references. And build the 'complete' 14403 * Expand attribute group references. And build the 'complete'
14336 * wildcard, i.e. intersect multiple wildcards. 14404 * wildcard, i.e. intersect multiple wildcards.
14337 * Move attribute prohibitions into a separate list. 14405 * Move attribute prohibitions into a separate list.
14338 */ 14406 */
14339 if (uses != NULL) {» 14407 if (uses != NULL) {
14340 if (WXS_IS_RESTRICTION(type)) { 14408 if (WXS_IS_RESTRICTION(type)) {
14341 /* 14409 /*
14342 * This one will transfer all attr. prohibitions 14410 * This one will transfer all attr. prohibitions
14343 * into pctxt->attrProhibs. 14411 * into pctxt->attrProhibs.
14344 */ 14412 */
14345 if (xmlSchemaExpandAttributeGroupRefs(pctxt, 14413 if (xmlSchemaExpandAttributeGroupRefs(pctxt,
14346 WXS_BASIC_CAST type, &(type->attributeWildcard), uses, 14414 WXS_BASIC_CAST type, &(type->attributeWildcard), uses,
14347 pctxt->attrProhibs) == -1) 14415 pctxt->attrProhibs) == -1)
14348 { 14416 {
14349 PERROR_INT("xmlSchemaFixupTypeAttributeUses", 14417 PERROR_INT("xmlSchemaFixupTypeAttributeUses",
(...skipping 13 matching lines...) Expand all
14363 } 14431 }
14364 /* 14432 /*
14365 * Inherit the attribute uses of the base type. 14433 * Inherit the attribute uses of the base type.
14366 */ 14434 */
14367 if (baseUses != NULL) { 14435 if (baseUses != NULL) {
14368 int i, j; 14436 int i, j;
14369 xmlSchemaAttributeUseProhibPtr pro; 14437 xmlSchemaAttributeUseProhibPtr pro;
14370 14438
14371 if (WXS_IS_RESTRICTION(type)) { 14439 if (WXS_IS_RESTRICTION(type)) {
14372 int usesCount; 14440 int usesCount;
14373 » xmlSchemaAttributeUsePtr tmp; 14441 » xmlSchemaAttributeUsePtr tmp;
14374 14442
14375 if (uses != NULL) 14443 if (uses != NULL)
14376 usesCount = uses->nbItems; 14444 usesCount = uses->nbItems;
14377 else 14445 else
14378 usesCount = 0; 14446 usesCount = 0;
14379 14447
14380 /* Restriction. */ 14448 /* Restriction. */
14381 for (i = 0; i < baseUses->nbItems; i++) { 14449 for (i = 0; i < baseUses->nbItems; i++) {
14382 use = baseUses->items[i]; 14450 use = baseUses->items[i];
14383 if (prohibs) { 14451 if (prohibs) {
(...skipping 29 matching lines...) Expand all
14413 type->attrUses = xmlSchemaItemListCreate(); 14481 type->attrUses = xmlSchemaItemListCreate();
14414 if (type->attrUses == NULL) 14482 if (type->attrUses == NULL)
14415 goto exit_failure; 14483 goto exit_failure;
14416 uses = type->attrUses; 14484 uses = type->attrUses;
14417 } 14485 }
14418 xmlSchemaItemListAddSize(uses, 2, use); 14486 xmlSchemaItemListAddSize(uses, 2, use);
14419 inherit_next: {} 14487 inherit_next: {}
14420 } 14488 }
14421 } else { 14489 } else {
14422 /* Extension. */ 14490 /* Extension. */
14423 » for (i = 0; i < baseUses->nbItems; i++) {» 14491 » for (i = 0; i < baseUses->nbItems; i++) {
14424 » » use = baseUses->items[i];» » 14492 » » use = baseUses->items[i];
14425 if (uses == NULL) { 14493 if (uses == NULL) {
14426 type->attrUses = xmlSchemaItemListCreate(); 14494 type->attrUses = xmlSchemaItemListCreate();
14427 if (type->attrUses == NULL) 14495 if (type->attrUses == NULL)
14428 goto exit_failure; 14496 goto exit_failure;
14429 uses = type->attrUses; 14497 uses = type->attrUses;
14430 } 14498 }
14431 » » xmlSchemaItemListAddSize(uses, baseUses->nbItems, use); 14499 » » xmlSchemaItemListAddSize(uses, baseUses->nbItems, use);
14432 } 14500 }
14433 } 14501 }
14434 } 14502 }
14435 /* 14503 /*
14436 * Shrink attr. uses. 14504 * Shrink attr. uses.
14437 */ 14505 */
14438 if (uses) { 14506 if (uses) {
14439 if (uses->nbItems == 0) { 14507 if (uses->nbItems == 0) {
14440 xmlSchemaItemListFree(uses); 14508 xmlSchemaItemListFree(uses);
14441 type->attrUses = NULL; 14509 type->attrUses = NULL;
14442 } 14510 }
14443 /* 14511 /*
14444 * TODO: We could shrink the size of the array 14512 * TODO: We could shrink the size of the array
14445 * to fit the actual number of items. 14513 * to fit the actual number of items.
14446 */ 14514 */
14447 } 14515 }
14448 /* 14516 /*
14449 * Compute the complete wildcard. 14517 * Compute the complete wildcard.
14450 */ 14518 */
14451 if (WXS_IS_EXTENSION(type)) {» 14519 if (WXS_IS_EXTENSION(type)) {
14452 if (baseType->attributeWildcard != NULL) { 14520 if (baseType->attributeWildcard != NULL) {
14453 /* 14521 /*
14454 » * (3.2.2.1) "If the ·base wildcard· is non-·absent·, then 14522 » * (3.2.2.1) "If the �base wildcard� is non-�absent�, then
14455 * the appropriate case among the following:" 14523 * the appropriate case among the following:"
14456 */ 14524 */
14457 if (type->attributeWildcard != NULL) { 14525 if (type->attributeWildcard != NULL) {
14458 /* 14526 /*
14459 * Union the complete wildcard with the base wildcard. 14527 * Union the complete wildcard with the base wildcard.
14460 * SPEC {attribute wildcard} 14528 * SPEC {attribute wildcard}
14461 * (3.2.2.1.2) "otherwise a wildcard whose {process contents} 14529 * (3.2.2.1.2) "otherwise a wildcard whose {process contents}
14462 » » * and {annotation} are those of the ·complete wildcard·, 14530 » » * and {annotation} are those of the �complete wildcard�,
14463 * and whose {namespace constraint} is the intensional union 14531 * and whose {namespace constraint} is the intensional union
14464 » » * of the {namespace constraint} of the ·complete wildcard· 14532 » » * of the {namespace constraint} of the �complete wildcard�
14465 » » * and of the ·base wildcard·, as defined in Attribute 14533 » » * and of the �base wildcard�, as defined in Attribute
14466 » » * Wildcard Union (§3.10.6)." 14534 » » * Wildcard Union (�3.10.6)."
14467 */ 14535 */
14468 if (xmlSchemaUnionWildcards(pctxt, type->attributeWildcard, 14536 if (xmlSchemaUnionWildcards(pctxt, type->attributeWildcard,
14469 baseType->attributeWildcard) == -1) 14537 baseType->attributeWildcard) == -1)
14470 » » goto exit_failure;» » 14538 » » goto exit_failure;
14471 } else { 14539 } else {
14472 /* 14540 /*
14473 » » * (3.2.2.1.1) "If the ·complete wildcard· is ·absent·, 14541 » » * (3.2.2.1.1) "If the �complete wildcard� is �absent�,
14474 » » * then the ·base wildcard·." 14542 » » * then the �base wildcard�."
14475 */ 14543 */
14476 type->attributeWildcard = baseType->attributeWildcard; 14544 type->attributeWildcard = baseType->attributeWildcard;
14477 » }» 14545 » }
14478 } else { 14546 } else {
14479 /* 14547 /*
14480 » * (3.2.2.2) "otherwise (the ·base wildcard· is ·absent·) the 14548 » * (3.2.2.2) "otherwise (the �base wildcard� is �absent�) the
14481 » * ·complete wildcard" 14549 » * �complete wildcard"
14482 * NOOP 14550 * NOOP
14483 */ 14551 */
14484 } 14552 }
14485 } else { 14553 } else {
14486 /* 14554 /*
14487 * SPEC {attribute wildcard} 14555 * SPEC {attribute wildcard}
14488 * (3.1) "If the <restriction> alternative is chosen, then the 14556 * (3.1) "If the <restriction> alternative is chosen, then the
14489 » * ·complete wildcard·;" 14557 » * �complete wildcard�;"
14490 * NOOP 14558 * NOOP
14491 */ 14559 */
14492 } 14560 }
14493 14561
14494 return (0); 14562 return (0);
14495 14563
14496 exit_failure: 14564 exit_failure:
14497 return(-1); 14565 return(-1);
14498 } 14566 }
14499 14567
14500 /** 14568 /**
14501 * xmlSchemaTypeFinalContains: 14569 * xmlSchemaTypeFinalContains:
14502 * @schema: the schema 14570 * @schema: the schema
14503 * @type: the type definition 14571 * @type: the type definition
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
14587 (part->children->type == XML_SCHEMA_TYPE_ANY)) 14655 (part->children->type == XML_SCHEMA_TYPE_ANY))
14588 sum += part->minOccurs; 14656 sum += part->minOccurs;
14589 else 14657 else
14590 sum += xmlSchemaGetParticleTotalRangeMin(part); 14658 sum += xmlSchemaGetParticleTotalRangeMin(part);
14591 part = (xmlSchemaParticlePtr) part->next; 14659 part = (xmlSchemaParticlePtr) part->next;
14592 } while (part != NULL); 14660 } while (part != NULL);
14593 return (particle->minOccurs * sum); 14661 return (particle->minOccurs * sum);
14594 } 14662 }
14595 } 14663 }
14596 14664
14665 #if 0
14597 /** 14666 /**
14598 * xmlSchemaGetParticleTotalRangeMax: 14667 * xmlSchemaGetParticleTotalRangeMax:
14599 * @particle: the particle 14668 * @particle: the particle
14600 * 14669 *
14601 * Schema Component Constraint: Effective Total Range 14670 * Schema Component Constraint: Effective Total Range
14602 * (all and sequence) + (choice) 14671 * (all and sequence) + (choice)
14603 * 14672 *
14604 * Returns the maximum Effective Total Range. 14673 * Returns the maximum Effective Total Range.
14605 */ 14674 */
14606 static int 14675 static int
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
14646 if (cur == UNBOUNDED) 14715 if (cur == UNBOUNDED)
14647 return (UNBOUNDED); 14716 return (UNBOUNDED);
14648 if ((cur > 0) && (particle->maxOccurs == UNBOUNDED)) 14717 if ((cur > 0) && (particle->maxOccurs == UNBOUNDED))
14649 return (UNBOUNDED); 14718 return (UNBOUNDED);
14650 sum += cur; 14719 sum += cur;
14651 } 14720 }
14652 /* TODO: Handle overflows? */ 14721 /* TODO: Handle overflows? */
14653 return (particle->maxOccurs * sum); 14722 return (particle->maxOccurs * sum);
14654 } 14723 }
14655 } 14724 }
14725 #endif
14656 14726
14657 /** 14727 /**
14658 * xmlSchemaIsParticleEmptiable: 14728 * xmlSchemaIsParticleEmptiable:
14659 * @particle: the particle 14729 * @particle: the particle
14660 * 14730 *
14661 * Schema Component Constraint: Particle Emptiable 14731 * Schema Component Constraint: Particle Emptiable
14662 * Checks whether the given particle is emptiable. 14732 * Checks whether the given particle is emptiable.
14663 * 14733 *
14664 * Returns 1 if emptiable, 0 otherwise. 14734 * Returns 1 if emptiable, 0 otherwise.
14665 */ 14735 */
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
14726 if (xmlSchemaTypeFixup(baseType, actxt) == -1) 14796 if (xmlSchemaTypeFixup(baseType, actxt) == -1)
14727 return(-1); 14797 return(-1);
14728 if ((subset & SUBSET_RESTRICTION) || 14798 if ((subset & SUBSET_RESTRICTION) ||
14729 (xmlSchemaTypeFinalContains(type->baseType, 14799 (xmlSchemaTypeFinalContains(type->baseType,
14730 XML_SCHEMAS_TYPE_FINAL_RESTRICTION))) { 14800 XML_SCHEMAS_TYPE_FINAL_RESTRICTION))) {
14731 return (XML_SCHEMAP_COS_ST_DERIVED_OK_2_1); 14801 return (XML_SCHEMAP_COS_ST_DERIVED_OK_2_1);
14732 } 14802 }
14733 /* 2.2 */ 14803 /* 2.2 */
14734 if (type->baseType == baseType) { 14804 if (type->baseType == baseType) {
14735 /* 14805 /*
14736 » * 2.2.1 D's ·base type definition· is B. 14806 » * 2.2.1 D's �base type definition� is B.
14737 */ 14807 */
14738 return (0); 14808 return (0);
14739 } 14809 }
14740 /* 14810 /*
14741 * 2.2.2 D's ·base type definition· is not the ·ur-type definition· 14811 * 2.2.2 D's �base type definition� is not the �ur-type definition�
14742 * and is validly derived from B given the subset, as defined by this 14812 * and is validly derived from B given the subset, as defined by this
14743 * constraint. 14813 * constraint.
14744 */ 14814 */
14745 if ((! WXS_IS_ANYTYPE(type->baseType)) && 14815 if ((! WXS_IS_ANYTYPE(type->baseType)) &&
14746 (xmlSchemaCheckCOSSTDerivedOK(actxt, type->baseType, 14816 (xmlSchemaCheckCOSSTDerivedOK(actxt, type->baseType,
14747 baseType, subset) == 0)) { 14817 baseType, subset) == 0)) {
14748 return (0); 14818 return (0);
14749 } 14819 }
14750 /* 14820 /*
14751 * 2.2.3 D's {variety} is list or union and B is the ·simple ur-type 14821 * 2.2.3 D's {variety} is list or union and B is the �simple ur-type
14752 * definition·. 14822 * definition�.
14753 */ 14823 */
14754 if (WXS_IS_ANY_SIMPLE_TYPE(baseType) && 14824 if (WXS_IS_ANY_SIMPLE_TYPE(baseType) &&
14755 (WXS_IS_LIST(type) || WXS_IS_UNION(type))) { 14825 (WXS_IS_LIST(type) || WXS_IS_UNION(type))) {
14756 return (0); 14826 return (0);
14757 } 14827 }
14758 /* 14828 /*
14759 * 2.2.4 B's {variety} is union and D is validly derived from a type 14829 * 2.2.4 B's {variety} is union and D is validly derived from a type
14760 * definition in B's {member type definitions} given the subset, as 14830 * definition in B's {member type definitions} given the subset, as
14761 * defined by this constraint. 14831 * defined by this constraint.
14762 * 14832 *
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
14858 * 14928 *
14859 * Note that this should work on the *representation* of a component, 14929 * Note that this should work on the *representation* of a component,
14860 * thus assumes any union types in the member types not being yet 14930 * thus assumes any union types in the member types not being yet
14861 * substituted. At this stage we need the variety of the types 14931 * substituted. At this stage we need the variety of the types
14862 * to be already computed. 14932 * to be already computed.
14863 */ 14933 */
14864 static int 14934 static int
14865 xmlSchemaCheckUnionTypeDefCircularRecur(xmlSchemaParserCtxtPtr pctxt, 14935 xmlSchemaCheckUnionTypeDefCircularRecur(xmlSchemaParserCtxtPtr pctxt,
14866 xmlSchemaTypePtr ctxType, 14936 xmlSchemaTypePtr ctxType,
14867 xmlSchemaTypeLinkPtr members) 14937 xmlSchemaTypeLinkPtr members)
14868 { 14938 {
14869 xmlSchemaTypeLinkPtr member; 14939 xmlSchemaTypeLinkPtr member;
14870 xmlSchemaTypePtr memberType; 14940 xmlSchemaTypePtr memberType;
14871 14941
14872 member = members; 14942 member = members;
14873 while (member != NULL) { 14943 while (member != NULL) {
14874 memberType = member->type; 14944 memberType = member->type;
14875 while ((memberType != NULL) && 14945 while ((memberType != NULL) &&
14876 (memberType->type != XML_SCHEMA_TYPE_BASIC)) { 14946 (memberType->type != XML_SCHEMA_TYPE_BASIC)) {
14877 if (memberType == ctxType) { 14947 if (memberType == ctxType) {
14878 xmlSchemaPCustomErr(pctxt, 14948 xmlSchemaPCustomErr(pctxt,
14879 XML_SCHEMAP_SRC_SIMPLE_TYPE_4, 14949 XML_SCHEMAP_SRC_SIMPLE_TYPE_4,
14880 WXS_BASIC_CAST ctxType, NULL, 14950 WXS_BASIC_CAST ctxType, NULL,
14881 "The union type definition is circular", NULL); 14951 "The union type definition is circular", NULL);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
14962 typeDef->subtypes = NULL; 15032 typeDef->subtypes = NULL;
14963 xmlSchemaPResCompAttrErr(ctxt, 15033 xmlSchemaPResCompAttrErr(ctxt,
14964 XML_SCHEMAP_SRC_RESOLVE, 15034 XML_SCHEMAP_SRC_RESOLVE,
14965 WXS_BASIC_CAST typeDef, typeDef->node, 15035 WXS_BASIC_CAST typeDef, typeDef->node,
14966 "itemType", typeDef->base, typeDef->baseNs, 15036 "itemType", typeDef->base, typeDef->baseNs,
14967 XML_SCHEMA_TYPE_SIMPLE, NULL); 15037 XML_SCHEMA_TYPE_SIMPLE, NULL);
14968 } 15038 }
14969 } 15039 }
14970 return; 15040 return;
14971 } 15041 }
14972 } 15042 }
14973 /* 15043 /*
14974 * The ball of letters below means, that if we have a particle 15044 * The ball of letters below means, that if we have a particle
14975 * which has a QName-helper component as its {term}, we want 15045 * which has a QName-helper component as its {term}, we want
14976 * to resolve it... 15046 * to resolve it...
14977 */ 15047 */
14978 else if ((WXS_TYPE_CONTENTTYPE(typeDef) != NULL) && 15048 else if ((WXS_TYPE_CONTENTTYPE(typeDef) != NULL) &&
14979 ((WXS_TYPE_CONTENTTYPE(typeDef))->type == 15049 ((WXS_TYPE_CONTENTTYPE(typeDef))->type ==
14980 XML_SCHEMA_TYPE_PARTICLE) && 15050 XML_SCHEMA_TYPE_PARTICLE) &&
14981 (WXS_TYPE_PARTICLE_TERM(typeDef) != NULL) && 15051 (WXS_TYPE_PARTICLE_TERM(typeDef) != NULL) &&
14982 ((WXS_TYPE_PARTICLE_TERM(typeDef))->type == 15052 ((WXS_TYPE_PARTICLE_TERM(typeDef))->type ==
(...skipping 22 matching lines...) Expand all
15005 WXS_TYPE_CONTENTTYPE(typeDef) = NULL; 15075 WXS_TYPE_CONTENTTYPE(typeDef) = NULL;
15006 } else if (WXS_MODELGROUPDEF_MODEL(groupDef) == NULL) 15076 } else if (WXS_MODELGROUPDEF_MODEL(groupDef) == NULL)
15007 /* Remove the particle. */ 15077 /* Remove the particle. */
15008 WXS_TYPE_CONTENTTYPE(typeDef) = NULL; 15078 WXS_TYPE_CONTENTTYPE(typeDef) = NULL;
15009 else { 15079 else {
15010 /* 15080 /*
15011 * Assign the MG definition's {model group} to the 15081 * Assign the MG definition's {model group} to the
15012 * particle's {term}. 15082 * particle's {term}.
15013 */ 15083 */
15014 WXS_TYPE_PARTICLE_TERM(typeDef) = WXS_MODELGROUPDEF_MODEL(groupDef); 15084 WXS_TYPE_PARTICLE_TERM(typeDef) = WXS_MODELGROUPDEF_MODEL(groupDef);
15015 » 15085
15016 if (WXS_MODELGROUPDEF_MODEL(groupDef)->type == XML_SCHEMA_TYPE_ALL) { 15086 if (WXS_MODELGROUPDEF_MODEL(groupDef)->type == XML_SCHEMA_TYPE_ALL) {
15017 /* 15087 /*
15018 * SPEC cos-all-limited (1.2) 15088 * SPEC cos-all-limited (1.2)
15019 * "1.2 the {term} property of a particle with 15089 * "1.2 the {term} property of a particle with
15020 * {max occurs}=1 which is part of a pair which constitutes 15090 * {max occurs}=1 which is part of a pair which constitutes
15021 * the {content type} of a complex type definition." 15091 * the {content type} of a complex type definition."
15022 */ 15092 */
15023 if ((WXS_TYPE_PARTICLE(typeDef))->maxOccurs != 1) { 15093 if ((WXS_TYPE_PARTICLE(typeDef))->maxOccurs != 1) {
15024 xmlSchemaCustomErr(ACTXT_CAST ctxt, 15094 xmlSchemaCustomErr(ACTXT_CAST ctxt,
15025 /* TODO: error code */ 15095 /* TODO: error code */
(...skipping 28 matching lines...) Expand all
15054 xmlSchemaTypePtr baseType = type->baseType; 15124 xmlSchemaTypePtr baseType = type->baseType;
15055 xmlChar *str = NULL; 15125 xmlChar *str = NULL;
15056 15126
15057 /* STATE: error funcs converted. */ 15127 /* STATE: error funcs converted. */
15058 /* 15128 /*
15059 * Schema Component Constraint: Simple Type Definition Properties Correct 15129 * Schema Component Constraint: Simple Type Definition Properties Correct
15060 * 15130 *
15061 * NOTE: This is somehow redundant, since we actually built a simple type 15131 * NOTE: This is somehow redundant, since we actually built a simple type
15062 * to have all the needed information; this acts as an self test. 15132 * to have all the needed information; this acts as an self test.
15063 */ 15133 */
15064 /* Base type: If the datatype has been ·derived· by ·restriction· 15134 /* Base type: If the datatype has been �derived� by �restriction�
15065 * then the Simple Type Definition component from which it is ·derived·, 15135 * then the Simple Type Definition component from which it is �derived�,
15066 * otherwise the Simple Type Definition for anySimpleType (§4.1.6). 15136 * otherwise the Simple Type Definition for anySimpleType (�4.1.6).
15067 */ 15137 */
15068 if (baseType == NULL) { 15138 if (baseType == NULL) {
15069 /* 15139 /*
15070 * TODO: Think about: "modulo the impact of Missing 15140 * TODO: Think about: "modulo the impact of Missing
15071 » * Sub-components (§5.3)." 15141 » * Sub-components (�5.3)."
15072 */ 15142 */
15073 xmlSchemaPCustomErr(ctxt, 15143 xmlSchemaPCustomErr(ctxt,
15074 XML_SCHEMAP_ST_PROPS_CORRECT_1, 15144 XML_SCHEMAP_ST_PROPS_CORRECT_1,
15075 WXS_BASIC_CAST type, NULL, 15145 WXS_BASIC_CAST type, NULL,
15076 "No base type existent", NULL); 15146 "No base type existent", NULL);
15077 return (XML_SCHEMAP_ST_PROPS_CORRECT_1); 15147 return (XML_SCHEMAP_ST_PROPS_CORRECT_1);
15078 15148
15079 } 15149 }
15080 if (! WXS_IS_SIMPLE(baseType)) { 15150 if (! WXS_IS_SIMPLE(baseType)) {
15081 xmlSchemaPCustomErr(ctxt, 15151 xmlSchemaPCustomErr(ctxt,
15082 XML_SCHEMAP_ST_PROPS_CORRECT_1, 15152 XML_SCHEMAP_ST_PROPS_CORRECT_1,
15083 WXS_BASIC_CAST type, NULL, 15153 WXS_BASIC_CAST type, NULL,
15084 "The base type '%s' is not a simple type", 15154 "The base type '%s' is not a simple type",
15085 xmlSchemaGetComponentQName(&str, baseType)); 15155 xmlSchemaGetComponentQName(&str, baseType));
15086 FREE_AND_NULL(str) 15156 FREE_AND_NULL(str)
15087 return (XML_SCHEMAP_ST_PROPS_CORRECT_1); 15157 return (XML_SCHEMAP_ST_PROPS_CORRECT_1);
15088 } 15158 }
15089 if ( (WXS_IS_LIST(type) || WXS_IS_UNION(type)) && 15159 if ( (WXS_IS_LIST(type) || WXS_IS_UNION(type)) &&
15090 (WXS_IS_RESTRICTION(type) == 0) && 15160 (WXS_IS_RESTRICTION(type) == 0) &&
15091 (! WXS_IS_ANY_SIMPLE_TYPE(baseType))) { 15161 (! WXS_IS_ANY_SIMPLE_TYPE(baseType))) {
15092 xmlSchemaPCustomErr(ctxt, 15162 xmlSchemaPCustomErr(ctxt,
15093 XML_SCHEMAP_ST_PROPS_CORRECT_1, 15163 XML_SCHEMAP_ST_PROPS_CORRECT_1,
15094 WXS_BASIC_CAST type, NULL, 15164 WXS_BASIC_CAST type, NULL,
15095 » "A type, derived by list or union, must have" 15165 » "A type, derived by list or union, must have "
15096 "the simple ur-type definition as base type, not '%s'", 15166 "the simple ur-type definition as base type, not '%s'",
15097 xmlSchemaGetComponentQName(&str, baseType)); 15167 xmlSchemaGetComponentQName(&str, baseType));
15098 FREE_AND_NULL(str) 15168 FREE_AND_NULL(str)
15099 return (XML_SCHEMAP_ST_PROPS_CORRECT_1); 15169 return (XML_SCHEMAP_ST_PROPS_CORRECT_1);
15100 } 15170 }
15101 /* 15171 /*
15102 * Variety: One of {atomic, list, union}. 15172 * Variety: One of {atomic, list, union}.
15103 */ 15173 */
15104 if ((! WXS_IS_ATOMIC(type)) && (! WXS_IS_UNION(type)) && 15174 if ((! WXS_IS_ATOMIC(type)) && (! WXS_IS_UNION(type)) &&
15105 (! WXS_IS_LIST(type))) { 15175 (! WXS_IS_LIST(type))) {
(...skipping 14 matching lines...) Expand all
15120 XML_SCHEMAP_ST_PROPS_CORRECT_3, 15190 XML_SCHEMAP_ST_PROPS_CORRECT_3,
15121 WXS_BASIC_CAST type, NULL, 15191 WXS_BASIC_CAST type, NULL,
15122 "The 'final' of its base type '%s' must not contain " 15192 "The 'final' of its base type '%s' must not contain "
15123 "'restriction'", 15193 "'restriction'",
15124 xmlSchemaGetComponentQName(&str, baseType)); 15194 xmlSchemaGetComponentQName(&str, baseType));
15125 FREE_AND_NULL(str) 15195 FREE_AND_NULL(str)
15126 return (XML_SCHEMAP_ST_PROPS_CORRECT_3); 15196 return (XML_SCHEMAP_ST_PROPS_CORRECT_3);
15127 } 15197 }
15128 15198
15129 /* 15199 /*
15130 * 2 All simple type definitions must be derived ultimately from the ·simple 15200 * 2 All simple type definitions must be derived ultimately from the �simpl e
15131 * ur-type definition (so· circular definitions are disallowed). That is, it 15201 * ur-type definition (so� circular definitions are disallowed). That is, i t
15132 * must be possible to reach a built-in primitive datatype or the ·simple 15202 * must be possible to reach a built-in primitive datatype or the �simple
15133 * ur-type definition· by repeatedly following the {base type definition}. 15203 * ur-type definition� by repeatedly following the {base type definition}.
15134 * 15204 *
15135 * NOTE: this is done in xmlSchemaCheckTypeDefCircular(). 15205 * NOTE: this is done in xmlSchemaCheckTypeDefCircular().
15136 */ 15206 */
15137 return (0); 15207 return (0);
15138 } 15208 }
15139 15209
15140 /** 15210 /**
15141 * xmlSchemaCheckCOSSTRestricts: 15211 * xmlSchemaCheckCOSSTRestricts:
15142 * @ctxt: the schema parser context 15212 * @ctxt: the schema parser context
15143 * @type: the simple type definition 15213 * @type: the simple type definition
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
15307 xmlSchemaPIllegalFacetListUnionErr(pctxt, 15377 xmlSchemaPIllegalFacetListUnionErr(pctxt,
15308 XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2, 15378 XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2,
15309 type, facet); 15379 type, facet);
15310 return (XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2); 15380 return (XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2);
15311 } 15381 }
15312 facet = facet->next; 15382 facet = facet->next;
15313 } while (facet != NULL); 15383 } while (facet != NULL);
15314 } 15384 }
15315 /* 15385 /*
15316 * MAYBE TODO: (Hmm, not really) Datatypes states: 15386 * MAYBE TODO: (Hmm, not really) Datatypes states:
15317 » * A ·list· datatype can be ·derived· from an ·atomic· datatype 15387 » * A �list� datatype can be �derived� from an �atomic� da tatype
15318 » * whose ·lexical space· allows space (such as string or anyURI)or 15388 » * whose �lexical space� allows space (such as string or anyURI)o r
15319 » * a ·union· datatype any of whose {member type definitions}'s 15389 » * a �union� datatype any of whose {member type definitions}'s
15320 » * ·lexical space· allows space. 15390 » * �lexical space� allows space.
15321 */ 15391 */
15322 } else { 15392 } else {
15323 /* 15393 /*
15324 * This is the case if we have: <simpleType><restriction ... 15394 * This is the case if we have: <simpleType><restriction ...
15325 * I.e. the variety of "list" is inherited. 15395 * I.e. the variety of "list" is inherited.
15326 */ 15396 */
15327 /* 15397 /*
15328 * 2.3.2 15398 * 2.3.2
15329 * 2.3.2.1 The {base type definition} must have a {variety} of list. 15399 * 2.3.2.1 The {base type definition} must have a {variety} of list.
15330 */ 15400 */
(...skipping 16 matching lines...) Expand all
15347 XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2, 15417 XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2,
15348 WXS_BASIC_CAST type, NULL, 15418 WXS_BASIC_CAST type, NULL,
15349 "The 'final' of the base type '%s' must not contain 'restric tion'", 15419 "The 'final' of the base type '%s' must not contain 'restric tion'",
15350 xmlSchemaGetComponentQName(&str, type->baseType)); 15420 xmlSchemaGetComponentQName(&str, type->baseType));
15351 FREE_AND_NULL(str) 15421 FREE_AND_NULL(str)
15352 return (XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2); 15422 return (XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2);
15353 } 15423 }
15354 /* 15424 /*
15355 * 2.3.2.3 The {item type definition} must be validly derived 15425 * 2.3.2.3 The {item type definition} must be validly derived
15356 * from the {base type definition}'s {item type definition} given 15426 * from the {base type definition}'s {item type definition} given
15357 » * the empty set, as defined in Type Derivation OK (Simple) (§3.14.6) . 15427 » * the empty set, as defined in Type Derivation OK (Simple) (�3.14. 6).
15358 */ 15428 */
15359 { 15429 {
15360 xmlSchemaTypePtr baseItemType; 15430 xmlSchemaTypePtr baseItemType;
15361 15431
15362 baseItemType = type->baseType->subtypes; 15432 baseItemType = type->baseType->subtypes;
15363 if ((baseItemType == NULL) || (! WXS_IS_SIMPLE(baseItemType))) { 15433 if ((baseItemType == NULL) || (! WXS_IS_SIMPLE(baseItemType))) {
15364 PERROR_INT("xmlSchemaCheckCOSSTRestricts", 15434 PERROR_INT("xmlSchemaCheckCOSSTRestricts",
15365 "failed to eval the item type of a base type"); 15435 "failed to eval the item type of a base type");
15366 return (-1); 15436 return (-1);
15367 } 15437 }
(...skipping 26 matching lines...) Expand all
15394 */ 15464 */
15395 facet = type->facets; 15465 facet = type->facets;
15396 do { 15466 do {
15397 switch (facet->type) { 15467 switch (facet->type) {
15398 case XML_SCHEMA_FACET_LENGTH: 15468 case XML_SCHEMA_FACET_LENGTH:
15399 case XML_SCHEMA_FACET_MINLENGTH: 15469 case XML_SCHEMA_FACET_MINLENGTH:
15400 case XML_SCHEMA_FACET_MAXLENGTH: 15470 case XML_SCHEMA_FACET_MAXLENGTH:
15401 case XML_SCHEMA_FACET_WHITESPACE: 15471 case XML_SCHEMA_FACET_WHITESPACE:
15402 /* 15472 /*
15403 * TODO: 2.5.1.2 List datatypes 15473 * TODO: 2.5.1.2 List datatypes
15404 » » » * The value of ·whiteSpace· is fixed to the value co llapse. 15474 » » » * The value of �whiteSpace� is fixed to the valu e collapse.
15405 */ 15475 */
15406 case XML_SCHEMA_FACET_PATTERN: 15476 case XML_SCHEMA_FACET_PATTERN:
15407 case XML_SCHEMA_FACET_ENUMERATION: 15477 case XML_SCHEMA_FACET_ENUMERATION:
15408 break; 15478 break;
15409 default: { 15479 default: {
15410 xmlSchemaPIllegalFacetListUnionErr(pctxt, 15480 xmlSchemaPIllegalFacetListUnionErr(pctxt,
15411 XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4, 15481 XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4,
15412 type, facet); 15482 type, facet);
15413 /* 15483 /*
15414 * We could return, but it's nicer to report all 15484 * We could return, but it's nicer to report all
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
15447 XML_SCHEMAP_COS_ST_RESTRICTS_3_1, 15517 XML_SCHEMAP_COS_ST_RESTRICTS_3_1,
15448 WXS_BASIC_CAST type, NULL, 15518 WXS_BASIC_CAST type, NULL,
15449 "The member type '%s' is neither an atomic, nor a list type" , 15519 "The member type '%s' is neither an atomic, nor a list type" ,
15450 xmlSchemaGetComponentQName(&str, member->type)); 15520 xmlSchemaGetComponentQName(&str, member->type));
15451 FREE_AND_NULL(str) 15521 FREE_AND_NULL(str)
15452 return (XML_SCHEMAP_COS_ST_RESTRICTS_3_1); 15522 return (XML_SCHEMAP_COS_ST_RESTRICTS_3_1);
15453 } 15523 }
15454 member = member->next; 15524 member = member->next;
15455 } 15525 }
15456 /* 15526 /*
15457 » * 3.3.1 If the {base type definition} is the ·simple ur-type 15527 » * 3.3.1 If the {base type definition} is the �simple ur-type
15458 » * definition· 15528 » * definition�
15459 */ 15529 */
15460 if (type->baseType->builtInType == XML_SCHEMAS_ANYSIMPLETYPE) { 15530 if (type->baseType->builtInType == XML_SCHEMAS_ANYSIMPLETYPE) {
15461 /* 15531 /*
15462 * 3.3.1.1 All of the {member type definitions} must have a 15532 * 3.3.1.1 All of the {member type definitions} must have a
15463 * {final} which does not contain union. 15533 * {final} which does not contain union.
15464 */ 15534 */
15465 member = type->memberTypes; 15535 member = type->memberTypes;
15466 while (member != NULL) { 15536 while (member != NULL) {
15467 if (xmlSchemaTypeFinalContains(member->type, 15537 if (xmlSchemaTypeFinalContains(member->type,
15468 XML_SCHEMAS_TYPE_FINAL_UNION)) { 15538 XML_SCHEMAS_TYPE_FINAL_UNION)) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
15510 WXS_BASIC_CAST type, NULL, 15580 WXS_BASIC_CAST type, NULL,
15511 "The 'final' of its base type '%s' must not contain 'restric tion'", 15581 "The 'final' of its base type '%s' must not contain 'restric tion'",
15512 xmlSchemaGetComponentQName(&str, type->baseType)); 15582 xmlSchemaGetComponentQName(&str, type->baseType));
15513 FREE_AND_NULL(str) 15583 FREE_AND_NULL(str)
15514 return (XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2); 15584 return (XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2);
15515 } 15585 }
15516 /* 15586 /*
15517 * 3.3.2.3 The {member type definitions}, in order, must be validly 15587 * 3.3.2.3 The {member type definitions}, in order, must be validly
15518 * derived from the corresponding type definitions in the {base 15588 * derived from the corresponding type definitions in the {base
15519 * type definition}'s {member type definitions} given the empty set, 15589 * type definition}'s {member type definitions} given the empty set,
15520 » * as defined in Type Derivation OK (Simple) (§3.14.6). 15590 » * as defined in Type Derivation OK (Simple) (�3.14.6).
15521 */ 15591 */
15522 { 15592 {
15523 xmlSchemaTypeLinkPtr baseMember; 15593 xmlSchemaTypeLinkPtr baseMember;
15524 15594
15525 /* 15595 /*
15526 * OPTIMIZE: if the type is restricting, it has no local defined 15596 * OPTIMIZE: if the type is restricting, it has no local defined
15527 * member types and inherits the member types of the base type; 15597 * member types and inherits the member types of the base type;
15528 * thus a check for equality can be skipped. 15598 * thus a check for equality can be skipped.
15529 */ 15599 */
15530 /* 15600 /*
(...skipping 27 matching lines...) Expand all
15558 "type %s of the base type %s", 15628 "type %s of the base type %s",
15559 xmlSchemaGetComponentQName(&str, member->type), 15629 xmlSchemaGetComponentQName(&str, member->type),
15560 xmlSchemaGetComponentQName(&strBMT, baseMember-> type), 15630 xmlSchemaGetComponentQName(&strBMT, baseMember-> type),
15561 xmlSchemaGetComponentQName(&strBT, type->baseTyp e)); 15631 xmlSchemaGetComponentQName(&strBT, type->baseTyp e));
15562 FREE_AND_NULL(str) 15632 FREE_AND_NULL(str)
15563 FREE_AND_NULL(strBMT) 15633 FREE_AND_NULL(strBMT)
15564 FREE_AND_NULL(strBT) 15634 FREE_AND_NULL(strBT)
15565 return (XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3); 15635 return (XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3);
15566 } 15636 }
15567 member = member->next; 15637 member = member->next;
15568 » » » baseMember = baseMember->next; 15638 if (baseMember != NULL)
15639 baseMember = baseMember->next;
15569 } 15640 }
15570 } 15641 }
15571 } 15642 }
15572 /* 15643 /*
15573 * 3.3.2.4 Only pattern and enumeration facet components are 15644 * 3.3.2.4 Only pattern and enumeration facet components are
15574 * allowed among the {facets}. 15645 * allowed among the {facets}.
15575 */ 15646 */
15576 if (type->facets != NULL) { 15647 if (type->facets != NULL) {
15577 xmlSchemaFacetPtr facet; 15648 xmlSchemaFacetPtr facet;
15578 int ok = 1; 15649 int ok = 1;
(...skipping 23 matching lines...) Expand all
15602 } 15673 }
15603 15674
15604 return (0); 15675 return (0);
15605 } 15676 }
15606 15677
15607 /** 15678 /**
15608 * xmlSchemaCheckSRCSimpleType: 15679 * xmlSchemaCheckSRCSimpleType:
15609 * @ctxt: the schema parser context 15680 * @ctxt: the schema parser context
15610 * @type: the simple type definition 15681 * @type: the simple type definition
15611 * 15682 *
15612 * Checks crc-simple-type constraints. 15683 * Checks crc-simple-type constraints.
15613 * 15684 *
15614 * Returns 0 if the constraints are satisfied, 15685 * Returns 0 if the constraints are satisfied,
15615 * if not a positive error code and -1 on internal 15686 * if not a positive error code and -1 on internal
15616 * errors. 15687 * errors.
15617 */ 15688 */
15618 #if 0 15689 #if 0
15619 static int 15690 static int
15620 xmlSchemaCheckSRCSimpleType(xmlSchemaParserCtxtPtr ctxt, 15691 xmlSchemaCheckSRCSimpleType(xmlSchemaParserCtxtPtr ctxt,
15621 xmlSchemaTypePtr type) 15692 xmlSchemaTypePtr type)
15622 { 15693 {
15623 /* 15694 /*
15624 * src-simple-type.1 The corresponding simple type definition, if any, 15695 * src-simple-type.1 The corresponding simple type definition, if any,
15625 * must satisfy the conditions set out in Constraints on Simple Type 15696 * must satisfy the conditions set out in Constraints on Simple Type
15626 * Definition Schema Components (§3.14.6). 15697 * Definition Schema Components (�3.14.6).
15627 */ 15698 */
15628 if (WXS_IS_RESTRICTION(type)) { 15699 if (WXS_IS_RESTRICTION(type)) {
15629 /* 15700 /*
15630 * src-simple-type.2 "If the <restriction> alternative is chosen, 15701 * src-simple-type.2 "If the <restriction> alternative is chosen,
15631 * either it must have a base [attribute] or a <simpleType> among its 15702 * either it must have a base [attribute] or a <simpleType> among its
15632 * [children], but not both." 15703 * [children], but not both."
15633 * NOTE: This is checked in the parse function of <restriction>. 15704 * NOTE: This is checked in the parse function of <restriction>.
15634 */ 15705 */
15635 /* 15706 /*
15636 » * 15707 » *
15637 */ 15708 */
15638 } else if (WXS_IS_LIST(type)) { 15709 } else if (WXS_IS_LIST(type)) {
15639 /* src-simple-type.3 "If the <list> alternative is chosen, either it mus t have 15710 /* src-simple-type.3 "If the <list> alternative is chosen, either it mus t have
15640 * an itemType [attribute] or a <simpleType> among its [children], 15711 * an itemType [attribute] or a <simpleType> among its [children],
15641 * but not both." 15712 * but not both."
15642 * 15713 *
15643 * NOTE: This is checked in the parse function of <list>. 15714 * NOTE: This is checked in the parse function of <list>.
15644 */ 15715 */
15645 } else if (WXS_IS_UNION(type)) {» 15716 } else if (WXS_IS_UNION(type)) {
15646 » /* 15717 » /*
15647 * src-simple-type.4 is checked in xmlSchemaCheckUnionTypeDefCircular(). 15718 * src-simple-type.4 is checked in xmlSchemaCheckUnionTypeDefCircular().
15648 */ 15719 */
15649 } 15720 }
15650 return (0); 15721 return (0);
15651 } 15722 }
15652 #endif 15723 #endif
15653 15724
15654 static int 15725 static int
15655 xmlSchemaCreateVCtxtOnPCtxt(xmlSchemaParserCtxtPtr ctxt) 15726 xmlSchemaCreateVCtxtOnPCtxt(xmlSchemaParserCtxtPtr ctxt)
15656 { 15727 {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
15714 * For a string to be a valid default with respect to a type 15785 * For a string to be a valid default with respect to a type
15715 * definition the appropriate case among the following must be true: 15786 * definition the appropriate case among the following must be true:
15716 */ 15787 */
15717 if WXS_IS_COMPLEX(type) { 15788 if WXS_IS_COMPLEX(type) {
15718 /* 15789 /*
15719 * Complex type. 15790 * Complex type.
15720 * 15791 *
15721 * SPEC (2.1) "its {content type} must be a simple type definition 15792 * SPEC (2.1) "its {content type} must be a simple type definition
15722 * or mixed." 15793 * or mixed."
15723 * SPEC (2.2.2) "If the {content type} is mixed, then the {content 15794 * SPEC (2.2.2) "If the {content type} is mixed, then the {content
15724 » * type}'s particle must be ·emptiable· as defined by 15795 » * type}'s particle must be �emptiable� as defined by
15725 » * Particle Emptiable (§3.9.6)." 15796 » * Particle Emptiable (�3.9.6)."
15726 */ 15797 */
15727 if ((! WXS_HAS_SIMPLE_CONTENT(type)) && 15798 if ((! WXS_HAS_SIMPLE_CONTENT(type)) &&
15728 ((! WXS_HAS_MIXED_CONTENT(type)) || (! WXS_EMPTIABLE(type)))) { 15799 ((! WXS_HAS_MIXED_CONTENT(type)) || (! WXS_EMPTIABLE(type)))) {
15729 /* NOTE that this covers (2.2.2) as well. */ 15800 /* NOTE that this covers (2.2.2) as well. */
15730 xmlSchemaPCustomErr(pctxt, 15801 xmlSchemaPCustomErr(pctxt,
15731 XML_SCHEMAP_COS_VALID_DEFAULT_2_1, 15802 XML_SCHEMAP_COS_VALID_DEFAULT_2_1,
15732 WXS_BASIC_CAST type, type->node, 15803 WXS_BASIC_CAST type, type->node,
15733 "For a string to be a valid default, the type definition " 15804 "For a string to be a valid default, the type definition "
15734 "must be a simple type or a complex type with mixed content " 15805 "must be a simple type or a complex type with mixed content "
15735 "and a particle emptiable", NULL); 15806 "and a particle emptiable", NULL);
15736 return(XML_SCHEMAP_COS_VALID_DEFAULT_2_1); 15807 return(XML_SCHEMAP_COS_VALID_DEFAULT_2_1);
15737 } 15808 }
15738 } 15809 }
15739 /* 15810 /*
15740 * 1 If the type definition is a simple type definition, then the string 15811 * 1 If the type definition is a simple type definition, then the string
15741 * must be ·valid· with respect to that definition as defined by String 15812 * must be �valid� with respect to that definition as defined by String
15742 * Valid (§3.14.4). 15813 * Valid (�3.14.4).
15743 * 15814 *
15744 * AND 15815 * AND
15745 * 15816 *
15746 * 2.2.1 If the {content type} is a simple type definition, then the 15817 * 2.2.1 If the {content type} is a simple type definition, then the
15747 * string must be ·valid· with respect to that simple type definition 15818 * string must be �valid� with respect to that simple type definition
15748 * as defined by String Valid (§3.14.4). 15819 * as defined by String Valid (�3.14.4).
15749 */ 15820 */
15750 if (WXS_IS_SIMPLE(type)) 15821 if (WXS_IS_SIMPLE(type))
15751 ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST pctxt, node, 15822 ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST pctxt, node,
15752 type, value, val, 1, 1, 0); 15823 type, value, val, 1, 1, 0);
15753 else if (WXS_HAS_SIMPLE_CONTENT(type)) 15824 else if (WXS_HAS_SIMPLE_CONTENT(type))
15754 ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST pctxt, node, 15825 ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST pctxt, node,
15755 type->contentTypeDef, value, val, 1, 1, 0); 15826 type->contentTypeDef, value, val, 1, 1, 0);
15756 else 15827 else
15757 return (ret); 15828 return (ret);
15758 15829
(...skipping 20 matching lines...) Expand all
15779 */ 15850 */
15780 static int 15851 static int
15781 xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt, 15852 xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
15782 xmlSchemaTypePtr type) 15853 xmlSchemaTypePtr type)
15783 { 15854 {
15784 /* 15855 /*
15785 * TODO: Correct the error code; XML_SCHEMAP_SRC_CT_1 is used temporarily. 15856 * TODO: Correct the error code; XML_SCHEMAP_SRC_CT_1 is used temporarily.
15786 * 15857 *
15787 * SPEC (1) "The values of the properties of a complex type definition must 15858 * SPEC (1) "The values of the properties of a complex type definition must
15788 * be as described in the property tableau in The Complex Type Definition 15859 * be as described in the property tableau in The Complex Type Definition
15789 * Schema Component (§3.4.1), modulo the impact of Missing 15860 * Schema Component (�3.4.1), modulo the impact of Missing
15790 * Sub-components (§5.3)." 15861 * Sub-components (�5.3)."
15791 */ 15862 */
15792 if ((type->baseType != NULL) && 15863 if ((type->baseType != NULL) &&
15793 (WXS_IS_SIMPLE(type->baseType)) && 15864 (WXS_IS_SIMPLE(type->baseType)) &&
15794 (WXS_IS_EXTENSION(type) == 0)) { 15865 (WXS_IS_EXTENSION(type) == 0)) {
15795 /* 15866 /*
15796 * SPEC (2) "If the {base type definition} is a simple type definition, 15867 * SPEC (2) "If the {base type definition} is a simple type definition,
15797 * the {derivation method} must be extension." 15868 * the {derivation method} must be extension."
15798 */ 15869 */
15799 xmlSchemaCustomErr(ACTXT_CAST pctxt, 15870 xmlSchemaCustomErr(ACTXT_CAST pctxt,
15800 XML_SCHEMAP_SRC_CT_1, 15871 XML_SCHEMAP_SRC_CT_1,
15801 » NULL, WXS_BASIC_CAST type, 15872 » NULL, WXS_BASIC_CAST type,
15802 "If the base type is a simple type, the derivation method must be " 15873 "If the base type is a simple type, the derivation method must be "
15803 "'extension'", NULL, NULL); 15874 "'extension'", NULL, NULL);
15804 return (XML_SCHEMAP_SRC_CT_1); 15875 return (XML_SCHEMAP_SRC_CT_1);
15805 } 15876 }
15806 /* 15877 /*
15807 * SPEC (3) "Circular definitions are disallowed, except for the ·ur-type 15878 * SPEC (3) "Circular definitions are disallowed, except for the �ur-type
15808 * definition·. That is, it must be possible to reach the ·ur-type 15879 * definition�. That is, it must be possible to reach the �ur-type
15809 * definition by repeatedly following the {base type definition}." 15880 * definition by repeatedly following the {base type definition}."
15810 * 15881 *
15811 * NOTE (3) is done in xmlSchemaCheckTypeDefCircular(). 15882 * NOTE (3) is done in xmlSchemaCheckTypeDefCircular().
15812 */ 15883 */
15813 /* 15884 /*
15814 * NOTE that (4) and (5) need the following: 15885 * NOTE that (4) and (5) need the following:
15815 * - attribute uses need to be already inherited (apply attr. prohibitions) 15886 * - attribute uses need to be already inherited (apply attr. prohibitions)
15816 * - attribute group references need to be expanded already 15887 * - attribute group references need to be expanded already
15817 * - simple types need to be typefixed already 15888 * - simple types need to be typefixed already
15818 */ 15889 */
15819 if (type->attrUses && 15890 if (type->attrUses &&
15820 (((xmlSchemaItemListPtr) type->attrUses)->nbItems > 1)) 15891 (((xmlSchemaItemListPtr) type->attrUses)->nbItems > 1))
15821 { 15892 {
15822 xmlSchemaItemListPtr uses = (xmlSchemaItemListPtr) type->attrUses; 15893 xmlSchemaItemListPtr uses = (xmlSchemaItemListPtr) type->attrUses;
15823 xmlSchemaAttributeUsePtr use, tmp; 15894 xmlSchemaAttributeUsePtr use, tmp;
15824 int i, j, hasId = 0; 15895 int i, j, hasId = 0;
15825 15896
15826 for (i = uses->nbItems -1; i >= 0; i--) { 15897 for (i = uses->nbItems -1; i >= 0; i--) {
15827 use = uses->items[i]; 15898 use = uses->items[i];
15828 » 15899
15829 » /* 15900 » /*
15830 * SPEC ct-props-correct 15901 * SPEC ct-props-correct
15831 * (4) "Two distinct attribute declarations in the 15902 * (4) "Two distinct attribute declarations in the
15832 * {attribute uses} must not have identical {name}s and 15903 * {attribute uses} must not have identical {name}s and
15833 * {target namespace}s." 15904 * {target namespace}s."
15834 */ 15905 */
15835 if (i > 0) { 15906 if (i > 0) {
15836 for (j = i -1; j >= 0; j--) { 15907 for (j = i -1; j >= 0; j--) {
15837 tmp = uses->items[j]; 15908 tmp = uses->items[j];
15838 if ((WXS_ATTRUSE_DECL_NAME(use) == 15909 if ((WXS_ATTRUSE_DECL_NAME(use) ==
15839 WXS_ATTRUSE_DECL_NAME(tmp)) && 15910 WXS_ATTRUSE_DECL_NAME(tmp)) &&
(...skipping 20 matching lines...) Expand all
15860 } 15931 }
15861 /* 15932 /*
15862 * SPEC ct-props-correct 15933 * SPEC ct-props-correct
15863 * (5) "Two distinct attribute declarations in the 15934 * (5) "Two distinct attribute declarations in the
15864 * {attribute uses} must not have {type definition}s which 15935 * {attribute uses} must not have {type definition}s which
15865 * are or are derived from ID." 15936 * are or are derived from ID."
15866 */ 15937 */
15867 if (WXS_ATTRUSE_TYPEDEF(use) != NULL) { 15938 if (WXS_ATTRUSE_TYPEDEF(use) != NULL) {
15868 if (xmlSchemaIsDerivedFromBuiltInType( 15939 if (xmlSchemaIsDerivedFromBuiltInType(
15869 WXS_ATTRUSE_TYPEDEF(use), XML_SCHEMAS_ID)) 15940 WXS_ATTRUSE_TYPEDEF(use), XML_SCHEMAS_ID))
15870 » » {» » 15941 » » {
15871 if (hasId) { 15942 if (hasId) {
15872 xmlChar *str = NULL; 15943 xmlChar *str = NULL;
15873 » » » 15944
15874 xmlSchemaCustomErr(ACTXT_CAST pctxt, 15945 xmlSchemaCustomErr(ACTXT_CAST pctxt,
15875 XML_SCHEMAP_AG_PROPS_CORRECT, 15946 XML_SCHEMAP_AG_PROPS_CORRECT,
15876 NULL, WXS_BASIC_CAST type, 15947 NULL, WXS_BASIC_CAST type,
15877 "There must not exist more than one attribute " 15948 "There must not exist more than one attribute "
15878 "declaration of type 'xs:ID' " 15949 "declaration of type 'xs:ID' "
15879 "(or derived from 'xs:ID'). The %s violates this " 15950 "(or derived from 'xs:ID'). The %s violates this "
15880 "constraint", 15951 "constraint",
15881 xmlSchemaGetComponentDesignation(&str, use), 15952 xmlSchemaGetComponentDesignation(&str, use),
15882 NULL); 15953 NULL);
15883 FREE_AND_NULL(str); 15954 FREE_AND_NULL(str);
15884 if (xmlSchemaItemListRemove(uses, i) == -1) 15955 if (xmlSchemaItemListRemove(uses, i) == -1)
15885 goto exit_failure; 15956 goto exit_failure;
15886 } 15957 }
15887 » » 15958
15888 hasId = 1; 15959 hasId = 1;
15889 } 15960 }
15890 } 15961 }
15891 next_use: {} 15962 next_use: {}
15892 } 15963 }
15893 } 15964 }
15894 return (0); 15965 return (0);
15895 exit_failure: 15966 exit_failure:
15896 return(-1); 15967 return(-1);
15897 } 15968 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
15951 * SPEC (2.1) "B and D must be the same type definition." 16022 * SPEC (2.1) "B and D must be the same type definition."
15952 */ 16023 */
15953 return (0); 16024 return (0);
15954 } 16025 }
15955 /* 16026 /*
15956 * SPEC (2.2) "B must be D's {base type definition}." 16027 * SPEC (2.2) "B must be D's {base type definition}."
15957 */ 16028 */
15958 if (type->baseType == baseType) 16029 if (type->baseType == baseType)
15959 return (0); 16030 return (0);
15960 /* 16031 /*
15961 * SPEC (2.3.1) "D's {base type definition} must not be the ·ur-type 16032 * SPEC (2.3.1) "D's {base type definition} must not be the �ur-type
15962 * definition·." 16033 * definition�."
15963 */ 16034 */
15964 if (WXS_IS_ANYTYPE(type->baseType)) 16035 if (WXS_IS_ANYTYPE(type->baseType))
15965 return (1); 16036 return (1);
15966 16037
15967 if (WXS_IS_COMPLEX(type->baseType)) { 16038 if (WXS_IS_COMPLEX(type->baseType)) {
15968 /* 16039 /*
15969 * SPEC (2.3.2.1) "If D's {base type definition} is complex, then it 16040 * SPEC (2.3.2.1) "If D's {base type definition} is complex, then it
15970 * must be validly derived from B given the subset as defined by this 16041 * must be validly derived from B given the subset as defined by this
15971 * constraint." 16042 * constraint."
15972 */ 16043 */
15973 return (xmlSchemaCheckCOSCTDerivedOK(actxt, type->baseType, 16044 return (xmlSchemaCheckCOSCTDerivedOK(actxt, type->baseType,
15974 baseType, set)); 16045 baseType, set));
15975 } else { 16046 } else {
15976 /* 16047 /*
15977 * SPEC (2.3.2.2) "If D's {base type definition} is simple, then it 16048 * SPEC (2.3.2.2) "If D's {base type definition} is simple, then it
15978 * must be validly derived from B given the subset as defined in Type 16049 * must be validly derived from B given the subset as defined in Type
15979 » * Derivation OK (Simple) (§3.14.6). 16050 » * Derivation OK (Simple) (�3.14.6).
15980 */ 16051 */
15981 return (xmlSchemaCheckCOSSTDerivedOK(actxt, type->baseType, 16052 return (xmlSchemaCheckCOSSTDerivedOK(actxt, type->baseType,
15982 baseType, set)); 16053 baseType, set));
15983 } 16054 }
15984 } 16055 }
15985 16056
15986 /** 16057 /**
15987 * xmlSchemaCheckCOSDerivedOK: 16058 * xmlSchemaCheckCOSDerivedOK:
15988 * @type: the derived simple type definition 16059 * @type: the derived simple type definition
15989 * @baseType: the base type definition 16060 * @baseType: the base type definition
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
16030 { 16101 {
16031 xmlSchemaTypePtr base = type->baseType; 16102 xmlSchemaTypePtr base = type->baseType;
16032 /* 16103 /*
16033 * TODO: Correct the error code; XML_SCHEMAP_COS_CT_EXTENDS_1_1 is used 16104 * TODO: Correct the error code; XML_SCHEMAP_COS_CT_EXTENDS_1_1 is used
16034 * temporarily only. 16105 * temporarily only.
16035 */ 16106 */
16036 /* 16107 /*
16037 * SPEC (1) "If the {base type definition} is a complex type definition, 16108 * SPEC (1) "If the {base type definition} is a complex type definition,
16038 * then all of the following must be true:" 16109 * then all of the following must be true:"
16039 */ 16110 */
16040 if (WXS_IS_COMPLEX(base)) {» 16111 if (WXS_IS_COMPLEX(base)) {
16041 /* 16112 /*
16042 * SPEC (1.1) "The {final} of the {base type definition} must not 16113 * SPEC (1.1) "The {final} of the {base type definition} must not
16043 * contain extension." 16114 * contain extension."
16044 */ 16115 */
16045 if (base->flags & XML_SCHEMAS_TYPE_FINAL_EXTENSION) { 16116 if (base->flags & XML_SCHEMAS_TYPE_FINAL_EXTENSION) {
16046 xmlSchemaPCustomErr(ctxt, 16117 xmlSchemaPCustomErr(ctxt,
16047 XML_SCHEMAP_COS_CT_EXTENDS_1_1, 16118 XML_SCHEMAP_COS_CT_EXTENDS_1_1,
16048 WXS_BASIC_CAST type, NULL, 16119 WXS_BASIC_CAST type, NULL,
16049 "The 'final' of the base type definition " 16120 "The 'final' of the base type definition "
16050 "contains 'extension'", NULL); 16121 "contains 'extension'", NULL);
16051 return (XML_SCHEMAP_COS_CT_EXTENDS_1_1); 16122 return (XML_SCHEMAP_COS_CT_EXTENDS_1_1);
16052 } 16123 }
16053 » 16124
16054 /* 16125 /*
16055 * ATTENTION: The constrains (1.2) and (1.3) are not applied, 16126 * ATTENTION: The constrains (1.2) and (1.3) are not applied,
16056 * since they are automatically satisfied through the 16127 * since they are automatically satisfied through the
16057 * inheriting mechanism. 16128 * inheriting mechanism.
16058 * Note that even if redefining components, the inheriting mechanism 16129 * Note that even if redefining components, the inheriting mechanism
16059 * is used. 16130 * is used.
16060 */ 16131 */
16061 #if 0 16132 #if 0
16062 /* 16133 /*
16063 * SPEC (1.2) "Its {attribute uses} must be a subset of the {attribute 16134 * SPEC (1.2) "Its {attribute uses} must be a subset of the {attribute
(...skipping 23 matching lines...) Expand all
16087 (WXS_ATTRUSE_TYPEDEF(use) == 16158 (WXS_ATTRUSE_TYPEDEF(use) ==
16088 WXS_ATTRUSE_TYPEDEF(buse)) 16159 WXS_ATTRUSE_TYPEDEF(buse))
16089 { 16160 {
16090 found = 1; 16161 found = 1;
16091 break; 16162 break;
16092 } 16163 }
16093 } 16164 }
16094 } 16165 }
16095 if (! found) { 16166 if (! found) {
16096 xmlChar *str = NULL; 16167 xmlChar *str = NULL;
16097 » » 16168
16098 xmlSchemaCustomErr(ACTXT_CAST ctxt, 16169 xmlSchemaCustomErr(ACTXT_CAST ctxt,
16099 XML_SCHEMAP_COS_CT_EXTENDS_1_2, 16170 XML_SCHEMAP_COS_CT_EXTENDS_1_2,
16100 NULL, WXS_BASIC_CAST type, 16171 NULL, WXS_BASIC_CAST type,
16101 » » » /* 16172 » » » /*
16102 * TODO: The report does not indicate that also the 16173 * TODO: The report does not indicate that also the
16103 * type needs to be the same. 16174 * type needs to be the same.
16104 */ 16175 */
16105 "This type is missing a matching correspondent " 16176 "This type is missing a matching correspondent "
16106 "for its {base type}'s %s in its {attribute uses}", 16177 "for its {base type}'s %s in its {attribute uses}",
16107 xmlSchemaGetComponentDesignation(&str, 16178 xmlSchemaGetComponentDesignation(&str,
16108 buse->children), 16179 buse->children),
16109 NULL); 16180 NULL);
16110 FREE_AND_NULL(str) 16181 FREE_AND_NULL(str)
16111 } 16182 }
16112 } 16183 }
16113 } 16184 }
16114 /* 16185 /*
16115 * SPEC (1.3) "If it has an {attribute wildcard}, the complex type 16186 * SPEC (1.3) "If it has an {attribute wildcard}, the complex type
16116 * definition must also have one, and the base type definition's 16187 * definition must also have one, and the base type definition's
16117 * {attribute wildcard}'s {namespace constraint} must be a subset 16188 * {attribute wildcard}'s {namespace constraint} must be a subset
16118 * of the complex type definition's {attribute wildcard}'s {namespace 16189 * of the complex type definition's {attribute wildcard}'s {namespace
16119 » * constraint}, as defined by Wildcard Subset (§3.10.6)." 16190 » * constraint}, as defined by Wildcard Subset (�3.10.6)."
16120 */ 16191 */
16121 16192
16122 /* 16193 /*
16123 * MAYBE TODO: Enable if ever needed. But this will be needed only 16194 * MAYBE TODO: Enable if ever needed. But this will be needed only
16124 * if created the type via a schema construction API. 16195 * if created the type via a schema construction API.
16125 */ 16196 */
16126 if (base->attributeWildcard != NULL) { 16197 if (base->attributeWildcard != NULL) {
16127 if (type->attributeWilcard == NULL) { 16198 if (type->attributeWilcard == NULL) {
16128 xmlChar *str = NULL; 16199 xmlChar *str = NULL;
16129 » » 16200
16130 xmlSchemaCustomErr(ACTXT_CAST pctxt, 16201 xmlSchemaCustomErr(ACTXT_CAST pctxt,
16131 XML_SCHEMAP_COS_CT_EXTENDS_1_3, 16202 XML_SCHEMAP_COS_CT_EXTENDS_1_3,
16132 NULL, type, 16203 NULL, type,
16133 "The base %s has an attribute wildcard, " 16204 "The base %s has an attribute wildcard, "
16134 "but this type is missing an attribute wildcard", 16205 "but this type is missing an attribute wildcard",
16135 xmlSchemaGetComponentDesignation(&str, base)); 16206 xmlSchemaGetComponentDesignation(&str, base));
16136 FREE_AND_NULL(str) 16207 FREE_AND_NULL(str)
16137 16208
16138 } else if (xmlSchemaCheckCOSNSSubset( 16209 } else if (xmlSchemaCheckCOSNSSubset(
16139 base->attributeWildcard, type->attributeWildcard)) 16210 base->attributeWildcard, type->attributeWildcard))
16140 { 16211 {
16141 xmlChar *str = NULL; 16212 xmlChar *str = NULL;
16142 » » 16213
16143 xmlSchemaCustomErr(ACTXT_CAST pctxt, 16214 xmlSchemaCustomErr(ACTXT_CAST pctxt,
16144 XML_SCHEMAP_COS_CT_EXTENDS_1_3, 16215 XML_SCHEMAP_COS_CT_EXTENDS_1_3,
16145 NULL, type, 16216 NULL, type,
16146 "The attribute wildcard is not a valid " 16217 "The attribute wildcard is not a valid "
16147 "superset of the one in the base %s", 16218 "superset of the one in the base %s",
16148 xmlSchemaGetComponentDesignation(&str, base)); 16219 xmlSchemaGetComponentDesignation(&str, base));
16149 FREE_AND_NULL(str) 16220 FREE_AND_NULL(str)
16150 } 16221 }
16151 } 16222 }
16152 #endif 16223 #endif
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
16206 */ 16277 */
16207 xmlSchemaPCustomErr(ctxt, 16278 xmlSchemaPCustomErr(ctxt,
16208 XML_SCHEMAP_COS_CT_EXTENDS_1_1, 16279 XML_SCHEMAP_COS_CT_EXTENDS_1_1,
16209 WXS_BASIC_CAST type, NULL, 16280 WXS_BASIC_CAST type, NULL,
16210 "The content type of both, the type and its base " 16281 "The content type of both, the type and its base "
16211 "type, must either 'mixed' or 'element-only'", NULL); 16282 "type, must either 'mixed' or 'element-only'", NULL);
16212 return (XML_SCHEMAP_COS_CT_EXTENDS_1_1); 16283 return (XML_SCHEMAP_COS_CT_EXTENDS_1_1);
16213 } 16284 }
16214 /* 16285 /*
16215 * URGENT TODO SPEC (1.4.3.2.2.2) "The particle of the 16286 * URGENT TODO SPEC (1.4.3.2.2.2) "The particle of the
16216 » » * complex type definition must be a ·valid extension· 16287 » » * complex type definition must be a �valid extension�
16217 * of the {base type definition}'s particle, as defined 16288 * of the {base type definition}'s particle, as defined
16218 » » * in Particle Valid (Extension) (§3.9.6)." 16289 » » * in Particle Valid (Extension) (�3.9.6)."
16219 * 16290 *
16220 * NOTE that we won't check "Particle Valid (Extension)", 16291 * NOTE that we won't check "Particle Valid (Extension)",
16221 * since it is ensured by the derivation process in 16292 * since it is ensured by the derivation process in
16222 * xmlSchemaTypeFixup(). We need to implement this when heading 16293 * xmlSchemaTypeFixup(). We need to implement this when heading
16223 * for a construction API 16294 * for a construction API
16224 * TODO: !! This is needed to be checked if redefining a type !! 16295 * TODO: !! This is needed to be checked if redefining a type !!
16225 */ 16296 */
16226 } 16297 }
16227 /* 16298 /*
16228 * URGENT TODO (1.5) 16299 * URGENT TODO (1.5)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
16286 xmlSchemaTypePtr type) 16357 xmlSchemaTypePtr type)
16287 { 16358 {
16288 xmlSchemaTypePtr base; 16359 xmlSchemaTypePtr base;
16289 16360
16290 /* 16361 /*
16291 * TODO: Correct the error code; XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1 is u sed 16362 * TODO: Correct the error code; XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1 is u sed
16292 * temporarily only. 16363 * temporarily only.
16293 */ 16364 */
16294 base = type->baseType; 16365 base = type->baseType;
16295 if (! WXS_IS_COMPLEX(base)) { 16366 if (! WXS_IS_COMPLEX(base)) {
16296 » xmlSchemaCustomErr(ACTXT_CAST ctxt,» 16367 » xmlSchemaCustomErr(ACTXT_CAST ctxt,
16297 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, 16368 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1,
16298 type->node, WXS_BASIC_CAST type, 16369 type->node, WXS_BASIC_CAST type,
16299 "The base type must be a complex type", NULL, NULL); 16370 "The base type must be a complex type", NULL, NULL);
16300 return(ctxt->err); 16371 return(ctxt->err);
16301 } 16372 }
16302 if (base->flags & XML_SCHEMAS_TYPE_FINAL_RESTRICTION) { 16373 if (base->flags & XML_SCHEMAS_TYPE_FINAL_RESTRICTION) {
16303 /* 16374 /*
16304 * SPEC (1) "The {base type definition} must be a complex type 16375 * SPEC (1) "The {base type definition} must be a complex type
16305 * definition whose {final} does not contain restriction." 16376 * definition whose {final} does not contain restriction."
16306 */ 16377 */
16307 » xmlSchemaCustomErr(ACTXT_CAST ctxt,» 16378 » xmlSchemaCustomErr(ACTXT_CAST ctxt,
16308 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, 16379 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1,
16309 type->node, WXS_BASIC_CAST type, 16380 type->node, WXS_BASIC_CAST type,
16310 "The 'final' of the base type definition " 16381 "The 'final' of the base type definition "
16311 "contains 'restriction'", NULL, NULL); 16382 "contains 'restriction'", NULL, NULL);
16312 return (ctxt->err); 16383 return (ctxt->err);
16313 } 16384 }
16314 /* 16385 /*
16315 * SPEC (2), (3) and (4) 16386 * SPEC (2), (3) and (4)
16316 * Those are handled in a separate function, since the 16387 * Those are handled in a separate function, since the
16317 * same constraints are needed for redefinition of 16388 * same constraints are needed for redefinition of
16318 * attribute groups as well. 16389 * attribute groups as well.
16319 */ 16390 */
16320 if (xmlSchemaCheckDerivationOKRestriction2to4(ctxt, 16391 if (xmlSchemaCheckDerivationOKRestriction2to4(ctxt,
16321 XML_SCHEMA_ACTION_DERIVE, 16392 XML_SCHEMA_ACTION_DERIVE,
16322 WXS_BASIC_CAST type, WXS_BASIC_CAST base, 16393 WXS_BASIC_CAST type, WXS_BASIC_CAST base,
16323 type->attrUses, base->attrUses, 16394 type->attrUses, base->attrUses,
16324 type->attributeWildcard, 16395 type->attributeWildcard,
16325 base->attributeWildcard) == -1) 16396 base->attributeWildcard) == -1)
16326 { 16397 {
16327 return(-1); 16398 return(-1);
16328 } 16399 }
16329 /* 16400 /*
16330 * SPEC (5) "One of the following must be true:" 16401 * SPEC (5) "One of the following must be true:"
16331 */ 16402 */
16332 if (base->builtInType == XML_SCHEMAS_ANYTYPE) { 16403 if (base->builtInType == XML_SCHEMAS_ANYTYPE) {
16333 /* 16404 /*
16334 * SPEC (5.1) "The {base type definition} must be the 16405 * SPEC (5.1) "The {base type definition} must be the
16335 » * ·ur-type definition·." 16406 » * �ur-type definition�."
16336 * PASS 16407 * PASS
16337 */ 16408 */
16338 } else if ((type->contentType == XML_SCHEMA_CONTENT_SIMPLE) || 16409 } else if ((type->contentType == XML_SCHEMA_CONTENT_SIMPLE) ||
16339 (type->contentType == XML_SCHEMA_CONTENT_BASIC)) { 16410 (type->contentType == XML_SCHEMA_CONTENT_BASIC)) {
16340 /* 16411 /*
16341 * SPEC (5.2.1) "The {content type} of the complex type definition 16412 * SPEC (5.2.1) "The {content type} of the complex type definition
16342 * must be a simple type definition" 16413 * must be a simple type definition"
16343 * 16414 *
16344 * SPEC (5.2.2) "One of the following must be true:" 16415 * SPEC (5.2.2) "One of the following must be true:"
16345 */ 16416 */
16346 if ((base->contentType == XML_SCHEMA_CONTENT_SIMPLE) || 16417 if ((base->contentType == XML_SCHEMA_CONTENT_SIMPLE) ||
16347 (base->contentType == XML_SCHEMA_CONTENT_BASIC)) 16418 (base->contentType == XML_SCHEMA_CONTENT_BASIC))
16348 { 16419 {
16349 int err; 16420 int err;
16350 /* 16421 /*
16351 * SPEC (5.2.2.1) "The {content type} of the {base type 16422 * SPEC (5.2.2.1) "The {content type} of the {base type
16352 * definition} must be a simple type definition from which 16423 * definition} must be a simple type definition from which
16353 * the {content type} is validly derived given the empty 16424 * the {content type} is validly derived given the empty
16354 » * set as defined in Type Derivation OK (Simple) (§3.14.6)." 16425 » * set as defined in Type Derivation OK (Simple) (�3.14.6)."
16355 * 16426 *
16356 * ATTENTION TODO: This seems not needed if the type implicitely 16427 * ATTENTION TODO: This seems not needed if the type implicitely
16357 * derived from the base type. 16428 * derived from the base type.
16358 » * 16429 » *
16359 */ 16430 */
16360 err = xmlSchemaCheckCOSSTDerivedOK(ACTXT_CAST ctxt, 16431 err = xmlSchemaCheckCOSSTDerivedOK(ACTXT_CAST ctxt,
16361 type->contentTypeDef, base->contentTypeDef, 0); 16432 type->contentTypeDef, base->contentTypeDef, 0);
16362 if (err != 0) { 16433 if (err != 0) {
16363 xmlChar *strA = NULL, *strB = NULL; 16434 xmlChar *strA = NULL, *strB = NULL;
16364 16435
16365 if (err == -1) 16436 if (err == -1)
16366 return(-1); 16437 return(-1);
16367 xmlSchemaCustomErr(ACTXT_CAST ctxt, 16438 xmlSchemaCustomErr(ACTXT_CAST ctxt,
16368 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, 16439 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1,
16369 NULL, WXS_BASIC_CAST type, 16440 NULL, WXS_BASIC_CAST type,
16370 "The {content type} %s is not validly derived from the " 16441 "The {content type} %s is not validly derived from the "
16371 "base type's {content type} %s", 16442 "base type's {content type} %s",
16372 xmlSchemaGetComponentDesignation(&strA, 16443 xmlSchemaGetComponentDesignation(&strA,
16373 type->contentTypeDef), 16444 type->contentTypeDef),
16374 xmlSchemaGetComponentDesignation(&strB, 16445 xmlSchemaGetComponentDesignation(&strB,
16375 base->contentTypeDef)); 16446 base->contentTypeDef));
16376 FREE_AND_NULL(strA); 16447 FREE_AND_NULL(strA);
16377 FREE_AND_NULL(strB); 16448 FREE_AND_NULL(strB);
16378 return(ctxt->err); 16449 return(ctxt->err);
16379 } 16450 }
16380 } else if ((base->contentType == XML_SCHEMA_CONTENT_MIXED) && 16451 } else if ((base->contentType == XML_SCHEMA_CONTENT_MIXED) &&
16381 (xmlSchemaIsParticleEmptiable( 16452 (xmlSchemaIsParticleEmptiable(
16382 (xmlSchemaParticlePtr) base->subtypes))) { 16453 (xmlSchemaParticlePtr) base->subtypes))) {
16383 /* 16454 /*
16384 * SPEC (5.2.2.2) "The {base type definition} must be mixed 16455 * SPEC (5.2.2.2) "The {base type definition} must be mixed
16385 » * and have a particle which is ·emptiable· as defined in 16456 » * and have a particle which is �emptiable� as defined in
16386 » * Particle Emptiable (§3.9.6)." 16457 » * Particle Emptiable (�3.9.6)."
16387 * PASS 16458 * PASS
16388 */ 16459 */
16389 } else { 16460 } else {
16390 xmlSchemaPCustomErr(ctxt, 16461 xmlSchemaPCustomErr(ctxt,
16391 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, 16462 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1,
16392 WXS_BASIC_CAST type, NULL, 16463 WXS_BASIC_CAST type, NULL,
16393 "The content type of the base type must be either " 16464 "The content type of the base type must be either "
16394 "a simple type or 'mixed' and an emptiable particle", NULL); 16465 "a simple type or 'mixed' and an emptiable particle", NULL);
16395 return (ctxt->err); 16466 return (ctxt->err);
16396 } 16467 }
16397 } else if (type->contentType == XML_SCHEMA_CONTENT_EMPTY) { 16468 } else if (type->contentType == XML_SCHEMA_CONTENT_EMPTY) {
16398 /* 16469 /*
16399 * SPEC (5.3.1) "The {content type} of the complex type itself must 16470 * SPEC (5.3.1) "The {content type} of the complex type itself must
16400 * be empty" 16471 * be empty"
16401 */ 16472 */
16402 if (base->contentType == XML_SCHEMA_CONTENT_EMPTY) { 16473 if (base->contentType == XML_SCHEMA_CONTENT_EMPTY) {
16403 /* 16474 /*
16404 * SPEC (5.3.2.1) "The {content type} of the {base type 16475 * SPEC (5.3.2.1) "The {content type} of the {base type
16405 * definition} must also be empty." 16476 * definition} must also be empty."
16406 * PASS 16477 * PASS
16407 */ 16478 */
16408 } else if (((base->contentType == XML_SCHEMA_CONTENT_ELEMENTS) || 16479 } else if (((base->contentType == XML_SCHEMA_CONTENT_ELEMENTS) ||
16409 (base->contentType == XML_SCHEMA_CONTENT_MIXED)) && 16480 (base->contentType == XML_SCHEMA_CONTENT_MIXED)) &&
16410 xmlSchemaIsParticleEmptiable( 16481 xmlSchemaIsParticleEmptiable(
16411 (xmlSchemaParticlePtr) base->subtypes)) { 16482 (xmlSchemaParticlePtr) base->subtypes)) {
16412 /* 16483 /*
16413 * SPEC (5.3.2.2) "The {content type} of the {base type 16484 * SPEC (5.3.2.2) "The {content type} of the {base type
16414 * definition} must be elementOnly or mixed and have a particle 16485 * definition} must be elementOnly or mixed and have a particle
16415 » * which is ·emptiable· as defined in Particle Emptiable (§3.9.6)." 16486 » * which is �emptiable� as defined in Particle Emptiable (�3.9. 6)."
16416 * PASS 16487 * PASS
16417 */ 16488 */
16418 } else { 16489 } else {
16419 xmlSchemaPCustomErr(ctxt, 16490 xmlSchemaPCustomErr(ctxt,
16420 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, 16491 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1,
16421 WXS_BASIC_CAST type, NULL, 16492 WXS_BASIC_CAST type, NULL,
16422 "The content type of the base type must be either " 16493 "The content type of the base type must be either "
16423 "empty or 'mixed' (or 'elements-only') and an emptiable " 16494 "empty or 'mixed' (or 'elements-only') and an emptiable "
16424 "particle", NULL); 16495 "particle", NULL);
16425 return (ctxt->err); 16496 return (ctxt->err);
16426 } 16497 }
16427 } else if ((type->contentType == XML_SCHEMA_CONTENT_ELEMENTS) || 16498 } else if ((type->contentType == XML_SCHEMA_CONTENT_ELEMENTS) ||
16428 WXS_HAS_MIXED_CONTENT(type)) { 16499 WXS_HAS_MIXED_CONTENT(type)) {
16429 /* 16500 /*
16430 * SPEC (5.4.1.1) "The {content type} of the complex type definition 16501 * SPEC (5.4.1.1) "The {content type} of the complex type definition
16431 * itself must be element-only" 16502 * itself must be element-only"
16432 » */» 16503 » */
16433 if (WXS_HAS_MIXED_CONTENT(type) && (! WXS_HAS_MIXED_CONTENT(base))) { 16504 if (WXS_HAS_MIXED_CONTENT(type) && (! WXS_HAS_MIXED_CONTENT(base))) {
16434 /* 16505 /*
16435 * SPEC (5.4.1.2) "The {content type} of the complex type 16506 * SPEC (5.4.1.2) "The {content type} of the complex type
16436 * definition itself and of the {base type definition} must be 16507 * definition itself and of the {base type definition} must be
16437 * mixed" 16508 * mixed"
16438 */ 16509 */
16439 xmlSchemaPCustomErr(ctxt, 16510 xmlSchemaPCustomErr(ctxt,
16440 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, 16511 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1,
16441 WXS_BASIC_CAST type, NULL, 16512 WXS_BASIC_CAST type, NULL,
16442 "If the content type is 'mixed', then the content type of the " 16513 "If the content type is 'mixed', then the content type of the "
16443 "base type must also be 'mixed'", NULL); 16514 "base type must also be 'mixed'", NULL);
16444 return (ctxt->err); 16515 return (ctxt->err);
16445 } 16516 }
16446 /* 16517 /*
16447 * SPEC (5.4.2) "The particle of the complex type definition itself 16518 * SPEC (5.4.2) "The particle of the complex type definition itself
16448 » * must be a ·valid restriction· of the particle of the {content 16519 » * must be a �valid restriction� of the particle of the {content
16449 * type} of the {base type definition} as defined in Particle Valid 16520 * type} of the {base type definition} as defined in Particle Valid
16450 » * (Restriction) (§3.9.6). 16521 » * (Restriction) (�3.9.6).
16451 * 16522 *
16452 * URGENT TODO: (5.4.2) 16523 * URGENT TODO: (5.4.2)
16453 */ 16524 */
16454 } else { 16525 } else {
16455 xmlSchemaPCustomErr(ctxt, 16526 xmlSchemaPCustomErr(ctxt,
16456 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, 16527 XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1,
16457 WXS_BASIC_CAST type, NULL, 16528 WXS_BASIC_CAST type, NULL,
16458 "The type is not a valid restriction of its base type", NULL); 16529 "The type is not a valid restriction of its base type", NULL);
16459 return (ctxt->err); 16530 return (ctxt->err);
16460 } 16531 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
16509 int ret = 0; 16580 int ret = 0;
16510 16581
16511 /* 16582 /*
16512 * TODO: Adjust the error codes here, as I used 16583 * TODO: Adjust the error codes here, as I used
16513 * XML_SCHEMAP_SRC_CT_1 only yet. 16584 * XML_SCHEMAP_SRC_CT_1 only yet.
16514 */ 16585 */
16515 base = type->baseType; 16586 base = type->baseType;
16516 if (! WXS_HAS_SIMPLE_CONTENT(type)) { 16587 if (! WXS_HAS_SIMPLE_CONTENT(type)) {
16517 /* 16588 /*
16518 * 1 If the <complexContent> alternative is chosen, the type definition 16589 * 1 If the <complexContent> alternative is chosen, the type definition
16519 » * ·resolved· to by the ·actual value· of the base [attribute] 16590 » * �resolved� to by the �actual value� of the base [attribute]
16520 * must be a complex type definition; 16591 * must be a complex type definition;
16521 */ 16592 */
16522 if (! WXS_IS_COMPLEX(base)) { 16593 if (! WXS_IS_COMPLEX(base)) {
16523 xmlChar *str = NULL; 16594 xmlChar *str = NULL;
16524 xmlSchemaPCustomErr(ctxt, 16595 xmlSchemaPCustomErr(ctxt,
16525 XML_SCHEMAP_SRC_CT_1, 16596 XML_SCHEMAP_SRC_CT_1,
16526 WXS_BASIC_CAST type, type->node, 16597 WXS_BASIC_CAST type, type->node,
16527 "If using <complexContent>, the base type is expected to be " 16598 "If using <complexContent>, the base type is expected to be "
16528 "a complex type. The base type '%s' is a simple type", 16599 "a complex type. The base type '%s' is a simple type",
16529 xmlSchemaFormatQName(&str, base->targetNamespace, 16600 xmlSchemaFormatQName(&str, base->targetNamespace,
16530 base->name)); 16601 base->name));
16531 FREE_AND_NULL(str) 16602 FREE_AND_NULL(str)
16532 return (XML_SCHEMAP_SRC_CT_1); 16603 return (XML_SCHEMAP_SRC_CT_1);
16533 } 16604 }
16534 } else { 16605 } else {
16535 /* 16606 /*
16536 * SPEC 16607 * SPEC
16537 * 2 If the <simpleContent> alternative is chosen, all of the 16608 * 2 If the <simpleContent> alternative is chosen, all of the
16538 * following must be true: 16609 * following must be true:
16539 » * 2.1 The type definition ·resolved· to by the ·actual value· of the 16610 » * 2.1 The type definition �resolved� to by the �actual value� of the
16540 * base [attribute] must be one of the following: 16611 * base [attribute] must be one of the following:
16541 */ 16612 */
16542 if (WXS_IS_SIMPLE(base)) { 16613 if (WXS_IS_SIMPLE(base)) {
16543 if (WXS_IS_EXTENSION(type) == 0) { 16614 if (WXS_IS_EXTENSION(type) == 0) {
16544 xmlChar *str = NULL; 16615 xmlChar *str = NULL;
16545 /* 16616 /*
16546 * 2.1.3 only if the <extension> alternative is also 16617 * 2.1.3 only if the <extension> alternative is also
16547 * chosen, a simple type definition. 16618 * chosen, a simple type definition.
16548 */ 16619 */
16549 /* TODO: Change error code to ..._SRC_CT_2_1_3. */ 16620 /* TODO: Change error code to ..._SRC_CT_2_1_3. */
(...skipping 29 matching lines...) Expand all
16579 (WXS_IS_RESTRICTION(type))) { 16650 (WXS_IS_RESTRICTION(type))) {
16580 16651
16581 /* 16652 /*
16582 * 2.1.2 only if the <restriction> alternative is also 16653 * 2.1.2 only if the <restriction> alternative is also
16583 * chosen, a complex type definition whose {content type} 16654 * chosen, a complex type definition whose {content type}
16584 * is mixed and a particle emptiable. 16655 * is mixed and a particle emptiable.
16585 */ 16656 */
16586 if (! xmlSchemaIsParticleEmptiable( 16657 if (! xmlSchemaIsParticleEmptiable(
16587 (xmlSchemaParticlePtr) base->subtypes)) { 16658 (xmlSchemaParticlePtr) base->subtypes)) {
16588 ret = XML_SCHEMAP_SRC_CT_1; 16659 ret = XML_SCHEMAP_SRC_CT_1;
16589 » » } else 16660 » » } else
16590 /* 16661 /*
16591 * Attention: at this point the <simpleType> child is in 16662 * Attention: at this point the <simpleType> child is in
16592 * ->contentTypeDef (put there during parsing). 16663 * ->contentTypeDef (put there during parsing).
16593 » » */» » 16664 » » */
16594 if (type->contentTypeDef == NULL) { 16665 if (type->contentTypeDef == NULL) {
16595 xmlChar *str = NULL; 16666 xmlChar *str = NULL;
16596 /* 16667 /*
16597 * 2.2 If clause 2.1.2 above is satisfied, then there 16668 * 2.2 If clause 2.1.2 above is satisfied, then there
16598 * must be a <simpleType> among the [children] of 16669 * must be a <simpleType> among the [children] of
16599 * <restriction>. 16670 * <restriction>.
16600 */ 16671 */
16601 /* TODO: Change error code to ..._SRC_CT_2_2. */ 16672 /* TODO: Change error code to ..._SRC_CT_2_2. */
16602 xmlSchemaPCustomErr(ctxt, 16673 xmlSchemaPCustomErr(ctxt,
16603 XML_SCHEMAP_SRC_CT_1, 16674 XML_SCHEMAP_SRC_CT_1,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
16635 "is a complex type", 16706 "is a complex type",
16636 xmlSchemaFormatQName(&str, base->targetNamespace, 16707 xmlSchemaFormatQName(&str, base->targetNamespace,
16637 base->name)); 16708 base->name));
16638 } 16709 }
16639 FREE_AND_NULL(str) 16710 FREE_AND_NULL(str)
16640 } 16711 }
16641 } 16712 }
16642 /* 16713 /*
16643 * SPEC (3) "The corresponding complex type definition component must 16714 * SPEC (3) "The corresponding complex type definition component must
16644 * satisfy the conditions set out in Constraints on Complex Type 16715 * satisfy the conditions set out in Constraints on Complex Type
16645 * Definition Schema Components (§3.4.6);" 16716 * Definition Schema Components (�3.4.6);"
16646 * NOTE (3) will be done in xmlSchemaTypeFixup(). 16717 * NOTE (3) will be done in xmlSchemaTypeFixup().
16647 */ 16718 */
16648 /* 16719 /*
16649 * SPEC (4) If clause 2.2.1 or clause 2.2.2 in the correspondence specificati on 16720 * SPEC (4) If clause 2.2.1 or clause 2.2.2 in the correspondence specificati on
16650 * above for {attribute wildcard} is satisfied, the intensional 16721 * above for {attribute wildcard} is satisfied, the intensional
16651 * intersection must be expressible, as defined in Attribute Wildcard 16722 * intersection must be expressible, as defined in Attribute Wildcard
16652 * Intersection (§3.10.6). 16723 * Intersection (�3.10.6).
16653 * NOTE (4) is done in xmlSchemaFixupTypeAttributeUses(). 16724 * NOTE (4) is done in xmlSchemaFixupTypeAttributeUses().
16654 */ 16725 */
16655 return (ret); 16726 return (ret);
16656 } 16727 }
16657 16728
16658 #ifdef ENABLE_PARTICLE_RESTRICTION 16729 #ifdef ENABLE_PARTICLE_RESTRICTION
16659 /** 16730 /**
16660 * xmlSchemaCheckParticleRangeOK: 16731 * xmlSchemaCheckParticleRangeOK:
16661 * @ctxt: the schema parser context 16732 * @ctxt: the schema parser context
16662 * @type: the complex type definition 16733 * @type: the complex type definition
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
16713 /* 16784 /*
16714 * SPEC (1) "The declarations' {name}s and {target namespace}s are 16785 * SPEC (1) "The declarations' {name}s and {target namespace}s are
16715 * the same." 16786 * the same."
16716 */ 16787 */
16717 if ((elemR != elemB) && 16788 if ((elemR != elemB) &&
16718 ((! xmlStrEqual(elemR->name, elemB->name)) || 16789 ((! xmlStrEqual(elemR->name, elemB->name)) ||
16719 (! xmlStrEqual(elemR->targetNamespace, elemB->targetNamespace)))) 16790 (! xmlStrEqual(elemR->targetNamespace, elemB->targetNamespace))))
16720 return (1); 16791 return (1);
16721 /* 16792 /*
16722 * SPEC (2) "R's occurrence range is a valid restriction of B's 16793 * SPEC (2) "R's occurrence range is a valid restriction of B's
16723 * occurrence range as defined by Occurrence Range OK (§3.9.6)." 16794 * occurrence range as defined by Occurrence Range OK (�3.9.6)."
16724 */ 16795 */
16725 if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs, 16796 if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs,
16726 b->minOccurs, b->maxOccurs) != 0) 16797 b->minOccurs, b->maxOccurs) != 0)
16727 return (1); 16798 return (1);
16728 /* 16799 /*
16729 * SPEC (3.1) "Both B's declaration's {scope} and R's declaration's 16800 * SPEC (3.1) "Both B's declaration's {scope} and R's declaration's
16730 * {scope} are global." 16801 * {scope} are global."
16731 */ 16802 */
16732 if (elemR == elemB) 16803 if (elemR == elemB)
16733 return (0); 16804 return (0);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
16805 * Returns 0 if the constraints are satisfied, a positive 16876 * Returns 0 if the constraints are satisfied, a positive
16806 * error code if not and -1 if an internal error occured. 16877 * error code if not and -1 if an internal error occured.
16807 */ 16878 */
16808 static int 16879 static int
16809 xmlSchemaCheckRCaseNSCompat(xmlSchemaParserCtxtPtr ctxt, 16880 xmlSchemaCheckRCaseNSCompat(xmlSchemaParserCtxtPtr ctxt,
16810 xmlSchemaParticlePtr r, 16881 xmlSchemaParticlePtr r,
16811 xmlSchemaParticlePtr b) 16882 xmlSchemaParticlePtr b)
16812 { 16883 {
16813 /* TODO:Error codes (rcase-NSCompat). */ 16884 /* TODO:Error codes (rcase-NSCompat). */
16814 /* 16885 /*
16815 * SPEC "For an element declaration particle to be a ·valid restriction· 16886 * SPEC "For an element declaration particle to be a �valid restriction�
16816 * of a wildcard particle all of the following must be true:" 16887 * of a wildcard particle all of the following must be true:"
16817 * 16888 *
16818 * SPEC (1) "The element declaration's {target namespace} is ·valid· 16889 * SPEC (1) "The element declaration's {target namespace} is �valid�
16819 * with respect to the wildcard's {namespace constraint} as defined by 16890 * with respect to the wildcard's {namespace constraint} as defined by
16820 * Wildcard allows Namespace Name (§3.10.4)." 16891 * Wildcard allows Namespace Name (�3.10.4)."
16821 */ 16892 */
16822 if (xmlSchemaCheckCVCWildcardNamespace((xmlSchemaWildcardPtr) b->children, 16893 if (xmlSchemaCheckCVCWildcardNamespace((xmlSchemaWildcardPtr) b->children,
16823 ((xmlSchemaElementPtr) r->children)->targetNamespace) != 0) 16894 ((xmlSchemaElementPtr) r->children)->targetNamespace) != 0)
16824 return (1); 16895 return (1);
16825 /* 16896 /*
16826 * SPEC (2) "R's occurrence range is a valid restriction of B's 16897 * SPEC (2) "R's occurrence range is a valid restriction of B's
16827 * occurrence range as defined by Occurrence Range OK (§3.9.6)." 16898 * occurrence range as defined by Occurrence Range OK (�3.9.6)."
16828 */ 16899 */
16829 if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs, 16900 if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs,
16830 b->minOccurs, b->maxOccurs) != 0) 16901 b->minOccurs, b->maxOccurs) != 0)
16831 return (1); 16902 return (1);
16832 16903
16833 return (0); 16904 return (0);
16834 } 16905 }
16835 16906
16836 /** 16907 /**
16837 * xmlSchemaCheckRCaseRecurseAsIfGroup: 16908 * xmlSchemaCheckRCaseRecurseAsIfGroup:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
16877 */ 16948 */
16878 static int 16949 static int
16879 xmlSchemaCheckRCaseNSSubset(xmlSchemaParserCtxtPtr ctxt, 16950 xmlSchemaCheckRCaseNSSubset(xmlSchemaParserCtxtPtr ctxt,
16880 xmlSchemaParticlePtr r, 16951 xmlSchemaParticlePtr r,
16881 xmlSchemaParticlePtr b, 16952 xmlSchemaParticlePtr b,
16882 int isAnyTypeBase) 16953 int isAnyTypeBase)
16883 { 16954 {
16884 /* TODO: Error codes (rcase-NSSubset). */ 16955 /* TODO: Error codes (rcase-NSSubset). */
16885 /* 16956 /*
16886 * SPEC (1) "R's occurrence range is a valid restriction of B's 16957 * SPEC (1) "R's occurrence range is a valid restriction of B's
16887 * occurrence range as defined by Occurrence Range OK (§3.9.6)." 16958 * occurrence range as defined by Occurrence Range OK (�3.9.6)."
16888 */ 16959 */
16889 if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs, 16960 if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs,
16890 b->minOccurs, b->maxOccurs)) 16961 b->minOccurs, b->maxOccurs))
16891 return (1); 16962 return (1);
16892 /* 16963 /*
16893 * SPEC (2) "R's {namespace constraint} must be an intensional subset 16964 * SPEC (2) "R's {namespace constraint} must be an intensional subset
16894 * of B's {namespace constraint} as defined by Wildcard Subset (§3.10.6)." 16965 * of B's {namespace constraint} as defined by Wildcard Subset (�3.10.6)."
16895 */ 16966 */
16896 if (xmlSchemaCheckCOSNSSubset((xmlSchemaWildcardPtr) r->children, 16967 if (xmlSchemaCheckCOSNSSubset((xmlSchemaWildcardPtr) r->children,
16897 (xmlSchemaWildcardPtr) b->children)) 16968 (xmlSchemaWildcardPtr) b->children))
16898 return (1); 16969 return (1);
16899 /* 16970 /*
16900 * SPEC (3) "Unless B is the content model wildcard of the ·ur-type 16971 * SPEC (3) "Unless B is the content model wildcard of the �ur-type
16901 * definition·, R's {process contents} must be identical to or stronger 16972 * definition�, R's {process contents} must be identical to or stronger
16902 * than B's {process contents}, where strict is stronger than lax is 16973 * than B's {process contents}, where strict is stronger than lax is
16903 * stronger than skip." 16974 * stronger than skip."
16904 */ 16975 */
16905 if (! isAnyTypeBase) { 16976 if (! isAnyTypeBase) {
16906 if ( ((xmlSchemaWildcardPtr) r->children)->processContents < 16977 if ( ((xmlSchemaWildcardPtr) r->children)->processContents <
16907 ((xmlSchemaWildcardPtr) b->children)->processContents) 16978 ((xmlSchemaWildcardPtr) b->children)->processContents)
16908 return (1); 16979 return (1);
16909 } 16980 }
16910 16981
16911 return (0); 16982 return (0);
(...skipping 29 matching lines...) Expand all
16941 /* 17012 /*
16942 * SPEC (1) "They are the same particle." 17013 * SPEC (1) "They are the same particle."
16943 */ 17014 */
16944 if (r == b) 17015 if (r == b)
16945 return (0); 17016 return (0);
16946 17017
16947 17018
16948 return (0); 17019 return (0);
16949 } 17020 }
16950 17021
17022 #if 0
16951 /** 17023 /**
16952 * xmlSchemaCheckRCaseNSRecurseCheckCardinality: 17024 * xmlSchemaCheckRCaseNSRecurseCheckCardinality:
16953 * @ctxt: the schema parser context 17025 * @ctxt: the schema parser context
16954 * @r: the model group particle 17026 * @r: the model group particle
16955 * @b: the base wildcard particle 17027 * @b: the base wildcard particle
16956 * 17028 *
16957 * (3.9.6) Constraints on Particle Schema Components 17029 * (3.9.6) Constraints on Particle Schema Components
16958 * Schema Component Constraint: 17030 * Schema Component Constraint:
16959 * Particle Derivation OK (All/Choice/Sequence:Any -- 17031 * Particle Derivation OK (All/Choice/Sequence:Any --
16960 * NSRecurseCheckCardinality) 17032 * NSRecurseCheckCardinality)
16961 * (rcase-NSRecurseCheckCardinality) 17033 * (rcase-NSRecurseCheckCardinality)
16962 * 17034 *
16963 * STATUS: TODO: subst-groups 17035 * STATUS: TODO: subst-groups
16964 * 17036 *
16965 * Returns 0 if the constraints are satisfied, a positive 17037 * Returns 0 if the constraints are satisfied, a positive
16966 * error code if not and -1 if an internal error occured. 17038 * error code if not and -1 if an internal error occured.
16967 */ 17039 */
16968 static int 17040 static int
16969 xmlSchemaCheckRCaseNSRecurseCheckCardinality(xmlSchemaParserCtxtPtr ctxt, 17041 xmlSchemaCheckRCaseNSRecurseCheckCardinality(xmlSchemaParserCtxtPtr ctxt,
16970 xmlSchemaParticlePtr r, 17042 xmlSchemaParticlePtr r,
16971 xmlSchemaParticlePtr b) 17043 xmlSchemaParticlePtr b)
16972 { 17044 {
16973 xmlSchemaParticlePtr part; 17045 xmlSchemaParticlePtr part;
16974 /* TODO: Error codes (rcase-NSRecurseCheckCardinality). */ 17046 /* TODO: Error codes (rcase-NSRecurseCheckCardinality). */
16975 if ((r->children == NULL) || (r->children->children == NULL)) 17047 if ((r->children == NULL) || (r->children->children == NULL))
16976 return (-1); 17048 return (-1);
16977 /* 17049 /*
16978 * SPEC "For a group particle to be a ·valid restriction· of a 17050 * SPEC "For a group particle to be a �valid restriction� of a
16979 * wildcard particle..." 17051 * wildcard particle..."
16980 * 17052 *
16981 * SPEC (1) "Every member of the {particles} of the group is a ·valid 17053 * SPEC (1) "Every member of the {particles} of the group is a �valid
16982 * restriction· of the wildcard as defined by 17054 * restriction� of the wildcard as defined by
16983 * Particle Valid (Restriction) (§3.9.6)." 17055 * Particle Valid (Restriction) (�3.9.6)."
16984 */ 17056 */
16985 part = (xmlSchemaParticlePtr) r->children->children; 17057 part = (xmlSchemaParticlePtr) r->children->children;
16986 do { 17058 do {
16987 if (xmlSchemaCheckCOSParticleRestrict(ctxt, part, b)) 17059 if (xmlSchemaCheckCOSParticleRestrict(ctxt, part, b))
16988 return (1); 17060 return (1);
16989 part = (xmlSchemaParticlePtr) part->next; 17061 part = (xmlSchemaParticlePtr) part->next;
16990 } while (part != NULL); 17062 } while (part != NULL);
16991 /* 17063 /*
16992 * SPEC (2) "The effective total range of the group [...] is a 17064 * SPEC (2) "The effective total range of the group [...] is a
16993 * valid restriction of B's occurrence range as defined by 17065 * valid restriction of B's occurrence range as defined by
16994 * Occurrence Range OK (§3.9.6)." 17066 * Occurrence Range OK (�3.9.6)."
16995 */ 17067 */
16996 if (xmlSchemaCheckParticleRangeOK( 17068 if (xmlSchemaCheckParticleRangeOK(
16997 xmlSchemaGetParticleTotalRangeMin(r), 17069 xmlSchemaGetParticleTotalRangeMin(r),
16998 xmlSchemaGetParticleTotalRangeMax(r), 17070 xmlSchemaGetParticleTotalRangeMax(r),
16999 b->minOccurs, b->maxOccurs) != 0) 17071 b->minOccurs, b->maxOccurs) != 0)
17000 return (1); 17072 return (1);
17001 return (0); 17073 return (0);
17002 } 17074 }
17075 #endif
17003 17076
17004 /** 17077 /**
17005 * xmlSchemaCheckRCaseRecurse: 17078 * xmlSchemaCheckRCaseRecurse:
17006 * @ctxt: the schema parser context 17079 * @ctxt: the schema parser context
17007 * @r: the <all> or <sequence> model group particle 17080 * @r: the <all> or <sequence> model group particle
17008 * @b: the base <all> or <sequence> model group particle 17081 * @b: the base <all> or <sequence> model group particle
17009 * 17082 *
17010 * (3.9.6) Constraints on Particle Schema Components 17083 * (3.9.6) Constraints on Particle Schema Components
17011 * Schema Component Constraint: 17084 * Schema Component Constraint:
17012 * Particle Derivation OK (All:All,Sequence:Sequence -- 17085 * Particle Derivation OK (All:All,Sequence:Sequence --
(...skipping 10 matching lines...) Expand all
17023 xmlSchemaCheckRCaseRecurse(xmlSchemaParserCtxtPtr ctxt, 17096 xmlSchemaCheckRCaseRecurse(xmlSchemaParserCtxtPtr ctxt,
17024 xmlSchemaParticlePtr r, 17097 xmlSchemaParticlePtr r,
17025 xmlSchemaParticlePtr b) 17098 xmlSchemaParticlePtr b)
17026 { 17099 {
17027 /* xmlSchemaParticlePtr part; */ 17100 /* xmlSchemaParticlePtr part; */
17028 /* TODO: Error codes (rcase-Recurse). */ 17101 /* TODO: Error codes (rcase-Recurse). */
17029 if ((r->children == NULL) || (b->children == NULL) || 17102 if ((r->children == NULL) || (b->children == NULL) ||
17030 (r->children->type != b->children->type)) 17103 (r->children->type != b->children->type))
17031 return (-1); 17104 return (-1);
17032 /* 17105 /*
17033 * SPEC "For an all or sequence group particle to be a ·valid 17106 * SPEC "For an all or sequence group particle to be a �valid
17034 * restriction· of another group particle with the same {compositor}..." 17107 * restriction� of another group particle with the same {compositor}..."
17035 * 17108 *
17036 * SPEC (1) "R's occurrence range is a valid restriction of B's 17109 * SPEC (1) "R's occurrence range is a valid restriction of B's
17037 * occurrence range as defined by Occurrence Range OK (§3.9.6)." 17110 * occurrence range as defined by Occurrence Range OK (�3.9.6)."
17038 */ 17111 */
17039 if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs, 17112 if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs,
17040 b->minOccurs, b->maxOccurs)) 17113 b->minOccurs, b->maxOccurs))
17041 return (1); 17114 return (1);
17042 17115
17043 17116
17044 return (0); 17117 return (0);
17045 } 17118 }
17046 17119
17047 #endif 17120 #endif
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
17124 fmininc = NULL, fmaxinc = NULL, 17197 fmininc = NULL, fmaxinc = NULL,
17125 fminexc = NULL, fmaxexc = NULL, 17198 fminexc = NULL, fmaxexc = NULL,
17126 bflength = NULL, bftotdig = NULL, bffracdig = NULL, 17199 bflength = NULL, bftotdig = NULL, bffracdig = NULL,
17127 bfmaxlen = NULL, bfminlen = NULL, /* facets of the base type */ 17200 bfmaxlen = NULL, bfminlen = NULL, /* facets of the base type */
17128 bfmininc = NULL, bfmaxinc = NULL, 17201 bfmininc = NULL, bfmaxinc = NULL,
17129 bfminexc = NULL, bfmaxexc = NULL; 17202 bfminexc = NULL, bfmaxexc = NULL;
17130 int res; /* err = 0, fixedErr; */ 17203 int res; /* err = 0, fixedErr; */
17131 17204
17132 /* 17205 /*
17133 * SPEC st-restrict-facets 1: 17206 * SPEC st-restrict-facets 1:
17134 * "The {variety} of R is the same as that of B." 17207 * "The {variety} of R is the same as that of B."
17135 */ 17208 */
17136 /* 17209 /*
17137 * SPEC st-restrict-facets 2: 17210 * SPEC st-restrict-facets 2:
17138 * "If {variety} is atomic, the {primitive type definition} 17211 * "If {variety} is atomic, the {primitive type definition}
17139 * of R is the same as that of B." 17212 * of R is the same as that of B."
17140 * 17213 *
17141 * NOTE: we leave 1 & 2 out for now, since this will be 17214 * NOTE: we leave 1 & 2 out for now, since this will be
17142 * satisfied by the derivation process. 17215 * satisfied by the derivation process.
17143 * CONSTRUCTION TODO: Maybe needed if using a construction API. 17216 * CONSTRUCTION TODO: Maybe needed if using a construction API.
17144 */ 17217 */
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
17278 FACET_RESTR_FIXED_ERR(fmaxlen) 17351 FACET_RESTR_FIXED_ERR(fmaxlen)
17279 } 17352 }
17280 } 17353 }
17281 /* 17354 /*
17282 * SCC "length and minLength or maxLength" 17355 * SCC "length and minLength or maxLength"
17283 */ 17356 */
17284 if (! flength) 17357 if (! flength)
17285 flength = bflength; 17358 flength = bflength;
17286 if (flength) { 17359 if (flength) {
17287 if (! fminlen) 17360 if (! fminlen)
17288 » flength = bflength; 17361 » fminlen = bfminlen;
17289 if (fminlen) { 17362 if (fminlen) {
17290 /* (1.1) length >= minLength */ 17363 /* (1.1) length >= minLength */
17291 res = xmlSchemaCompareValues(flength->val, fminlen->val); 17364 res = xmlSchemaCompareValues(flength->val, fminlen->val);
17292 if (res == -2) 17365 if (res == -2)
17293 goto internal_error; 17366 goto internal_error;
17294 if (res == -1) 17367 if (res == -1)
17295 xmlSchemaDeriveFacetErr(pctxt, flength, fminlen, 1, 1, 0); 17368 xmlSchemaDeriveFacetErr(pctxt, flength, fminlen, 1, 1, 0);
17296 } 17369 }
17297 if (! fmaxlen) 17370 if (! fmaxlen)
17298 fmaxlen = bfmaxlen; 17371 fmaxlen = bfmaxlen;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
17596 /* fixedErr = 0; */ 17669 /* fixedErr = 0; */
17597 while (link != NULL) { 17670 while (link != NULL) {
17598 facet = link->facet; 17671 facet = link->facet;
17599 if (facet->type == bfacet->type) { 17672 if (facet->type == bfacet->type) {
17600 switch (facet->type) { 17673 switch (facet->type) {
17601 case XML_SCHEMA_FACET_WHITESPACE: 17674 case XML_SCHEMA_FACET_WHITESPACE:
17602 /* 17675 /*
17603 * The whitespace must be stronger. 17676 * The whitespace must be stronger.
17604 */ 17677 */
17605 if (facet->whitespace < bfacet->whitespace) { 17678 if (facet->whitespace < bfacet->whitespace) {
17606 » » » FACET_RESTR_ERR(flength, 17679 » » » FACET_RESTR_ERR(facet,
17607 "The 'whitespace' value has to be equal to " 17680 "The 'whitespace' value has to be equal to "
17608 "or stronger than the 'whitespace' value of " 17681 "or stronger than the 'whitespace' value of "
17609 "the base type") 17682 "the base type")
17610 } 17683 }
17611 if ((bfacet->fixed) && 17684 if ((bfacet->fixed) &&
17612 (facet->whitespace != bfacet->whitespace)) { 17685 (facet->whitespace != bfacet->whitespace)) {
17613 FACET_RESTR_FIXED_ERR(facet) 17686 FACET_RESTR_FIXED_ERR(facet)
17614 } 17687 }
17615 break; 17688 break;
17616 default: 17689 default:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
17651 return (-1); 17724 return (-1);
17652 } 17725 }
17653 17726
17654 static int 17727 static int
17655 xmlSchemaFinishMemberTypeDefinitionsProperty(xmlSchemaParserCtxtPtr pctxt, 17728 xmlSchemaFinishMemberTypeDefinitionsProperty(xmlSchemaParserCtxtPtr pctxt,
17656 xmlSchemaTypePtr type) 17729 xmlSchemaTypePtr type)
17657 { 17730 {
17658 xmlSchemaTypeLinkPtr link, lastLink, prevLink, subLink, newLink; 17731 xmlSchemaTypeLinkPtr link, lastLink, prevLink, subLink, newLink;
17659 /* 17732 /*
17660 * The actual value is then formed by replacing any union type 17733 * The actual value is then formed by replacing any union type
17661 * definition in the ·explicit members· with the members of their 17734 * definition in the �explicit members� with the members of their
17662 * {member type definitions}, in order. 17735 * {member type definitions}, in order.
17663 * 17736 *
17664 * TODO: There's a bug entry at 17737 * TODO: There's a bug entry at
17665 * "http://lists.w3.org/Archives/Public/www-xml-schema-comments/2005JulSep/02 87.html" 17738 * "http://lists.w3.org/Archives/Public/www-xml-schema-comments/2005JulSep/02 87.html"
17666 * which indicates that we'll keep the union types the future. 17739 * which indicates that we'll keep the union types the future.
17667 */ 17740 */
17668 link = type->memberTypes; 17741 link = type->memberTypes;
17669 while (link != NULL) { 17742 while (link != NULL) {
17670 17743
17671 if (WXS_IS_TYPE_NOT_FIXED(link->type)) 17744 if (WXS_IS_TYPE_NOT_FIXED(link->type))
(...skipping 25 matching lines...) Expand all
17697 } 17770 }
17698 } 17771 }
17699 } 17772 }
17700 link = link->next; 17773 link = link->next;
17701 } 17774 }
17702 return (0); 17775 return (0);
17703 } 17776 }
17704 17777
17705 static void 17778 static void
17706 xmlSchemaTypeFixupOptimFacets(xmlSchemaTypePtr type) 17779 xmlSchemaTypeFixupOptimFacets(xmlSchemaTypePtr type)
17707 { 17780 {
17708 int has = 0, needVal = 0, normVal = 0; 17781 int has = 0, needVal = 0, normVal = 0;
17709 17782
17710 has = (type->baseType->flags & XML_SCHEMAS_TYPE_HAS_FACETS) ? 1 : 0; 17783 has = (type->baseType->flags & XML_SCHEMAS_TYPE_HAS_FACETS) ? 1 : 0;
17711 if (has) { 17784 if (has) {
17712 needVal = (type->baseType->flags & 17785 needVal = (type->baseType->flags &
17713 XML_SCHEMAS_TYPE_FACETSNEEDVALUE) ? 1 : 0; 17786 XML_SCHEMAS_TYPE_FACETSNEEDVALUE) ? 1 : 0;
17714 normVal = (type->baseType->flags & 17787 normVal = (type->baseType->flags &
17715 XML_SCHEMAS_TYPE_NORMVALUENEEDED) ? 1 : 0; 17788 XML_SCHEMAS_TYPE_NORMVALUENEEDED) ? 1 : 0;
17716 } 17789 }
17717 if (type->facets != NULL) { 17790 if (type->facets != NULL) {
17718 xmlSchemaFacetPtr fac; 17791 xmlSchemaFacetPtr fac;
17719 » 17792
17720 for (fac = type->facets; fac != NULL; fac = fac->next) { 17793 for (fac = type->facets; fac != NULL; fac = fac->next) {
17721 switch (fac->type) { 17794 switch (fac->type) {
17722 case XML_SCHEMA_FACET_WHITESPACE: 17795 case XML_SCHEMA_FACET_WHITESPACE:
17723 break; 17796 break;
17724 case XML_SCHEMA_FACET_PATTERN: 17797 case XML_SCHEMA_FACET_PATTERN:
17725 normVal = 1; 17798 normVal = 1;
17726 has = 1; 17799 has = 1;
17727 break; 17800 break;
17728 case XML_SCHEMA_FACET_ENUMERATION: 17801 case XML_SCHEMA_FACET_ENUMERATION:
17729 needVal = 1; 17802 needVal = 1;
17730 normVal = 1; 17803 normVal = 1;
17731 has = 1; 17804 has = 1;
17732 break; 17805 break;
17733 default: 17806 default:
17734 has = 1; 17807 has = 1;
17735 break; 17808 break;
17736 } 17809 }
17737 » }» 17810 » }
17738 } 17811 }
17739 if (normVal) 17812 if (normVal)
17740 type->flags |= XML_SCHEMAS_TYPE_NORMVALUENEEDED; 17813 type->flags |= XML_SCHEMAS_TYPE_NORMVALUENEEDED;
17741 if (needVal) 17814 if (needVal)
17742 type->flags |= XML_SCHEMAS_TYPE_FACETSNEEDVALUE; 17815 type->flags |= XML_SCHEMAS_TYPE_FACETSNEEDVALUE;
17743 if (has) 17816 if (has)
17744 type->flags |= XML_SCHEMAS_TYPE_HAS_FACETS; 17817 type->flags |= XML_SCHEMAS_TYPE_HAS_FACETS;
17745 17818
17746 if (has && (! needVal) && WXS_IS_ATOMIC(type)) { 17819 if (has && (! needVal) && WXS_IS_ATOMIC(type)) {
17747 xmlSchemaTypePtr prim = xmlSchemaGetPrimitiveType(type); 17820 xmlSchemaTypePtr prim = xmlSchemaGetPrimitiveType(type);
17748 /* 17821 /*
17749 * OPTIMIZE VAL TODO: Some facets need a computed value. 17822 * OPTIMIZE VAL TODO: Some facets need a computed value.
17750 */ 17823 */
17751 if ((prim->builtInType != XML_SCHEMAS_ANYSIMPLETYPE) && 17824 if ((prim->builtInType != XML_SCHEMAS_ANYSIMPLETYPE) &&
17752 (prim->builtInType != XML_SCHEMAS_STRING)) { 17825 (prim->builtInType != XML_SCHEMAS_STRING)) {
17753 type->flags |= XML_SCHEMAS_TYPE_FACETSNEEDVALUE; 17826 type->flags |= XML_SCHEMAS_TYPE_FACETSNEEDVALUE;
17754 » } » 17827 » }
17755 } 17828 }
17756 } 17829 }
17757 17830
17758 static int 17831 static int
17759 xmlSchemaTypeFixupWhitespace(xmlSchemaTypePtr type) 17832 xmlSchemaTypeFixupWhitespace(xmlSchemaTypePtr type)
17760 { 17833 {
17761 17834
17762 17835
17763 /* 17836 /*
17764 * Evaluate the whitespace-facet value. 17837 * Evaluate the whitespace-facet value.
17765 */ 17838 */
17766 if (WXS_IS_LIST(type)) { 17839 if (WXS_IS_LIST(type)) {
17767 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE; 17840 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE;
17768 return (0); 17841 return (0);
17769 } else if (WXS_IS_UNION(type)) 17842 } else if (WXS_IS_UNION(type))
17770 return (0); 17843 return (0);
17771 17844
17772 if (type->facetSet != NULL) { 17845 if (type->facetSet != NULL) {
17773 xmlSchemaFacetLinkPtr lin; 17846 xmlSchemaFacetLinkPtr lin;
17774 17847
17775 for (lin = type->facetSet; lin != NULL; lin = lin->next) { 17848 for (lin = type->facetSet; lin != NULL; lin = lin->next) {
17776 if (lin->facet->type == XML_SCHEMA_FACET_WHITESPACE) { 17849 if (lin->facet->type == XML_SCHEMA_FACET_WHITESPACE) {
17777 switch (lin->facet->whitespace) { 17850 switch (lin->facet->whitespace) {
17778 case XML_SCHEMAS_FACET_PRESERVE: 17851 case XML_SCHEMAS_FACET_PRESERVE:
17779 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE; 17852 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE;
17780 break; 17853 break;
17781 case XML_SCHEMAS_FACET_REPLACE: 17854 case XML_SCHEMAS_FACET_REPLACE:
17782 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_REPLACE; 17855 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_REPLACE;
17783 break; 17856 break;
17784 case XML_SCHEMAS_FACET_COLLAPSE: 17857 case XML_SCHEMAS_FACET_COLLAPSE:
17785 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE; 17858 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE;
17786 break; 17859 break;
17787 default: 17860 default:
17788 return (-1); 17861 return (-1);
17789 } 17862 }
17790 return (0); 17863 return (0);
17791 } 17864 }
17792 } 17865 }
17793 } 17866 }
17794 /* 17867 /*
17795 * For all ·atomic· datatypes other than string (and types ·derived· 17868 * For all �atomic� datatypes other than string (and types �derived�
17796 * by ·restriction· from it) the value of whiteSpace is fixed to 17869 * by �restriction� from it) the value of whiteSpace is fixed to
17797 * collapse 17870 * collapse
17798 */ 17871 */
17799 { 17872 {
17800 xmlSchemaTypePtr anc; 17873 xmlSchemaTypePtr anc;
17801 17874
17802 » for (anc = type->baseType; anc != NULL && 17875 » for (anc = type->baseType; anc != NULL &&
17803 anc->builtInType != XML_SCHEMAS_ANYTYPE; 17876 anc->builtInType != XML_SCHEMAS_ANYTYPE;
17804 anc = anc->baseType) { 17877 anc = anc->baseType) {
17805 17878
17806 if (anc->type == XML_SCHEMA_TYPE_BASIC) { 17879 if (anc->type == XML_SCHEMA_TYPE_BASIC) {
17807 » » if (anc->builtInType == XML_SCHEMAS_NORMSTRING) {» 17880 » » if (anc->builtInType == XML_SCHEMAS_NORMSTRING) {
17808 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_REPLACE; 17881 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_REPLACE;
17809 17882
17810 } else if ((anc->builtInType == XML_SCHEMAS_STRING) || 17883 } else if ((anc->builtInType == XML_SCHEMAS_STRING) ||
17811 » » (anc->builtInType == XML_SCHEMAS_ANYSIMPLETYPE)) {» » 17884 » » (anc->builtInType == XML_SCHEMAS_ANYSIMPLETYPE)) {
17812 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE; 17885 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE;
17813 17886
17814 } else 17887 } else
17815 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE; 17888 type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE;
17816 break; 17889 break;
17817 } 17890 }
17818 } 17891 }
17819 } 17892 }
17820 return (0); 17893 return (0);
17821 } 17894 }
(...skipping 16 matching lines...) Expand all
17838 /* 17911 /*
17839 * This one is really needed, so get out. 17912 * This one is really needed, so get out.
17840 */ 17913 */
17841 PERROR_INT("xmlSchemaFixupSimpleTypeStageOne", 17914 PERROR_INT("xmlSchemaFixupSimpleTypeStageOne",
17842 "list type has no item-type assigned"); 17915 "list type has no item-type assigned");
17843 return(-1); 17916 return(-1);
17844 } 17917 }
17845 } else if (WXS_IS_UNION(type)) { 17918 } else if (WXS_IS_UNION(type)) {
17846 /* 17919 /*
17847 * Corresponds to <simpleType><union>... 17920 * Corresponds to <simpleType><union>...
17848 » */» 17921 » */
17849 if (type->memberTypes == NULL) { 17922 if (type->memberTypes == NULL) {
17850 /* 17923 /*
17851 * This one is really needed, so get out. 17924 * This one is really needed, so get out.
17852 */ 17925 */
17853 PERROR_INT("xmlSchemaFixupSimpleTypeStageOne", 17926 PERROR_INT("xmlSchemaFixupSimpleTypeStageOne",
17854 "union type has no member-types assigned"); 17927 "union type has no member-types assigned");
17855 return(-1); 17928 return(-1);
17856 » }» 17929 » }
17857 } else { 17930 } else {
17858 /* 17931 /*
17859 * Corresponds to <simpleType><restriction>... 17932 * Corresponds to <simpleType><restriction>...
17860 */ 17933 */
17861 if (type->baseType == NULL) { 17934 if (type->baseType == NULL) {
17862 PERROR_INT("xmlSchemaFixupSimpleTypeStageOne", 17935 PERROR_INT("xmlSchemaFixupSimpleTypeStageOne",
17863 "type has no base-type assigned"); 17936 "type has no base-type assigned");
17864 return(-1); 17937 return(-1);
17865 } 17938 }
17866 if (WXS_IS_TYPE_NOT_FIXED_1(type->baseType)) 17939 if (WXS_IS_TYPE_NOT_FIXED_1(type->baseType))
17867 if (xmlSchemaFixupSimpleTypeStageOne(pctxt, type->baseType) == -1) 17940 if (xmlSchemaFixupSimpleTypeStageOne(pctxt, type->baseType) == -1)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
17962 type->flags |= XML_SCHEMAS_TYPE_INTERNAL_RESOLVED; 18035 type->flags |= XML_SCHEMAS_TYPE_INTERNAL_RESOLVED;
17963 type->contentType = XML_SCHEMA_CONTENT_SIMPLE; 18036 type->contentType = XML_SCHEMA_CONTENT_SIMPLE;
17964 18037
17965 if (type->baseType == NULL) { 18038 if (type->baseType == NULL) {
17966 PERROR_INT("xmlSchemaFixupSimpleTypeStageTwo", 18039 PERROR_INT("xmlSchemaFixupSimpleTypeStageTwo",
17967 "missing baseType"); 18040 "missing baseType");
17968 goto exit_failure; 18041 goto exit_failure;
17969 } 18042 }
17970 if (WXS_IS_TYPE_NOT_FIXED(type->baseType)) 18043 if (WXS_IS_TYPE_NOT_FIXED(type->baseType))
17971 xmlSchemaTypeFixup(type->baseType, ACTXT_CAST pctxt); 18044 xmlSchemaTypeFixup(type->baseType, ACTXT_CAST pctxt);
17972 /* 18045 /*
17973 * If a member type of a union is a union itself, we need to substitute 18046 * If a member type of a union is a union itself, we need to substitute
17974 * that member type for its member types. 18047 * that member type for its member types.
17975 * NOTE that this might change in WXS 1.1; i.e. we will keep the union 18048 * NOTE that this might change in WXS 1.1; i.e. we will keep the union
17976 * types in WXS 1.1. 18049 * types in WXS 1.1.
17977 */ 18050 */
17978 if ((type->memberTypes != NULL) && 18051 if ((type->memberTypes != NULL) &&
17979 (xmlSchemaFinishMemberTypeDefinitionsProperty(pctxt, type) == -1)) 18052 (xmlSchemaFinishMemberTypeDefinitionsProperty(pctxt, type) == -1))
17980 » return(-1); 18053 » return(-1);
17981 /* 18054 /*
17982 * SPEC src-simple-type 1 18055 * SPEC src-simple-type 1
17983 * "The corresponding simple type definition, if any, must satisfy 18056 * "The corresponding simple type definition, if any, must satisfy
17984 * the conditions set out in Constraints on Simple Type Definition 18057 * the conditions set out in Constraints on Simple Type Definition
17985 * Schema Components (§3.14.6)." 18058 * Schema Components (�3.14.6)."
17986 */ 18059 */
17987 /* 18060 /*
17988 * Schema Component Constraint: Simple Type Definition Properties Correct 18061 * Schema Component Constraint: Simple Type Definition Properties Correct
17989 * (st-props-correct) 18062 * (st-props-correct)
17990 */ 18063 */
17991 res = xmlSchemaCheckSTPropsCorrect(pctxt, type); 18064 res = xmlSchemaCheckSTPropsCorrect(pctxt, type);
17992 HFAILURE HERROR 18065 HFAILURE HERROR
17993 /* 18066 /*
17994 * Schema Component Constraint: Derivation Valid (Restriction, Simple) 18067 * Schema Component Constraint: Derivation Valid (Restriction, Simple)
17995 * (cos-st-restricts) 18068 * (cos-st-restricts)
17996 */ 18069 */
17997 res = xmlSchemaCheckCOSSTRestricts(pctxt, type); 18070 res = xmlSchemaCheckCOSSTRestricts(pctxt, type);
17998 HFAILURE HERROR 18071 HFAILURE HERROR
17999 /* 18072 /*
18000 * TODO: Removed the error report, since it got annoying to get an 18073 * TODO: Removed the error report, since it got annoying to get an
18001 * extra error report, if anything failed until now. 18074 * extra error report, if anything failed until now.
18002 * Enable this if needed. 18075 * Enable this if needed.
18003 * 18076 *
(...skipping 12 matching lines...) Expand all
18016 if ((type->facetSet != NULL) || 18089 if ((type->facetSet != NULL) ||
18017 (type->baseType->facetSet != NULL)) { 18090 (type->baseType->facetSet != NULL)) {
18018 res = xmlSchemaDeriveAndValidateFacets(pctxt, type); 18091 res = xmlSchemaDeriveAndValidateFacets(pctxt, type);
18019 HFAILURE HERROR 18092 HFAILURE HERROR
18020 } 18093 }
18021 /* 18094 /*
18022 * Whitespace value. 18095 * Whitespace value.
18023 */ 18096 */
18024 res = xmlSchemaTypeFixupWhitespace(type); 18097 res = xmlSchemaTypeFixupWhitespace(type);
18025 HFAILURE HERROR 18098 HFAILURE HERROR
18026 xmlSchemaTypeFixupOptimFacets(type); 18099 xmlSchemaTypeFixupOptimFacets(type);
18027 18100
18028 exit_error: 18101 exit_error:
18029 #ifdef DEBUG_TYPE 18102 #ifdef DEBUG_TYPE
18030 xmlSchemaDebugFixedType(pctxt, type); 18103 xmlSchemaDebugFixedType(pctxt, type);
18031 #endif 18104 #endif
18032 if (olderrs != pctxt->nberrors) 18105 if (olderrs != pctxt->nberrors)
18033 return(pctxt->err); 18106 return(pctxt->err);
18034 return(0); 18107 return(0);
18035 18108
18036 exit_failure: 18109 exit_failure:
(...skipping 10 matching lines...) Expand all
18047 int res = 0, olderrs = pctxt->nberrors; 18120 int res = 0, olderrs = pctxt->nberrors;
18048 xmlSchemaTypePtr baseType = type->baseType; 18121 xmlSchemaTypePtr baseType = type->baseType;
18049 18122
18050 if (! WXS_IS_TYPE_NOT_FIXED(type)) 18123 if (! WXS_IS_TYPE_NOT_FIXED(type))
18051 return(0); 18124 return(0);
18052 type->flags |= XML_SCHEMAS_TYPE_INTERNAL_RESOLVED; 18125 type->flags |= XML_SCHEMAS_TYPE_INTERNAL_RESOLVED;
18053 if (baseType == NULL) { 18126 if (baseType == NULL) {
18054 PERROR_INT("xmlSchemaFixupComplexType", 18127 PERROR_INT("xmlSchemaFixupComplexType",
18055 "missing baseType"); 18128 "missing baseType");
18056 goto exit_failure; 18129 goto exit_failure;
18057 } 18130 }
18058 /* 18131 /*
18059 * Fixup the base type. 18132 * Fixup the base type.
18060 */ 18133 */
18061 if (WXS_IS_TYPE_NOT_FIXED(baseType)) 18134 if (WXS_IS_TYPE_NOT_FIXED(baseType))
18062 xmlSchemaTypeFixup(baseType, ACTXT_CAST pctxt); 18135 xmlSchemaTypeFixup(baseType, ACTXT_CAST pctxt);
18063 if (baseType->flags & XML_SCHEMAS_TYPE_INTERNAL_INVALID) { 18136 if (baseType->flags & XML_SCHEMAS_TYPE_INTERNAL_INVALID) {
18064 /* 18137 /*
18065 * Skip fixup if the base type is invalid. 18138 * Skip fixup if the base type is invalid.
18066 * TODO: Generate a warning! 18139 * TODO: Generate a warning!
18067 */ 18140 */
18068 return(0); 18141 return(0);
18069 }» 18142 }
18070 /* 18143 /*
18071 * This basically checks if the base type can be derived. 18144 * This basically checks if the base type can be derived.
18072 */ 18145 */
18073 res = xmlSchemaCheckSRCCT(pctxt, type); 18146 res = xmlSchemaCheckSRCCT(pctxt, type);
18074 HFAILURE HERROR 18147 HFAILURE HERROR
18075 /* 18148 /*
18076 * Fixup the content type. 18149 * Fixup the content type.
18077 */ 18150 */
18078 if (type->contentType == XML_SCHEMA_CONTENT_SIMPLE) { 18151 if (type->contentType == XML_SCHEMA_CONTENT_SIMPLE) {
18079 /* 18152 /*
18080 * Corresponds to <complexType><simpleContent>... 18153 * Corresponds to <complexType><simpleContent>...
18081 */ 18154 */
18082 if ((WXS_IS_COMPLEX(baseType)) && 18155 if ((WXS_IS_COMPLEX(baseType)) &&
18083 (baseType->contentTypeDef != NULL) && 18156 (baseType->contentTypeDef != NULL) &&
18084 (WXS_IS_RESTRICTION(type))) { 18157 (WXS_IS_RESTRICTION(type))) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
18138 content->type = XML_SCHEMA_TYPE_SIMPLE; 18211 content->type = XML_SCHEMA_TYPE_SIMPLE;
18139 content->baseType = contentBase; 18212 content->baseType = contentBase;
18140 /* 18213 /*
18141 * Move the facets, previously anchored on the 18214 * Move the facets, previously anchored on the
18142 * complexType during parsing. 18215 * complexType during parsing.
18143 */ 18216 */
18144 content->facets = type->facets; 18217 content->facets = type->facets;
18145 type->facets = NULL; 18218 type->facets = NULL;
18146 content->facetSet = type->facetSet; 18219 content->facetSet = type->facetSet;
18147 type->facetSet = NULL; 18220 type->facetSet = NULL;
18148 » 18221
18149 type->contentTypeDef = content; 18222 type->contentTypeDef = content;
18150 if (WXS_IS_TYPE_NOT_FIXED(contentBase)) 18223 if (WXS_IS_TYPE_NOT_FIXED(contentBase))
18151 xmlSchemaTypeFixup(contentBase, ACTXT_CAST pctxt); 18224 xmlSchemaTypeFixup(contentBase, ACTXT_CAST pctxt);
18152 /* 18225 /*
18153 * Fixup the newly created type. We don't need to check 18226 * Fixup the newly created type. We don't need to check
18154 * for circularity here. 18227 * for circularity here.
18155 */ 18228 */
18156 res = xmlSchemaFixupSimpleTypeStageOne(pctxt, content); 18229 res = xmlSchemaFixupSimpleTypeStageOne(pctxt, content);
18157 » HFAILURE HERROR 18230 » HFAILURE HERROR
18158 res = xmlSchemaFixupSimpleTypeStageTwo(pctxt, content); 18231 res = xmlSchemaFixupSimpleTypeStageTwo(pctxt, content);
18159 » HFAILURE HERROR 18232 » HFAILURE HERROR
18160 » » 18233
18161 } else if ((WXS_IS_COMPLEX(baseType)) && 18234 } else if ((WXS_IS_COMPLEX(baseType)) &&
18162 (baseType->contentType == XML_SCHEMA_CONTENT_MIXED) && 18235 (baseType->contentType == XML_SCHEMA_CONTENT_MIXED) &&
18163 (WXS_IS_RESTRICTION(type))) { 18236 (WXS_IS_RESTRICTION(type))) {
18164 /* 18237 /*
18165 * SPEC (2) If <restriction> + base is a mixed <complexType> with 18238 * SPEC (2) If <restriction> + base is a mixed <complexType> with
18166 * an emptiable particle, then a simple type definition which 18239 * an emptiable particle, then a simple type definition which
18167 * restricts the <restriction>'s <simpleType> child. 18240 * restricts the <restriction>'s <simpleType> child.
18168 */ 18241 */
18169 if ((type->contentTypeDef == NULL) || 18242 if ((type->contentTypeDef == NULL) ||
18170 (type->contentTypeDef->baseType == NULL)) { 18243 (type->contentTypeDef->baseType == NULL)) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
18235 */ 18308 */
18236 if ((particle == NULL) || 18309 if ((particle == NULL) ||
18237 ((particle->type == XML_SCHEMA_TYPE_PARTICLE) && 18310 ((particle->type == XML_SCHEMA_TYPE_PARTICLE) &&
18238 ((particle->children->type == XML_SCHEMA_TYPE_ALL) || 18311 ((particle->children->type == XML_SCHEMA_TYPE_ALL) ||
18239 (particle->children->type == XML_SCHEMA_TYPE_SEQUENCE) || 18312 (particle->children->type == XML_SCHEMA_TYPE_SEQUENCE) ||
18240 ((particle->children->type == XML_SCHEMA_TYPE_CHOICE) && 18313 ((particle->children->type == XML_SCHEMA_TYPE_CHOICE) &&
18241 (particle->minOccurs == 0))) && 18314 (particle->minOccurs == 0))) &&
18242 ( ((xmlSchemaTreeItemPtr) particle->children)->children == NULL))) { 18315 ( ((xmlSchemaTreeItemPtr) particle->children)->children == NULL))) {
18243 if (type->flags & XML_SCHEMAS_TYPE_MIXED) { 18316 if (type->flags & XML_SCHEMAS_TYPE_MIXED) {
18244 /* 18317 /*
18245 » » * SPEC (2.1.4) "If the ·effective mixed· is true, then 18318 » » * SPEC (2.1.4) "If the �effective mixed� is true, then
18246 * a particle whose properties are as follows:..." 18319 * a particle whose properties are as follows:..."
18247 * 18320 *
18248 * Empty sequence model group with 18321 * Empty sequence model group with
18249 * minOccurs/maxOccurs = 1 (i.e. a "particle emptiable"). 18322 * minOccurs/maxOccurs = 1 (i.e. a "particle emptiable").
18250 * NOTE that we sill assign it the <complexType> node to 18323 * NOTE that we sill assign it the <complexType> node to
18251 * somehow anchor it in the doc. 18324 * somehow anchor it in the doc.
18252 */ 18325 */
18253 if ((particle == NULL) || 18326 if ((particle == NULL) ||
18254 (particle->children->type != XML_SCHEMA_TYPE_SEQUENCE)) { 18327 (particle->children->type != XML_SCHEMA_TYPE_SEQUENCE)) {
18255 /* 18328 /*
18256 * Create the particle. 18329 * Create the particle.
18257 */ 18330 */
18258 particle = xmlSchemaAddParticle(pctxt, 18331 particle = xmlSchemaAddParticle(pctxt,
18259 type->node, 1, 1); 18332 type->node, 1, 1);
18260 if (particle == NULL) 18333 if (particle == NULL)
18261 goto exit_failure; 18334 goto exit_failure;
18262 /* 18335 /*
18263 * Create the model group. 18336 * Create the model group.
18264 */ /* URGENT TODO: avoid adding to pending items. */ 18337 */ /* URGENT TODO: avoid adding to pending items. */
18265 particle->children = (xmlSchemaTreeItemPtr) 18338 particle->children = (xmlSchemaTreeItemPtr)
18266 xmlSchemaAddModelGroup(pctxt, pctxt->schema, 18339 xmlSchemaAddModelGroup(pctxt, pctxt->schema,
18267 XML_SCHEMA_TYPE_SEQUENCE, type->node); 18340 XML_SCHEMA_TYPE_SEQUENCE, type->node);
18268 if (particle->children == NULL) 18341 if (particle->children == NULL)
18269 goto exit_failure; 18342 goto exit_failure;
18270 » » 18343
18271 type->subtypes = (xmlSchemaTypePtr) particle; 18344 type->subtypes = (xmlSchemaTypePtr) particle;
18272 } 18345 }
18273 dummySequence = 1; 18346 dummySequence = 1;
18274 type->contentType = XML_SCHEMA_CONTENT_ELEMENTS; 18347 type->contentType = XML_SCHEMA_CONTENT_ELEMENTS;
18275 } else { 18348 } else {
18276 /* 18349 /*
18277 * SPEC (2.1.5) "otherwise empty" 18350 * SPEC (2.1.5) "otherwise empty"
18278 */ 18351 */
18279 type->contentType = XML_SCHEMA_CONTENT_EMPTY; 18352 type->contentType = XML_SCHEMA_CONTENT_EMPTY;
18280 } 18353 }
(...skipping 16 matching lines...) Expand all
18297 if (type->flags & XML_SCHEMAS_TYPE_MIXED) 18370 if (type->flags & XML_SCHEMAS_TYPE_MIXED)
18298 type->contentType = XML_SCHEMA_CONTENT_MIXED; 18371 type->contentType = XML_SCHEMA_CONTENT_MIXED;
18299 } 18372 }
18300 } else { 18373 } else {
18301 /* 18374 /*
18302 * SPEC (3.2) "If <extension>..." 18375 * SPEC (3.2) "If <extension>..."
18303 */ 18376 */
18304 if (type->contentType == XML_SCHEMA_CONTENT_EMPTY) { 18377 if (type->contentType == XML_SCHEMA_CONTENT_EMPTY) {
18305 /* 18378 /*
18306 * SPEC (3.2.1) 18379 * SPEC (3.2.1)
18307 » » * "If the ·effective content· is empty, then the 18380 » » * "If the �effective content� is empty, then the
18308 * {content type} of the [...] base ..." 18381 * {content type} of the [...] base ..."
18309 */ 18382 */
18310 type->contentType = baseType->contentType; 18383 type->contentType = baseType->contentType;
18311 type->subtypes = baseType->subtypes; 18384 type->subtypes = baseType->subtypes;
18312 /* 18385 /*
18313 * Fixes bug #347316: 18386 * Fixes bug #347316:
18314 * This is the case when the base type has a simple 18387 * This is the case when the base type has a simple
18315 * type definition as content. 18388 * type definition as content.
18316 */ 18389 */
18317 type->contentTypeDef = baseType->contentTypeDef; 18390 type->contentTypeDef = baseType->contentTypeDef;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
18404 type->node, 18477 type->node,
18405 ((xmlSchemaParticlePtr) type->subtypes)->minOccurs, 18478 ((xmlSchemaParticlePtr) type->subtypes)->minOccurs,
18406 ((xmlSchemaParticlePtr) type->subtypes)->maxOccurs); 18479 ((xmlSchemaParticlePtr) type->subtypes)->maxOccurs);
18407 if (particle->children->children == NULL) 18480 if (particle->children->children == NULL)
18408 goto exit_failure; 18481 goto exit_failure;
18409 particle = (xmlSchemaParticlePtr) 18482 particle = (xmlSchemaParticlePtr)
18410 particle->children->children; 18483 particle->children->children;
18411 particle->children = 18484 particle->children =
18412 ((xmlSchemaParticlePtr) baseType->subtypes)->children; 18485 ((xmlSchemaParticlePtr) baseType->subtypes)->children;
18413 /* 18486 /*
18414 » » * SPEC "followed by the ·effective content·." 18487 » » * SPEC "followed by the �effective content�."
18415 */ 18488 */
18416 particle->next = effectiveContent; 18489 particle->next = effectiveContent;
18417 /* 18490 /*
18418 * This all will result in: 18491 * This all will result in:
18419 * new-particle 18492 * new-particle
18420 * --> new-sequence( 18493 * --> new-sequence(
18421 * new-particle 18494 * new-particle
18422 * --> base-model, 18495 * --> base-model,
18423 * this-particle 18496 * this-particle
18424 * --> this-model 18497 * --> this-model
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
18548 case XML_SCHEMA_FACET_MAXEXCLUSIVE: 18621 case XML_SCHEMA_FACET_MAXEXCLUSIVE:
18549 case XML_SCHEMA_FACET_ENUMERATION: { 18622 case XML_SCHEMA_FACET_ENUMERATION: {
18550 /* 18623 /*
18551 * Okay we need to validate the value 18624 * Okay we need to validate the value
18552 * at that point. 18625 * at that point.
18553 */ 18626 */
18554 xmlSchemaTypePtr base; 18627 xmlSchemaTypePtr base;
18555 18628
18556 /* 4.3.5.5 Constraints on enumeration Schema Components 18629 /* 4.3.5.5 Constraints on enumeration Schema Components
18557 * Schema Component Constraint: enumeration valid restriction 18630 * Schema Component Constraint: enumeration valid restriction
18558 » » * It is an ·error· if any member of {value} is not in the 18631 » » * It is an �error� if any member of {value} is not in the
18559 » » * ·value space· of {base type definition}. 18632 » » * �value space� of {base type definition}.
18560 * 18633 *
18561 * minInclusive, maxInclusive, minExclusive, maxExclusive: 18634 * minInclusive, maxInclusive, minExclusive, maxExclusive:
18562 » » * The value ·must· be in the 18635 » » * The value �must� be in the
18563 » » * ·value space· of the ·base type·. 18636 » » * �value space� of the �base type�.
18564 */ 18637 */
18565 /* 18638 /*
18566 * This function is intended to deliver a compiled value 18639 * This function is intended to deliver a compiled value
18567 * on the facet. In this implementation of XML Schemata the 18640 * on the facet. In this implementation of XML Schemata the
18568 * type holding a facet, won't be a built-in type. 18641 * type holding a facet, won't be a built-in type.
18569 * Thus to ensure that other API 18642 * Thus to ensure that other API
18570 * calls (relaxng) do work, if the given type is a built-in 18643 * calls (relaxng) do work, if the given type is a built-in
18571 * type, we will assume that the given built-in type *is 18644 * type, we will assume that the given built-in type *is
18572 * already* the base type. 18645 * already* the base type.
18573 */ 18646 */
18574 if (typeDecl->type != XML_SCHEMA_TYPE_BASIC) { 18647 if (typeDecl->type != XML_SCHEMA_TYPE_BASIC) {
18575 base = typeDecl->baseType; 18648 base = typeDecl->baseType;
18576 if (base == NULL) { 18649 if (base == NULL) {
18577 PERROR_INT("xmlSchemaCheckFacet", 18650 PERROR_INT("xmlSchemaCheckFacet",
18578 "a type user derived type has no base type"); 18651 "a type user derived type has no base type");
18579 return (-1); 18652 return (-1);
18580 } 18653 }
18581 } else 18654 } else
18582 base = typeDecl; 18655 base = typeDecl;
18583 » 18656
18584 if (! ctxtGiven) { 18657 if (! ctxtGiven) {
18585 /* 18658 /*
18586 * A context is needed if called from RelaxNG. 18659 * A context is needed if called from RelaxNG.
18587 » » */» » 18660 » » */
18588 pctxt = xmlSchemaNewParserCtxt("*"); 18661 pctxt = xmlSchemaNewParserCtxt("*");
18589 if (pctxt == NULL) 18662 if (pctxt == NULL)
18590 return (-1); 18663 return (-1);
18591 } 18664 }
18592 /* 18665 /*
18593 * NOTE: This call does not check the content nodes, 18666 * NOTE: This call does not check the content nodes,
18594 * since they are not available: 18667 * since they are not available:
18595 * facet->node is just the node holding the facet 18668 * facet->node is just the node holding the facet
18596 * definition, *not* the attribute holding the *value* 18669 * definition, *not* the attribute holding the *value*
18597 * of the facet. 18670 * of the facet.
18598 » » */» » 18671 » » */
18599 ret = xmlSchemaVCheckCVCSimpleType( 18672 ret = xmlSchemaVCheckCVCSimpleType(
18600 ACTXT_CAST pctxt, facet->node, base, 18673 ACTXT_CAST pctxt, facet->node, base,
18601 facet->value, &(facet->val), 1, 1, 0); 18674 facet->value, &(facet->val), 1, 1, 0);
18602 if (ret != 0) { 18675 if (ret != 0) {
18603 if (ret < 0) { 18676 if (ret < 0) {
18604 /* No error message for RelaxNG. */ 18677 /* No error message for RelaxNG. */
18605 » » » if (ctxtGiven) {» » » 18678 » » » if (ctxtGiven) {
18606 xmlSchemaCustomErr(ACTXT_CAST pctxt, 18679 xmlSchemaCustomErr(ACTXT_CAST pctxt,
18607 XML_SCHEMAP_INTERNAL, facet->node, NULL, 18680 XML_SCHEMAP_INTERNAL, facet->node, NULL,
18608 » » » » "Internal error: xmlSchemaCheckFacet, " 18681 » » » » "Internal error: xmlSchemaCheckFacet, "
18609 "failed to validate the value '%s' of the " 18682 "failed to validate the value '%s' of the "
18610 "facet '%s' against the base type", 18683 "facet '%s' against the base type",
18611 facet->value, xmlSchemaFacetTypeToString(facet-> type)); 18684 facet->value, xmlSchemaFacetTypeToString(facet-> type));
18612 } 18685 }
18613 goto internal_error; 18686 goto internal_error;
18614 } 18687 }
18615 ret = XML_SCHEMAP_INVALID_FACET_VALUE; 18688 ret = XML_SCHEMAP_INVALID_FACET_VALUE;
18616 /* No error message for RelaxNG. */ 18689 /* No error message for RelaxNG. */
18617 if (ctxtGiven) { 18690 if (ctxtGiven) {
18618 xmlChar *str = NULL; 18691 xmlChar *str = NULL;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
18673 "validating facet value"); 18746 "validating facet value");
18674 } 18747 }
18675 goto internal_error; 18748 goto internal_error;
18676 } 18749 }
18677 ret = XML_SCHEMAP_INVALID_FACET_VALUE; 18750 ret = XML_SCHEMAP_INVALID_FACET_VALUE;
18678 /* No error message for RelaxNG. */ 18751 /* No error message for RelaxNG. */
18679 if (ctxtGiven) { 18752 if (ctxtGiven) {
18680 /* error code */ 18753 /* error code */
18681 xmlSchemaCustomErr4(ACTXT_CAST pctxt, 18754 xmlSchemaCustomErr4(ACTXT_CAST pctxt,
18682 ret, facet->node, WXS_BASIC_CAST typeDecl, 18755 ret, facet->node, WXS_BASIC_CAST typeDecl,
18683 » » » "The value '%s' of the facet '%s' is not a valid '%s'",» » » 18756 » » » "The value '%s' of the facet '%s' is not a valid '%s'",
18684 facet->value, 18757 facet->value,
18685 xmlSchemaFacetTypeToString(facet->type), 18758 xmlSchemaFacetTypeToString(facet->type),
18686 » » » (facet->type != XML_SCHEMA_FACET_TOTALDIGITS) ? 18759 » » » (facet->type != XML_SCHEMA_FACET_TOTALDIGITS) ?
18687 BAD_CAST "nonNegativeInteger" : 18760 BAD_CAST "nonNegativeInteger" :
18688 BAD_CAST "positiveInteger", 18761 BAD_CAST "positiveInteger",
18689 NULL); 18762 NULL);
18690 } 18763 }
18691 } 18764 }
18692 break; 18765 break;
18693 18766
18694 case XML_SCHEMA_FACET_WHITESPACE:{ 18767 case XML_SCHEMA_FACET_WHITESPACE:{
18695 if (xmlStrEqual(facet->value, BAD_CAST "preserve")) { 18768 if (xmlStrEqual(facet->value, BAD_CAST "preserve")) {
18696 facet->whitespace = XML_SCHEMAS_FACET_PRESERVE; 18769 facet->whitespace = XML_SCHEMAS_FACET_PRESERVE;
18697 } else if (xmlStrEqual(facet->value, BAD_CAST "replace")) { 18770 } else if (xmlStrEqual(facet->value, BAD_CAST "replace")) {
18698 facet->whitespace = XML_SCHEMAS_FACET_REPLACE; 18771 facet->whitespace = XML_SCHEMAS_FACET_REPLACE;
18699 } else if (xmlStrEqual(facet->value, BAD_CAST "collapse")) { 18772 } else if (xmlStrEqual(facet->value, BAD_CAST "collapse")) {
18700 facet->whitespace = XML_SCHEMAS_FACET_COLLAPSE; 18773 facet->whitespace = XML_SCHEMAS_FACET_COLLAPSE;
18701 } else { 18774 } else {
18702 ret = XML_SCHEMAP_INVALID_FACET_VALUE; 18775 ret = XML_SCHEMAP_INVALID_FACET_VALUE;
18703 /* No error message for RelaxNG. */ 18776 /* No error message for RelaxNG. */
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
18896 { 18969 {
18897 xmlSchemaParticlePtr particle = WXS_MODELGROUP_PARTICLE(mg); 18970 xmlSchemaParticlePtr particle = WXS_MODELGROUP_PARTICLE(mg);
18898 18971
18899 while (particle != NULL) { 18972 while (particle != NULL) {
18900 if ((WXS_PARTICLE_TERM(particle) == NULL) || 18973 if ((WXS_PARTICLE_TERM(particle) == NULL) ||
18901 ((WXS_PARTICLE_TERM(particle))->type != 18974 ((WXS_PARTICLE_TERM(particle))->type !=
18902 XML_SCHEMA_TYPE_GROUP)) 18975 XML_SCHEMA_TYPE_GROUP))
18903 { 18976 {
18904 particle = WXS_PTC_CAST particle->next; 18977 particle = WXS_PTC_CAST particle->next;
18905 continue; 18978 continue;
18906 » } 18979 » }
18907 if (WXS_MODELGROUPDEF_MODEL(WXS_PARTICLE_TERM(particle)) == NULL) { 18980 if (WXS_MODELGROUPDEF_MODEL(WXS_PARTICLE_TERM(particle)) == NULL) {
18908 /* 18981 /*
18909 * TODO: Remove the particle. 18982 * TODO: Remove the particle.
18910 */ 18983 */
18911 WXS_PARTICLE_TERM(particle) = NULL; 18984 WXS_PARTICLE_TERM(particle) = NULL;
18912 particle = WXS_PTC_CAST particle->next; 18985 particle = WXS_PTC_CAST particle->next;
18913 continue; 18986 continue;
18914 } 18987 }
18915 /* 18988 /*
18916 * Assign the model group to the {term} of the particle. 18989 * Assign the model group to the {term} of the particle.
(...skipping 29 matching lines...) Expand all
18946 for (i = 0; i < list->nbItems; i++) { 19019 for (i = 0; i < list->nbItems; i++) {
18947 ref = list->items[i]; 19020 ref = list->items[i];
18948 if ((ref->type == XML_SCHEMA_EXTRA_QNAMEREF) && 19021 if ((ref->type == XML_SCHEMA_EXTRA_QNAMEREF) &&
18949 (ref->itemType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP) && 19022 (ref->itemType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP) &&
18950 (ref->item != NULL)) 19023 (ref->item != NULL))
18951 { 19024 {
18952 gr = WXS_ATTR_GROUP_CAST ref->item; 19025 gr = WXS_ATTR_GROUP_CAST ref->item;
18953 if (gr == ctxtGr) 19026 if (gr == ctxtGr)
18954 return(ref); 19027 return(ref);
18955 if (gr->flags & XML_SCHEMAS_ATTRGROUP_MARKED) 19028 if (gr->flags & XML_SCHEMAS_ATTRGROUP_MARKED)
18956 » » continue;» 19029 » » continue;
18957 /* 19030 /*
18958 * Mark as visited to avoid infinite recursion on 19031 * Mark as visited to avoid infinite recursion on
18959 * circular references not yet examined. 19032 * circular references not yet examined.
18960 */ 19033 */
18961 if ((gr->attrUses) && 19034 if ((gr->attrUses) &&
18962 (gr->flags & XML_SCHEMAS_ATTRGROUP_HAS_REFS)) 19035 (gr->flags & XML_SCHEMAS_ATTRGROUP_HAS_REFS))
18963 { 19036 {
18964 gr->flags |= XML_SCHEMAS_ATTRGROUP_MARKED; 19037 gr->flags |= XML_SCHEMAS_ATTRGROUP_MARKED;
18965 circ = xmlSchemaCheckAttrGroupCircularRecur(ctxtGr, 19038 circ = xmlSchemaCheckAttrGroupCircularRecur(ctxtGr,
18966 » » (xmlSchemaItemListPtr) gr->attrUses);» » 19039 » » (xmlSchemaItemListPtr) gr->attrUses);
18967 gr->flags ^= XML_SCHEMAS_ATTRGROUP_MARKED; 19040 gr->flags ^= XML_SCHEMAS_ATTRGROUP_MARKED;
18968 if (circ != NULL) 19041 if (circ != NULL)
18969 return (circ); 19042 return (circ);
18970 } 19043 }
18971 » 19044
18972 } 19045 }
18973 } 19046 }
18974 return (NULL); 19047 return (NULL);
18975 } 19048 }
18976 19049
18977 /** 19050 /**
18978 * xmlSchemaCheckAttrGroupCircular: 19051 * xmlSchemaCheckAttrGroupCircular:
18979 * attrGr: the attribute group definition 19052 * attrGr: the attribute group definition
18980 * @ctxt: the parser context 19053 * @ctxt: the parser context
18981 * @name: the name 19054 * @name: the name
18982 * 19055 *
18983 * Checks for circular references of attribute groups. 19056 * Checks for circular references of attribute groups.
18984 */ 19057 */
18985 static int 19058 static int
18986 xmlSchemaCheckAttrGroupCircular(xmlSchemaAttributeGroupPtr attrGr, 19059 xmlSchemaCheckAttrGroupCircular(xmlSchemaAttributeGroupPtr attrGr,
18987 xmlSchemaParserCtxtPtr ctxt) 19060 xmlSchemaParserCtxtPtr ctxt)
18988 { 19061 {
18989 /* 19062 /*
18990 * Schema Representation Constraint: 19063 * Schema Representation Constraint:
18991 * Attribute Group Definition Representation OK 19064 * Attribute Group Definition Representation OK
18992 * 3 Circular group reference is disallowed outside <redefine>. 19065 * 3 Circular group reference is disallowed outside <redefine>.
18993 * That is, unless this element information item's parent is 19066 * That is, unless this element information item's parent is
18994 * <redefine>, then among the [children], if any, there must 19067 * <redefine>, then among the [children], if any, there must
18995 * not be an <attributeGroup> with ref [attribute] which resolves 19068 * not be an <attributeGroup> with ref [attribute] which resolves
18996 * to the component corresponding to this <attributeGroup>. Indirect 19069 * to the component corresponding to this <attributeGroup>. Indirect
18997 * circularity is also ruled out. That is, when QName resolution 19070 * circularity is also ruled out. That is, when QName resolution
18998 * (Schema Document) (§3.15.3) is applied to a ·QName· arising from 19071 * (Schema Document) (�3.15.3) is applied to a �QName� arising from
18999 * any <attributeGroup>s with a ref [attribute] among the [children], 19072 * any <attributeGroup>s with a ref [attribute] among the [children],
19000 * it must not be the case that a ·QName· is encountered at any depth 19073 * it must not be the case that a �QName� is encountered at any depth
19001 * which resolves to the component corresponding to this <attributeGroup>. 19074 * which resolves to the component corresponding to this <attributeGroup>.
19002 */ 19075 */
19003 if (attrGr->attrUses == NULL) 19076 if (attrGr->attrUses == NULL)
19004 return(0); 19077 return(0);
19005 else if ((attrGr->flags & XML_SCHEMAS_ATTRGROUP_HAS_REFS) == 0) 19078 else if ((attrGr->flags & XML_SCHEMAS_ATTRGROUP_HAS_REFS) == 0)
19006 return(0); 19079 return(0);
19007 else { 19080 else {
19008 xmlSchemaQNameRefPtr circ; 19081 xmlSchemaQNameRefPtr circ;
19009 » 19082
19010 circ = xmlSchemaCheckAttrGroupCircularRecur(attrGr, 19083 circ = xmlSchemaCheckAttrGroupCircularRecur(attrGr,
19011 » (xmlSchemaItemListPtr) attrGr->attrUses);» 19084 » (xmlSchemaItemListPtr) attrGr->attrUses);
19012 if (circ != NULL) { 19085 if (circ != NULL) {
19013 xmlChar *str = NULL; 19086 xmlChar *str = NULL;
19014 /* 19087 /*
19015 * TODO: Report the referenced attr group as QName. 19088 * TODO: Report the referenced attr group as QName.
19016 */ 19089 */
19017 xmlSchemaPCustomErr(ctxt, 19090 xmlSchemaPCustomErr(ctxt,
19018 XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3, 19091 XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3,
19019 NULL, WXS_ITEM_NODE(WXS_BASIC_CAST circ), 19092 NULL, WXS_ITEM_NODE(WXS_BASIC_CAST circ),
19020 "Circular reference to the attribute group '%s' " 19093 "Circular reference to the attribute group '%s' "
19021 "defined", xmlSchemaGetComponentQName(&str, attrGr)); 19094 "defined", xmlSchemaGetComponentQName(&str, attrGr));
(...skipping 11 matching lines...) Expand all
19033 } 19106 }
19034 19107
19035 static int 19108 static int
19036 xmlSchemaAttributeGroupExpandRefs(xmlSchemaParserCtxtPtr pctxt, 19109 xmlSchemaAttributeGroupExpandRefs(xmlSchemaParserCtxtPtr pctxt,
19037 xmlSchemaAttributeGroupPtr attrGr); 19110 xmlSchemaAttributeGroupPtr attrGr);
19038 19111
19039 /** 19112 /**
19040 * xmlSchemaExpandAttributeGroupRefs: 19113 * xmlSchemaExpandAttributeGroupRefs:
19041 * @pctxt: the parser context 19114 * @pctxt: the parser context
19042 * @node: the node of the component holding the attribute uses 19115 * @node: the node of the component holding the attribute uses
19043 * @completeWild: the intersected wildcard to be returned 19116 * @completeWild: the intersected wildcard to be returned
19044 * @list: the attribute uses 19117 * @list: the attribute uses
19045 * 19118 *
19046 * Substitutes contained attribute group references 19119 * Substitutes contained attribute group references
19047 * for their attribute uses. Wilcards are intersected. 19120 * for their attribute uses. Wilcards are intersected.
19048 * Attribute use prohibitions are removed from the list 19121 * Attribute use prohibitions are removed from the list
19049 * and returned via the @prohibs list. 19122 * and returned via the @prohibs list.
19050 * Pointlessness of attr. prohibs, if a matching attr. decl 19123 * Pointlessness of attr. prohibs, if a matching attr. decl
19051 * is existent a well, are checked. 19124 * is existent a well, are checked.
19052 */ 19125 */
19053 static int 19126 static int
19054 xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt, 19127 xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt,
19055 xmlSchemaBasicItemPtr item, 19128 xmlSchemaBasicItemPtr item,
19056 xmlSchemaWildcardPtr *completeWild, 19129 xmlSchemaWildcardPtr *completeWild,
19057 xmlSchemaItemListPtr list, 19130 xmlSchemaItemListPtr list,
19058 xmlSchemaItemListPtr prohibs) 19131 xmlSchemaItemListPtr prohibs)
19059 { 19132 {
19060 xmlSchemaAttributeGroupPtr gr; 19133 xmlSchemaAttributeGroupPtr gr;
19061 xmlSchemaAttributeUsePtr use; 19134 xmlSchemaAttributeUsePtr use;
19062 xmlSchemaItemListPtr sublist; 19135 xmlSchemaItemListPtr sublist;
19063 int i, j; 19136 int i, j;
19064 int created = (*completeWild == NULL) ? 0 : 1; 19137 int created = (*completeWild == NULL) ? 0 : 1;
19065 19138
19066 if (prohibs) 19139 if (prohibs)
19067 prohibs->nbItems = 0; 19140 prohibs->nbItems = 0;
19068 19141
19069 for (i = 0; i < list->nbItems; i++) { 19142 for (i = 0; i < list->nbItems; i++) {
19070 use = list->items[i]; 19143 use = list->items[i];
19071 19144
19072 » if (use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) {» 19145 » if (use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) {
19073 if (prohibs == NULL) { 19146 if (prohibs == NULL) {
19074 PERROR_INT("xmlSchemaExpandAttributeGroupRefs", 19147 PERROR_INT("xmlSchemaExpandAttributeGroupRefs",
19075 "unexpected attr prohibition found"); 19148 "unexpected attr prohibition found");
19076 return(-1); 19149 return(-1);
19077 } 19150 }
19078 /* 19151 /*
19079 * Remove from attribute uses. 19152 * Remove from attribute uses.
19080 */ 19153 */
19081 if (xmlSchemaItemListRemove(list, i) == -1) 19154 if (xmlSchemaItemListRemove(list, i) == -1)
19082 return(-1); 19155 return(-1);
19083 i--; 19156 i--;
19084 /* 19157 /*
19085 * Note that duplicate prohibitions were already 19158 * Note that duplicate prohibitions were already
19086 * handled at parsing time. 19159 * handled at parsing time.
19087 » */» 19160 » */
19088 /* 19161 /*
19089 * Add to list of prohibitions. 19162 * Add to list of prohibitions.
19090 */ 19163 */
19091 xmlSchemaItemListAddSize(prohibs, 2, use); 19164 xmlSchemaItemListAddSize(prohibs, 2, use);
19092 continue; 19165 continue;
19093 } 19166 }
19094 if ((use->type == XML_SCHEMA_EXTRA_QNAMEREF) && 19167 if ((use->type == XML_SCHEMA_EXTRA_QNAMEREF) &&
19095 ((WXS_QNAME_CAST use)->itemType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP)) 19168 ((WXS_QNAME_CAST use)->itemType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP))
19096 { 19169 {
19097 if ((WXS_QNAME_CAST use)->item == NULL) 19170 if ((WXS_QNAME_CAST use)->item == NULL)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
19130 WXS_ITEM_NODE(item)); 19203 WXS_ITEM_NODE(item));
19131 if (tmpWild == NULL) 19204 if (tmpWild == NULL)
19132 return(-1); 19205 return(-1);
19133 if (xmlSchemaCloneWildcardNsConstraints(pctxt, 19206 if (xmlSchemaCloneWildcardNsConstraints(pctxt,
19134 tmpWild, *completeWild) == -1) 19207 tmpWild, *completeWild) == -1)
19135 return (-1); 19208 return (-1);
19136 tmpWild->processContents = (*completeWild)->processConte nts; 19209 tmpWild->processContents = (*completeWild)->processConte nts;
19137 *completeWild = tmpWild; 19210 *completeWild = tmpWild;
19138 created = 1; 19211 created = 1;
19139 } 19212 }
19140 » » 19213
19141 if (xmlSchemaIntersectWildcards(pctxt, *completeWild, 19214 if (xmlSchemaIntersectWildcards(pctxt, *completeWild,
19142 gr->attributeWildcard) == -1) 19215 gr->attributeWildcard) == -1)
19143 return(-1); 19216 return(-1);
19144 } 19217 }
19145 } 19218 }
19146 /* 19219 /*
19147 * Just remove the reference if the referenced group does not 19220 * Just remove the reference if the referenced group does not
19148 * contain any attribute uses. 19221 * contain any attribute uses.
19149 */ 19222 */
19150 sublist = ((xmlSchemaItemListPtr) gr->attrUses); 19223 sublist = ((xmlSchemaItemListPtr) gr->attrUses);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
19204 } 19277 }
19205 } 19278 }
19206 } 19279 }
19207 } 19280 }
19208 return(0); 19281 return(0);
19209 } 19282 }
19210 19283
19211 /** 19284 /**
19212 * xmlSchemaAttributeGroupExpandRefs: 19285 * xmlSchemaAttributeGroupExpandRefs:
19213 * @pctxt: the parser context 19286 * @pctxt: the parser context
19214 * @attrGr: the attribute group definition 19287 * @attrGr: the attribute group definition
19215 * 19288 *
19216 * Computation of: 19289 * Computation of:
19217 * {attribute uses} property 19290 * {attribute uses} property
19218 * {attribute wildcard} property 19291 * {attribute wildcard} property
19219 * 19292 *
19220 * Substitutes contained attribute group references 19293 * Substitutes contained attribute group references
19221 * for their attribute uses. Wilcards are intersected. 19294 * for their attribute uses. Wilcards are intersected.
19222 */ 19295 */
19223 static int 19296 static int
19224 xmlSchemaAttributeGroupExpandRefs(xmlSchemaParserCtxtPtr pctxt, 19297 xmlSchemaAttributeGroupExpandRefs(xmlSchemaParserCtxtPtr pctxt,
19225 xmlSchemaAttributeGroupPtr attrGr) 19298 xmlSchemaAttributeGroupPtr attrGr)
19226 { 19299 {
19227 if ((attrGr->attrUses == NULL) || 19300 if ((attrGr->attrUses == NULL) ||
19228 (attrGr->flags & XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED)) 19301 (attrGr->flags & XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED))
19229 return(0); 19302 return(0);
19230 19303
19231 attrGr->flags |= XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED; 19304 attrGr->flags |= XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED;
19232 if (xmlSchemaExpandAttributeGroupRefs(pctxt, WXS_BASIC_CAST attrGr, 19305 if (xmlSchemaExpandAttributeGroupRefs(pctxt, WXS_BASIC_CAST attrGr,
19233 &(attrGr->attributeWildcard), attrGr->attrUses, NULL) == -1) 19306 &(attrGr->attributeWildcard), attrGr->attrUses, NULL) == -1)
19234 » return(-1); 19307 » return(-1);
19235 return(0); 19308 return(0);
19236 } 19309 }
19237 19310
19238 /** 19311 /**
19239 * xmlSchemaAttributeGroupExpandRefs: 19312 * xmlSchemaAttributeGroupExpandRefs:
19240 * @pctxt: the parser context 19313 * @pctxt: the parser context
19241 * @attrGr: the attribute group definition 19314 * @attrGr: the attribute group definition
19242 * 19315 *
19243 * Substitutes contained attribute group references 19316 * Substitutes contained attribute group references
19244 * for their attribute uses. Wilcards are intersected. 19317 * for their attribute uses. Wilcards are intersected.
19245 * 19318 *
19246 * Schema Component Constraint: 19319 * Schema Component Constraint:
19247 * Attribute Group Definition Properties Correct (ag-props-correct) 19320 * Attribute Group Definition Properties Correct (ag-props-correct)
19248 */ 19321 */
19249 static int 19322 static int
19250 xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt, 19323 xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
19251 xmlSchemaAttributeGroupPtr attrGr) 19324 xmlSchemaAttributeGroupPtr attrGr)
19252 { 19325 {
19253 /* 19326 /*
19254 * SPEC ag-props-correct 19327 * SPEC ag-props-correct
19255 * (1) "The values of the properties of an attribute group definition 19328 * (1) "The values of the properties of an attribute group definition
19256 * must be as described in the property tableau in The Attribute 19329 * must be as described in the property tableau in The Attribute
19257 * Group Definition Schema Component (§3.6.1), modulo the impact of 19330 * Group Definition Schema Component (�3.6.1), modulo the impact of
19258 * Missing Sub-components (§5.3);" 19331 * Missing Sub-components (�5.3);"
19259 */ 19332 */
19260 19333
19261 if ((attrGr->attrUses != NULL) && 19334 if ((attrGr->attrUses != NULL) &&
19262 (WXS_LIST_CAST attrGr->attrUses)->nbItems > 1) 19335 (WXS_LIST_CAST attrGr->attrUses)->nbItems > 1)
19263 { 19336 {
19264 xmlSchemaItemListPtr uses = WXS_LIST_CAST attrGr->attrUses; 19337 xmlSchemaItemListPtr uses = WXS_LIST_CAST attrGr->attrUses;
19265 xmlSchemaAttributeUsePtr use, tmp; 19338 xmlSchemaAttributeUsePtr use, tmp;
19266 int i, j, hasId = 0; 19339 int i, j, hasId = 0;
19267 19340
19268 for (i = uses->nbItems -1; i >= 0; i--) { 19341 for (i = uses->nbItems -1; i >= 0; i--) {
19269 » use = uses->items[i];» 19342 » use = uses->items[i];
19270 /* 19343 /*
19271 * SPEC ag-props-correct 19344 * SPEC ag-props-correct
19272 * (2) "Two distinct members of the {attribute uses} must not have 19345 * (2) "Two distinct members of the {attribute uses} must not have
19273 * {attribute declaration}s both of whose {name}s match and whose 19346 * {attribute declaration}s both of whose {name}s match and whose
19274 * {target namespace}s are identical." 19347 * {target namespace}s are identical."
19275 */ 19348 */
19276 if (i > 0) { 19349 if (i > 0) {
19277 for (j = i -1; j >= 0; j--) { 19350 for (j = i -1; j >= 0; j--) {
19278 tmp = uses->items[j]; 19351 tmp = uses->items[j];
19279 if ((WXS_ATTRUSE_DECL_NAME(use) == 19352 if ((WXS_ATTRUSE_DECL_NAME(use) ==
19280 WXS_ATTRUSE_DECL_NAME(tmp)) && 19353 WXS_ATTRUSE_DECL_NAME(tmp)) &&
19281 (WXS_ATTRUSE_DECL_TNS(use) == 19354 (WXS_ATTRUSE_DECL_TNS(use) ==
19282 WXS_ATTRUSE_DECL_TNS(tmp))) 19355 WXS_ATTRUSE_DECL_TNS(tmp)))
19283 { 19356 {
19284 xmlChar *str = NULL; 19357 xmlChar *str = NULL;
19285 » » » 19358
19286 xmlSchemaCustomErr(ACTXT_CAST pctxt, 19359 xmlSchemaCustomErr(ACTXT_CAST pctxt,
19287 XML_SCHEMAP_AG_PROPS_CORRECT, 19360 XML_SCHEMAP_AG_PROPS_CORRECT,
19288 attrGr->node, WXS_BASIC_CAST attrGr, 19361 attrGr->node, WXS_BASIC_CAST attrGr,
19289 "Duplicate %s", 19362 "Duplicate %s",
19290 xmlSchemaGetComponentDesignation(&str, use), 19363 xmlSchemaGetComponentDesignation(&str, use),
19291 NULL); 19364 NULL);
19292 FREE_AND_NULL(str); 19365 FREE_AND_NULL(str);
19293 /* 19366 /*
19294 * Remove the duplicate. 19367 * Remove the duplicate.
19295 */ 19368 */
19296 if (xmlSchemaItemListRemove(uses, i) == -1) 19369 if (xmlSchemaItemListRemove(uses, i) == -1)
19297 return(-1); 19370 return(-1);
19298 goto next_use; 19371 goto next_use;
19299 } 19372 }
19300 } 19373 }
19301 } 19374 }
19302 /* 19375 /*
19303 * SPEC ag-props-correct 19376 * SPEC ag-props-correct
19304 * (3) "Two distinct members of the {attribute uses} must not have 19377 * (3) "Two distinct members of the {attribute uses} must not have
19305 * {attribute declaration}s both of whose {type definition}s are or 19378 * {attribute declaration}s both of whose {type definition}s are or
19306 * are derived from ID." 19379 * are derived from ID."
19307 * TODO: Does 'derived' include member-types of unions? 19380 * TODO: Does 'derived' include member-types of unions?
19308 */ 19381 */
19309 » if (WXS_ATTRUSE_TYPEDEF(use) != NULL) {» » 19382 » if (WXS_ATTRUSE_TYPEDEF(use) != NULL) {
19310 if (xmlSchemaIsDerivedFromBuiltInType( 19383 if (xmlSchemaIsDerivedFromBuiltInType(
19311 WXS_ATTRUSE_TYPEDEF(use), XML_SCHEMAS_ID)) 19384 WXS_ATTRUSE_TYPEDEF(use), XML_SCHEMAS_ID))
19312 » » {» » 19385 » » {
19313 if (hasId) { 19386 if (hasId) {
19314 xmlChar *str = NULL; 19387 xmlChar *str = NULL;
19315 » » » 19388
19316 xmlSchemaCustomErr(ACTXT_CAST pctxt, 19389 xmlSchemaCustomErr(ACTXT_CAST pctxt,
19317 XML_SCHEMAP_AG_PROPS_CORRECT, 19390 XML_SCHEMAP_AG_PROPS_CORRECT,
19318 attrGr->node, WXS_BASIC_CAST attrGr, 19391 attrGr->node, WXS_BASIC_CAST attrGr,
19319 "There must not exist more than one attribute " 19392 "There must not exist more than one attribute "
19320 "declaration of type 'xs:ID' " 19393 "declaration of type 'xs:ID' "
19321 "(or derived from 'xs:ID'). The %s violates this " 19394 "(or derived from 'xs:ID'). The %s violates this "
19322 "constraint", 19395 "constraint",
19323 xmlSchemaGetComponentDesignation(&str, use), 19396 xmlSchemaGetComponentDesignation(&str, use),
19324 NULL); 19397 NULL);
19325 FREE_AND_NULL(str); 19398 FREE_AND_NULL(str);
19326 if (xmlSchemaItemListRemove(uses, i) == -1) 19399 if (xmlSchemaItemListRemove(uses, i) == -1)
19327 return(-1); 19400 return(-1);
19328 » » }» » 19401 » » }
19329 hasId = 1; 19402 hasId = 1;
19330 } 19403 }
19331 } 19404 }
19332 next_use: {} 19405 next_use: {}
19333 } 19406 }
19334 } 19407 }
19335 return(0); 19408 return(0);
19336 } 19409 }
19337 19410
19338 /** 19411 /**
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
19382 */ 19455 */
19383 static int 19456 static int
19384 xmlSchemaCheckAttrPropsCorrect(xmlSchemaParserCtxtPtr pctxt, 19457 xmlSchemaCheckAttrPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
19385 xmlSchemaAttributePtr attr) 19458 xmlSchemaAttributePtr attr)
19386 { 19459 {
19387 19460
19388 /* 19461 /*
19389 * SPEC a-props-correct (1) 19462 * SPEC a-props-correct (1)
19390 * "The values of the properties of an attribute declaration must 19463 * "The values of the properties of an attribute declaration must
19391 * be as described in the property tableau in The Attribute 19464 * be as described in the property tableau in The Attribute
19392 * Declaration Schema Component (§3.2.1), modulo the impact of 19465 * Declaration Schema Component (�3.2.1), modulo the impact of
19393 * Missing Sub-components (§5.3)." 19466 * Missing Sub-components (�5.3)."
19394 */ 19467 */
19395 19468
19396 if (WXS_ATTR_TYPEDEF(attr) == NULL) 19469 if (WXS_ATTR_TYPEDEF(attr) == NULL)
19397 return(0); 19470 return(0);
19398 19471
19399 if (attr->defValue != NULL) { 19472 if (attr->defValue != NULL) {
19400 int ret; 19473 int ret;
19401 19474
19402 /* 19475 /*
19403 * SPEC a-props-correct (3) 19476 * SPEC a-props-correct (3)
19404 * "If the {type definition} is or is derived from ID then there 19477 * "If the {type definition} is or is derived from ID then there
19405 * must not be a {value constraint}." 19478 * must not be a {value constraint}."
19406 */ 19479 */
19407 if (xmlSchemaIsDerivedFromBuiltInType( 19480 if (xmlSchemaIsDerivedFromBuiltInType(
19408 WXS_ATTR_TYPEDEF(attr), XML_SCHEMAS_ID)) 19481 WXS_ATTR_TYPEDEF(attr), XML_SCHEMAS_ID))
19409 { 19482 {
19410 xmlSchemaCustomErr(ACTXT_CAST pctxt, 19483 xmlSchemaCustomErr(ACTXT_CAST pctxt,
19411 XML_SCHEMAP_A_PROPS_CORRECT_3, 19484 XML_SCHEMAP_A_PROPS_CORRECT_3,
19412 NULL, WXS_BASIC_CAST attr, 19485 NULL, WXS_BASIC_CAST attr,
19413 "Value constraints are not allowed if the type definition " 19486 "Value constraints are not allowed if the type definition "
19414 "is or is derived from xs:ID", 19487 "is or is derived from xs:ID",
19415 NULL, NULL); 19488 NULL, NULL);
19416 return(pctxt->err); 19489 return(pctxt->err);
19417 } 19490 }
19418 /* 19491 /*
19419 * SPEC a-props-correct (2) 19492 * SPEC a-props-correct (2)
19420 * "if there is a {value constraint}, the canonical lexical 19493 * "if there is a {value constraint}, the canonical lexical
19421 » * representation of its value must be ·valid· with respect 19494 » * representation of its value must be �valid� with respect
19422 » * to the {type definition} as defined in String Valid (§3.14.4)." 19495 » * to the {type definition} as defined in String Valid (�3.14.4)."
19423 * TODO: Don't care about the *cononical* stuff here, this requirement 19496 * TODO: Don't care about the *cononical* stuff here, this requirement
19424 * will be removed in WXS 1.1 anyway. 19497 * will be removed in WXS 1.1 anyway.
19425 */ 19498 */
19426 ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST pctxt, 19499 ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST pctxt,
19427 attr->node, WXS_ATTR_TYPEDEF(attr), 19500 attr->node, WXS_ATTR_TYPEDEF(attr),
19428 attr->defValue, &(attr->defVal), 19501 attr->defValue, &(attr->defVal),
19429 1, 1, 0); 19502 1, 1, 0);
19430 if (ret != 0) { 19503 if (ret != 0) {
19431 if (ret < 0) { 19504 if (ret < 0) {
19432 PERROR_INT("xmlSchemaCheckAttrPropsCorrect", 19505 PERROR_INT("xmlSchemaCheckAttrPropsCorrect",
19433 "calling xmlSchemaVCheckCVCSimpleType()"); 19506 "calling xmlSchemaVCheckCVCSimpleType()");
19434 return(-1); 19507 return(-1);
19435 } 19508 }
19436 xmlSchemaCustomErr(ACTXT_CAST pctxt, 19509 xmlSchemaCustomErr(ACTXT_CAST pctxt,
19437 XML_SCHEMAP_A_PROPS_CORRECT_2, 19510 XML_SCHEMAP_A_PROPS_CORRECT_2,
19438 NULL, WXS_BASIC_CAST attr, 19511 NULL, WXS_BASIC_CAST attr,
19439 "The value of the value constraint is not valid", 19512 "The value of the value constraint is not valid",
19440 NULL, NULL); 19513 NULL, NULL);
19441 return(pctxt->err); 19514 return(pctxt->err);
19442 } 19515 }
19443 } 19516 }
19444 19517
19445 return(0); 19518 return(0);
19446 } 19519 }
19447 19520
19448 static xmlSchemaElementPtr 19521 static xmlSchemaElementPtr
19449 xmlSchemaCheckSubstGroupCircular(xmlSchemaElementPtr elemDecl, 19522 xmlSchemaCheckSubstGroupCircular(xmlSchemaElementPtr elemDecl,
19450 xmlSchemaElementPtr ancestor) 19523 xmlSchemaElementPtr ancestor)
19451 { 19524 {
19452 xmlSchemaElementPtr ret; 19525 xmlSchemaElementPtr ret;
19453 19526
19454 if (WXS_SUBST_HEAD(ancestor) == NULL) 19527 if (WXS_SUBST_HEAD(ancestor) == NULL)
(...skipping 25 matching lines...) Expand all
19480 */ 19553 */
19481 static int 19554 static int
19482 xmlSchemaCheckElemPropsCorrect(xmlSchemaParserCtxtPtr pctxt, 19555 xmlSchemaCheckElemPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
19483 xmlSchemaElementPtr elemDecl) 19556 xmlSchemaElementPtr elemDecl)
19484 { 19557 {
19485 int ret = 0; 19558 int ret = 0;
19486 xmlSchemaTypePtr typeDef = WXS_ELEM_TYPEDEF(elemDecl); 19559 xmlSchemaTypePtr typeDef = WXS_ELEM_TYPEDEF(elemDecl);
19487 /* 19560 /*
19488 * SPEC (1) "The values of the properties of an element declaration 19561 * SPEC (1) "The values of the properties of an element declaration
19489 * must be as described in the property tableau in The Element 19562 * must be as described in the property tableau in The Element
19490 * Declaration Schema Component (§3.3.1), modulo the impact of Missing 19563 * Declaration Schema Component (�3.3.1), modulo the impact of Missing
19491 * Sub-components (§5.3)." 19564 * Sub-components (�5.3)."
19492 */ 19565 */
19493 if (WXS_SUBST_HEAD(elemDecl) != NULL) { 19566 if (WXS_SUBST_HEAD(elemDecl) != NULL) {
19494 xmlSchemaElementPtr head = WXS_SUBST_HEAD(elemDecl), circ; 19567 xmlSchemaElementPtr head = WXS_SUBST_HEAD(elemDecl), circ;
19495 19568
19496 xmlSchemaCheckElementDeclComponent(head, pctxt); 19569 xmlSchemaCheckElementDeclComponent(head, pctxt);
19497 /* 19570 /*
19498 » * SPEC (3) "If there is a non-·absent· {substitution group 19571 » * SPEC (3) "If there is a non-�absent� {substitution group
19499 * affiliation}, then {scope} must be global." 19572 * affiliation}, then {scope} must be global."
19500 */ 19573 */
19501 if ((elemDecl->flags & XML_SCHEMAS_ELEM_GLOBAL) == 0) { 19574 if ((elemDecl->flags & XML_SCHEMAS_ELEM_GLOBAL) == 0) {
19502 xmlSchemaPCustomErr(pctxt, 19575 xmlSchemaPCustomErr(pctxt,
19503 XML_SCHEMAP_E_PROPS_CORRECT_3, 19576 XML_SCHEMAP_E_PROPS_CORRECT_3,
19504 WXS_BASIC_CAST elemDecl, NULL, 19577 WXS_BASIC_CAST elemDecl, NULL,
19505 "Only global element declarations can have a " 19578 "Only global element declarations can have a "
19506 "substitution group affiliation", NULL); 19579 "substitution group affiliation", NULL);
19507 ret = XML_SCHEMAP_E_PROPS_CORRECT_3; 19580 ret = XML_SCHEMAP_E_PROPS_CORRECT_3;
19508 } 19581 }
(...skipping 23 matching lines...) Expand all
19532 FREE_AND_NULL(strA) 19605 FREE_AND_NULL(strA)
19533 FREE_AND_NULL(strB) 19606 FREE_AND_NULL(strB)
19534 ret = XML_SCHEMAP_E_PROPS_CORRECT_6; 19607 ret = XML_SCHEMAP_E_PROPS_CORRECT_6;
19535 } 19608 }
19536 /* 19609 /*
19537 * SPEC (4) "If there is a {substitution group affiliation}, 19610 * SPEC (4) "If there is a {substitution group affiliation},
19538 * the {type definition} 19611 * the {type definition}
19539 * of the element declaration must be validly derived from the {type 19612 * of the element declaration must be validly derived from the {type
19540 * definition} of the {substitution group affiliation}, given the value 19613 * definition} of the {substitution group affiliation}, given the value
19541 * of the {substitution group exclusions} of the {substitution group 19614 * of the {substitution group exclusions} of the {substitution group
19542 » * affiliation}, as defined in Type Derivation OK (Complex) (§3.4.6) 19615 » * affiliation}, as defined in Type Derivation OK (Complex) (�3.4.6)
19543 * (if the {type definition} is complex) or as defined in 19616 * (if the {type definition} is complex) or as defined in
19544 » * Type Derivation OK (Simple) (§3.14.6) (if the {type definition} is 19617 » * Type Derivation OK (Simple) (�3.14.6) (if the {type definition} is
19545 * simple)." 19618 * simple)."
19546 * 19619 *
19547 * NOTE: {substitution group exclusions} means the values of the 19620 * NOTE: {substitution group exclusions} means the values of the
19548 * attribute "final". 19621 * attribute "final".
19549 */ 19622 */
19550 19623
19551 if (typeDef != WXS_ELEM_TYPEDEF(WXS_SUBST_HEAD(elemDecl))) { 19624 if (typeDef != WXS_ELEM_TYPEDEF(WXS_SUBST_HEAD(elemDecl))) {
19552 int set = 0; 19625 int set = 0;
19553 19626
19554 if (head->flags & XML_SCHEMAS_ELEM_FINAL_EXTENSION) 19627 if (head->flags & XML_SCHEMAS_ELEM_FINAL_EXTENSION)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
19598 WXS_BASIC_CAST elemDecl, NULL, 19671 WXS_BASIC_CAST elemDecl, NULL,
19599 "The type definition (or type definition's content type) is or " 19672 "The type definition (or type definition's content type) is or "
19600 "is derived from ID; value constraints are not allowed in " 19673 "is derived from ID; value constraints are not allowed in "
19601 "conjunction with such a type definition", NULL); 19674 "conjunction with such a type definition", NULL);
19602 } else if (elemDecl->value != NULL) { 19675 } else if (elemDecl->value != NULL) {
19603 int vcret; 19676 int vcret;
19604 xmlNodePtr node = NULL; 19677 xmlNodePtr node = NULL;
19605 19678
19606 /* 19679 /*
19607 * SPEC (2) "If there is a {value constraint}, the canonical lexical 19680 * SPEC (2) "If there is a {value constraint}, the canonical lexical
19608 » * representation of its value must be ·valid· with respect to the 19681 » * representation of its value must be �valid� with respect to the
19609 * {type definition} as defined in Element Default Valid (Immediate) 19682 * {type definition} as defined in Element Default Valid (Immediate)
19610 » * (§3.3.6)." 19683 » * (�3.3.6)."
19611 */ 19684 */
19612 if (typeDef == NULL) { 19685 if (typeDef == NULL) {
19613 xmlSchemaPErr(pctxt, elemDecl->node, 19686 xmlSchemaPErr(pctxt, elemDecl->node,
19614 XML_SCHEMAP_INTERNAL, 19687 XML_SCHEMAP_INTERNAL,
19615 "Internal error: xmlSchemaCheckElemPropsCorrect, " 19688 "Internal error: xmlSchemaCheckElemPropsCorrect, "
19616 "type is missing... skipping validation of " 19689 "type is missing... skipping validation of "
19617 "the value constraint", NULL, NULL); 19690 "the value constraint", NULL, NULL);
19618 return (-1); 19691 return (-1);
19619 } 19692 }
19620 if (elemDecl->node != NULL) { 19693 if (elemDecl->node != NULL) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
19668 /* SPEC (1) "Its {abstract} is false." */ 19741 /* SPEC (1) "Its {abstract} is false." */
19669 (elemDecl->flags & XML_SCHEMAS_ELEM_ABSTRACT)) 19742 (elemDecl->flags & XML_SCHEMAS_ELEM_ABSTRACT))
19670 return; 19743 return;
19671 { 19744 {
19672 xmlSchemaElementPtr head; 19745 xmlSchemaElementPtr head;
19673 xmlSchemaTypePtr headType, type; 19746 xmlSchemaTypePtr headType, type;
19674 int set, methSet; 19747 int set, methSet;
19675 /* 19748 /*
19676 * SPEC (2) "It is validly substitutable for HEAD subject to HEAD's 19749 * SPEC (2) "It is validly substitutable for HEAD subject to HEAD's
19677 * {disallowed substitutions} as the blocking constraint, as defined in 19750 * {disallowed substitutions} as the blocking constraint, as defined in
19678 » * Substitution Group OK (Transitive) (§3.3.6)." 19751 » * Substitution Group OK (Transitive) (�3.3.6)."
19679 */ 19752 */
19680 for (head = WXS_SUBST_HEAD(elemDecl); head != NULL; 19753 for (head = WXS_SUBST_HEAD(elemDecl); head != NULL;
19681 head = WXS_SUBST_HEAD(head)) { 19754 head = WXS_SUBST_HEAD(head)) {
19682 set = 0; 19755 set = 0;
19683 methSet = 0; 19756 methSet = 0;
19684 /* 19757 /*
19685 * The blocking constraints. 19758 * The blocking constraints.
19686 */ 19759 */
19687 if (head->flags & XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION) 19760 if (head->flags & XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION)
19688 continue; 19761 continue;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
19760 } 19833 }
19761 19834
19762 #ifdef WXS_ELEM_DECL_CONS_ENABLED /* enable when finished */ 19835 #ifdef WXS_ELEM_DECL_CONS_ENABLED /* enable when finished */
19763 /** 19836 /**
19764 * xmlSchemaCheckElementDeclComponent 19837 * xmlSchemaCheckElementDeclComponent
19765 * @pctxt: the schema parser context 19838 * @pctxt: the schema parser context
19766 * @ctxtComponent: the context component (an element declaration) 19839 * @ctxtComponent: the context component (an element declaration)
19767 * @ctxtParticle: the first particle of the context component 19840 * @ctxtParticle: the first particle of the context component
19768 * @searchParticle: the element declaration particle to be analysed 19841 * @searchParticle: the element declaration particle to be analysed
19769 * 19842 *
19770 * Schema Component Constraint: Element Declarations Consistent 19843 * Schema Component Constraint: Element Declarations Consistent
19771 */ 19844 */
19772 static int 19845 static int
19773 xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt, 19846 xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt,
19774 xmlSchemaBasicItemPtr ctxtComponent, 19847 xmlSchemaBasicItemPtr ctxtComponent,
19775 » » » » xmlSchemaParticlePtr ctxtParticle,» » » » 19848 » » » » xmlSchemaParticlePtr ctxtParticle,
19776 xmlSchemaParticlePtr searchParticle, 19849 xmlSchemaParticlePtr searchParticle,
19777 xmlSchemaParticlePtr curParticle, 19850 xmlSchemaParticlePtr curParticle,
19778 int search) 19851 int search)
19779 { 19852 {
19780 return(0); 19853 return(0);
19781 19854
19782 int ret = 0; 19855 int ret = 0;
19783 xmlSchemaParticlePtr cur = curParticle; 19856 xmlSchemaParticlePtr cur = curParticle;
19784 if (curParticle == NULL) {» 19857 if (curParticle == NULL) {
19785 return(0); 19858 return(0);
19786 } 19859 }
19787 if (WXS_PARTICLE_TERM(curParticle) == NULL) { 19860 if (WXS_PARTICLE_TERM(curParticle) == NULL) {
19788 /* 19861 /*
19789 * Just return in this case. A missing "term" of the particle 19862 * Just return in this case. A missing "term" of the particle
19790 * might arise due to an invalid "term" component. 19863 * might arise due to an invalid "term" component.
19791 */ 19864 */
19792 return(0); 19865 return(0);
19793 } 19866 }
19794 while (cur != NULL) { 19867 while (cur != NULL) {
19795 switch (WXS_PARTICLE_TERM(cur)->type) { 19868 switch (WXS_PARTICLE_TERM(cur)->type) {
19796 case XML_SCHEMA_TYPE_ANY: 19869 case XML_SCHEMA_TYPE_ANY:
19797 break; 19870 break;
19798 case XML_SCHEMA_TYPE_ELEMENT: 19871 case XML_SCHEMA_TYPE_ELEMENT:
19799 if (search == 0) { 19872 if (search == 0) {
19800 ret = xmlSchemaCheckElementDeclConsistent(pctxt, 19873 ret = xmlSchemaCheckElementDeclConsistent(pctxt,
19801 ctxtComponent, ctxtParticle, cur, ctxtParticle, 1); 19874 ctxtComponent, ctxtParticle, cur, ctxtParticle, 1);
19802 if (ret != 0) 19875 if (ret != 0)
19803 » » » return(ret);» » 19876 » » » return(ret);
19804 } else { 19877 } else {
19805 xmlSchemaElementPtr elem = 19878 xmlSchemaElementPtr elem =
19806 WXS_ELEM_CAST(WXS_PARTICLE_TERM(cur)); 19879 WXS_ELEM_CAST(WXS_PARTICLE_TERM(cur));
19807 /* 19880 /*
19808 * SPEC Element Declarations Consistent: 19881 * SPEC Element Declarations Consistent:
19809 * "If the {particles} contains, either directly, 19882 * "If the {particles} contains, either directly,
19810 * indirectly (that is, within the {particles} of a 19883 * indirectly (that is, within the {particles} of a
19811 » » * contained model group, recursively) or ·implicitly· 19884 » » * contained model group, recursively) or �implicitly�
19812 * two or more element declaration particles with 19885 * two or more element declaration particles with
19813 * the same {name} and {target namespace}, then 19886 * the same {name} and {target namespace}, then
19814 * all their type definitions must be the same 19887 * all their type definitions must be the same
19815 * top-level definition [...]" 19888 * top-level definition [...]"
19816 */ 19889 */
19817 if (xmlStrEqual(WXS_PARTICLE_TERM_AS_ELEM(cur)->name, 19890 if (xmlStrEqual(WXS_PARTICLE_TERM_AS_ELEM(cur)->name,
19818 WXS_PARTICLE_TERM_AS_ELEM(searchParticle)->name) && 19891 WXS_PARTICLE_TERM_AS_ELEM(searchParticle)->name) &&
19819 xmlStrEqual(WXS_PARTICLE_TERM_AS_ELEM(cur)->targetNamesp ace, 19892 xmlStrEqual(WXS_PARTICLE_TERM_AS_ELEM(cur)->targetNamesp ace,
19820 WXS_PARTICLE_TERM_AS_ELEM(searchParticle)->targetNam espace)) 19893 WXS_PARTICLE_TERM_AS_ELEM(searchParticle)->targetNam espace))
19821 { 19894 {
19822 xmlChar *strA = NULL, *strB = NULL; 19895 xmlChar *strA = NULL, *strB = NULL;
19823 » » » 19896
19824 xmlSchemaCustomErr(ACTXT_CAST pctxt, 19897 xmlSchemaCustomErr(ACTXT_CAST pctxt,
19825 /* TODO: error code */ 19898 /* TODO: error code */
19826 XML_SCHEMAP_COS_NONAMBIG, 19899 XML_SCHEMAP_COS_NONAMBIG,
19827 WXS_ITEM_NODE(cur), NULL, 19900 WXS_ITEM_NODE(cur), NULL,
19828 "In the content model of %s, there are multiple " 19901 "In the content model of %s, there are multiple "
19829 "element declarations for '%s' with different " 19902 "element declarations for '%s' with different "
19830 "type definitions", 19903 "type definitions",
19831 xmlSchemaGetComponentDesignation(&strA, 19904 xmlSchemaGetComponentDesignation(&strA,
19832 ctxtComponent), 19905 ctxtComponent),
19833 xmlSchemaFormatQName(&strB, 19906 xmlSchemaFormatQName(&strB,
19834 WXS_PARTICLE_TERM_AS_ELEM(cur)->targetNamespace, 19907 WXS_PARTICLE_TERM_AS_ELEM(cur)->targetNamespace,
19835 WXS_PARTICLE_TERM_AS_ELEM(cur)->name)); 19908 WXS_PARTICLE_TERM_AS_ELEM(cur)->name));
19836 FREE_AND_NULL(strA); 19909 FREE_AND_NULL(strA);
19837 FREE_AND_NULL(strB); 19910 FREE_AND_NULL(strB);
19838 return(XML_SCHEMAP_COS_NONAMBIG); 19911 return(XML_SCHEMAP_COS_NONAMBIG);
19839 } 19912 }
19840 » » }» 19913 » » }
19841 break; 19914 break;
19842 » case XML_SCHEMA_TYPE_SEQUENCE: {» » 19915 » case XML_SCHEMA_TYPE_SEQUENCE: {
19843 break; 19916 break;
19844 } 19917 }
19845 case XML_SCHEMA_TYPE_CHOICE:{ 19918 case XML_SCHEMA_TYPE_CHOICE:{
19846 /* 19919 /*
19847 xmlSchemaTreeItemPtr sub; 19920 xmlSchemaTreeItemPtr sub;
19848 » » 19921
19849 » » sub = WXS_PARTICLE_TERM(particle)->children; (xmlSchemaParticle Ptr) 19922 » » sub = WXS_PARTICLE_TERM(particle)->children; (xmlSchemaParticle Ptr)
19850 while (sub != NULL) { 19923 while (sub != NULL) {
19851 ret = xmlSchemaCheckElementDeclConsistent(pctxt, ctxtCompone nt, 19924 ret = xmlSchemaCheckElementDeclConsistent(pctxt, ctxtCompone nt,
19852 ctxtParticle, ctxtElem); 19925 ctxtParticle, ctxtElem);
19853 if (ret != 0) 19926 if (ret != 0)
19854 return(ret); 19927 return(ret);
19855 sub = sub->next; 19928 sub = sub->next;
19856 } 19929 }
19857 */ 19930 */
19858 break; 19931 break;
19859 } 19932 }
(...skipping 16 matching lines...) Expand all
19876 } 19949 }
19877 #endif 19950 #endif
19878 19951
19879 /** 19952 /**
19880 * xmlSchemaCheckElementDeclComponent 19953 * xmlSchemaCheckElementDeclComponent
19881 * @item: an schema element declaration/particle 19954 * @item: an schema element declaration/particle
19882 * @ctxt: a schema parser context 19955 * @ctxt: a schema parser context
19883 * @name: the name of the attribute 19956 * @name: the name of the attribute
19884 * 19957 *
19885 * Validates the value constraints of an element declaration. 19958 * Validates the value constraints of an element declaration.
19886 * Adds substitution group members. 19959 * Adds substitution group members.
19887 */ 19960 */
19888 static void 19961 static void
19889 xmlSchemaCheckElementDeclComponent(xmlSchemaElementPtr elemDecl, 19962 xmlSchemaCheckElementDeclComponent(xmlSchemaElementPtr elemDecl,
19890 xmlSchemaParserCtxtPtr ctxt) 19963 xmlSchemaParserCtxtPtr ctxt)
19891 { 19964 {
19892 if (elemDecl == NULL) 19965 if (elemDecl == NULL)
19893 return; 19966 return;
19894 if (elemDecl->flags & XML_SCHEMAS_ELEM_INTERNAL_CHECKED) 19967 if (elemDecl->flags & XML_SCHEMAS_ELEM_INTERNAL_CHECKED)
19895 return; 19968 return;
19896 elemDecl->flags |= XML_SCHEMAS_ELEM_INTERNAL_CHECKED; 19969 elemDecl->flags |= XML_SCHEMAS_ELEM_INTERNAL_CHECKED;
19897 if (xmlSchemaCheckElemPropsCorrect(ctxt, elemDecl) == 0) { 19970 if (xmlSchemaCheckElemPropsCorrect(ctxt, elemDecl) == 0) {
19898 /* 19971 /*
19899 * Adds substitution group members. 19972 * Adds substitution group members.
19900 */ 19973 */
19901 » xmlSchemaCheckElemSubstGroup(ctxt, elemDecl);» 19974 » xmlSchemaCheckElemSubstGroup(ctxt, elemDecl);
19902 } 19975 }
19903 } 19976 }
19904 19977
19905 /** 19978 /**
19906 * xmlSchemaResolveModelGroupParticleReferences: 19979 * xmlSchemaResolveModelGroupParticleReferences:
19907 * @particle: a particle component 19980 * @particle: a particle component
19908 * @ctxt: a parser context 19981 * @ctxt: a parser context
19909 * 19982 *
19910 * Resolves references of a model group's {particles} to 19983 * Resolves references of a model group's {particles} to
19911 * model group definitions and to element declarations. 19984 * model group definitions and to element declarations.
19912 */ 19985 */
19913 static void 19986 static void
19914 xmlSchemaResolveModelGroupParticleReferences( 19987 xmlSchemaResolveModelGroupParticleReferences(
19915 xmlSchemaParserCtxtPtr ctxt, 19988 xmlSchemaParserCtxtPtr ctxt,
19916 xmlSchemaModelGroupPtr mg) 19989 xmlSchemaModelGroupPtr mg)
19917 { 19990 {
19918 xmlSchemaParticlePtr particle = WXS_MODELGROUP_PARTICLE(mg); 19991 xmlSchemaParticlePtr particle = WXS_MODELGROUP_PARTICLE(mg);
19919 xmlSchemaQNameRefPtr ref; 19992 xmlSchemaQNameRefPtr ref;
19920 xmlSchemaBasicItemPtr refItem; 19993 xmlSchemaBasicItemPtr refItem;
19921 19994
19922 /* 19995 /*
19923 * URGENT TODO: Test this. 19996 * URGENT TODO: Test this.
19924 */ 19997 */
19925 while (particle != NULL) { 19998 while (particle != NULL) {
19926 if ((WXS_PARTICLE_TERM(particle) == NULL) || 19999 if ((WXS_PARTICLE_TERM(particle) == NULL) ||
19927 ((WXS_PARTICLE_TERM(particle))->type != 20000 ((WXS_PARTICLE_TERM(particle))->type !=
19928 XML_SCHEMA_EXTRA_QNAMEREF)) 20001 XML_SCHEMA_EXTRA_QNAMEREF))
19929 { 20002 {
19930 goto next_particle; 20003 goto next_particle;
19931 » } 20004 » }
19932 ref = WXS_QNAME_CAST WXS_PARTICLE_TERM(particle); 20005 ref = WXS_QNAME_CAST WXS_PARTICLE_TERM(particle);
19933 /* 20006 /*
19934 * Resolve the reference. 20007 * Resolve the reference.
19935 * NULL the {term} by default. 20008 * NULL the {term} by default.
19936 */ 20009 */
19937 particle->children = NULL; 20010 particle->children = NULL;
19938 20011
19939 refItem = xmlSchemaGetNamedComponent(ctxt->schema, 20012 refItem = xmlSchemaGetNamedComponent(ctxt->schema,
19940 ref->itemType, ref->name, ref->targetNamespace); 20013 ref->itemType, ref->name, ref->targetNamespace);
19941 if (refItem == NULL) { 20014 if (refItem == NULL) {
19942 xmlSchemaPResCompAttrErr(ctxt, XML_SCHEMAP_SRC_RESOLVE, 20015 xmlSchemaPResCompAttrErr(ctxt, XML_SCHEMAP_SRC_RESOLVE,
19943 NULL, WXS_ITEM_NODE(particle), "ref", ref->name, 20016 NULL, WXS_ITEM_NODE(particle), "ref", ref->name,
19944 ref->targetNamespace, ref->itemType, NULL); 20017 ref->targetNamespace, ref->itemType, NULL);
19945 /* TODO: remove the particle. */ 20018 /* TODO: remove the particle. */
19946 goto next_particle; 20019 goto next_particle;
19947 » } 20020 » }
19948 if (refItem->type == XML_SCHEMA_TYPE_GROUP) { 20021 if (refItem->type == XML_SCHEMA_TYPE_GROUP) {
19949 if (WXS_MODELGROUPDEF_MODEL(refItem) == NULL) 20022 if (WXS_MODELGROUPDEF_MODEL(refItem) == NULL)
19950 /* TODO: remove the particle. */ 20023 /* TODO: remove the particle. */
19951 goto next_particle; 20024 goto next_particle;
19952 /* 20025 /*
19953 * NOTE that we will assign the model group definition 20026 * NOTE that we will assign the model group definition
19954 * itself to the "term" of the particle. This will ease 20027 * itself to the "term" of the particle. This will ease
19955 * the check for circular model group definitions. After 20028 * the check for circular model group definitions. After
19956 * that the "term" will be assigned the model group of the 20029 * that the "term" will be assigned the model group of the
19957 * model group definition. 20030 * model group definition.
(...skipping 29 matching lines...) Expand all
19987 */ 20060 */
19988 particle->children = (xmlSchemaTreeItemPtr) refItem; 20061 particle->children = (xmlSchemaTreeItemPtr) refItem;
19989 } 20062 }
19990 next_particle: 20063 next_particle:
19991 particle = WXS_PTC_CAST particle->next; 20064 particle = WXS_PTC_CAST particle->next;
19992 } 20065 }
19993 } 20066 }
19994 20067
19995 static int 20068 static int
19996 xmlSchemaAreValuesEqual(xmlSchemaValPtr x, 20069 xmlSchemaAreValuesEqual(xmlSchemaValPtr x,
19997 » » xmlSchemaValPtr y) 20070 » » xmlSchemaValPtr y)
19998 { 20071 {
19999 xmlSchemaTypePtr tx, ty, ptx, pty; 20072 xmlSchemaTypePtr tx, ty, ptx, pty;
20000 int ret; 20073 int ret;
20001 20074
20002 while (x != NULL) { 20075 while (x != NULL) {
20003 /* Same types. */ 20076 /* Same types. */
20004 tx = xmlSchemaGetBuiltInType(xmlSchemaGetValType(x)); 20077 tx = xmlSchemaGetBuiltInType(xmlSchemaGetValType(x));
20005 ty = xmlSchemaGetBuiltInType(xmlSchemaGetValType(y)); 20078 ty = xmlSchemaGetBuiltInType(xmlSchemaGetValType(y));
20006 ptx = xmlSchemaGetPrimitiveType(tx); 20079 ptx = xmlSchemaGetPrimitiveType(tx);
20007 pty = xmlSchemaGetPrimitiveType(ty); 20080 pty = xmlSchemaGetPrimitiveType(ty);
20008 /* 20081 /*
20009 » * (1) if a datatype T' is ·derived· by ·restriction· from an 20082 » * (1) if a datatype T' is �derived� by �restriction� from an
20010 » * atomic datatype T then the ·value space· of T' is a subset of 20083 » * atomic datatype T then the �value space� of T' is a subset of
20011 » * the ·value space· of T. */ 20084 » * the �value space� of T. */
20012 /* 20085 /*
20013 » * (2) if datatypes T' and T'' are ·derived· by ·restriction· 20086 » * (2) if datatypes T' and T'' are �derived� by �restriction�
20014 » * from a common atomic ancestor T then the ·value space·s of T' 20087 » * from a common atomic ancestor T then the �value space�s of T'
20015 * and T'' may overlap. 20088 * and T'' may overlap.
20016 */ 20089 */
20017 if (ptx != pty) 20090 if (ptx != pty)
20018 return(0); 20091 return(0);
20019 /* 20092 /*
20020 * We assume computed values to be normalized, so do a fast 20093 * We assume computed values to be normalized, so do a fast
20021 * string comparison for string based types. 20094 * string comparison for string based types.
20022 */ 20095 */
20023 if ((ptx->builtInType == XML_SCHEMAS_STRING) || 20096 if ((ptx->builtInType == XML_SCHEMAS_STRING) ||
20024 WXS_IS_ANY_SIMPLE_TYPE(ptx)) { 20097 WXS_IS_ANY_SIMPLE_TYPE(ptx)) {
(...skipping 10 matching lines...) Expand all
20035 if (ret != 0) 20108 if (ret != 0)
20036 return(0); 20109 return(0);
20037 } 20110 }
20038 /* 20111 /*
20039 * Lists. 20112 * Lists.
20040 */ 20113 */
20041 x = xmlSchemaValueGetNext(x); 20114 x = xmlSchemaValueGetNext(x);
20042 if (x != NULL) { 20115 if (x != NULL) {
20043 y = xmlSchemaValueGetNext(y); 20116 y = xmlSchemaValueGetNext(y);
20044 if (y == NULL) 20117 if (y == NULL)
20045 » » return (0);» 20118 » » return (0);
20046 } else if (xmlSchemaValueGetNext(y) != NULL) 20119 } else if (xmlSchemaValueGetNext(y) != NULL)
20047 return (0); 20120 return (0);
20048 else 20121 else
20049 return (1); 20122 return (1);
20050 } 20123 }
20051 return (0); 20124 return (0);
20052 } 20125 }
20053 20126
20054 /** 20127 /**
20055 * xmlSchemaResolveAttrUseReferences: 20128 * xmlSchemaResolveAttrUseReferences:
(...skipping 29 matching lines...) Expand all
20085 XML_SCHEMA_TYPE_ATTRIBUTE, NULL); 20158 XML_SCHEMA_TYPE_ATTRIBUTE, NULL);
20086 return(ctxt->err);; 20159 return(ctxt->err);;
20087 } 20160 }
20088 } 20161 }
20089 return(0); 20162 return(0);
20090 } 20163 }
20091 20164
20092 /** 20165 /**
20093 * xmlSchemaCheckAttrUsePropsCorrect: 20166 * xmlSchemaCheckAttrUsePropsCorrect:
20094 * @ctxt: a parser context 20167 * @ctxt: a parser context
20095 * @use: an attribute use 20168 * @use: an attribute use
20096 * 20169 *
20097 * Schema Component Constraint: 20170 * Schema Component Constraint:
20098 * Attribute Use Correct (au-props-correct) 20171 * Attribute Use Correct (au-props-correct)
20099 * 20172 *
20100 */ 20173 */
20101 static int 20174 static int
20102 xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt, 20175 xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt,
20103 xmlSchemaAttributeUsePtr use) 20176 xmlSchemaAttributeUsePtr use)
20104 { 20177 {
20105 if ((ctxt == NULL) || (use == NULL)) 20178 if ((ctxt == NULL) || (use == NULL))
20106 return(-1); 20179 return(-1);
20107 if ((use->defValue == NULL) || (WXS_ATTRUSE_DECL(use) == NULL) || 20180 if ((use->defValue == NULL) || (WXS_ATTRUSE_DECL(use) == NULL) ||
20108 ((WXS_ATTRUSE_DECL(use))->type != XML_SCHEMA_TYPE_ATTRIBUTE)) 20181 ((WXS_ATTRUSE_DECL(use))->type != XML_SCHEMA_TYPE_ATTRIBUTE))
20109 » return(0);» 20182 » return(0);
20110 20183
20111 /* 20184 /*
20112 * SPEC au-props-correct (1) 20185 * SPEC au-props-correct (1)
20113 * "The values of the properties of an attribute use must be as 20186 * "The values of the properties of an attribute use must be as
20114 * described in the property tableau in The Attribute Use Schema 20187 * described in the property tableau in The Attribute Use Schema
20115 * Component (§3.5.1), modulo the impact of Missing 20188 * Component (�3.5.1), modulo the impact of Missing
20116 * Sub-components (§5.3)." 20189 * Sub-components (�5.3)."
20117 */ 20190 */
20118 20191
20119 if (((WXS_ATTRUSE_DECL(use))->defValue != NULL) && 20192 if (((WXS_ATTRUSE_DECL(use))->defValue != NULL) &&
20120 ((WXS_ATTRUSE_DECL(use))->flags & XML_SCHEMAS_ATTR_FIXED) && 20193 ((WXS_ATTRUSE_DECL(use))->flags & XML_SCHEMAS_ATTR_FIXED) &&
20121 ((use->flags & XML_SCHEMA_ATTR_USE_FIXED) == 0)) 20194 ((use->flags & XML_SCHEMA_ATTR_USE_FIXED) == 0))
20122 { 20195 {
20123 xmlSchemaPCustomErr(ctxt, 20196 xmlSchemaPCustomErr(ctxt,
20124 XML_SCHEMAP_AU_PROPS_CORRECT_2, 20197 XML_SCHEMAP_AU_PROPS_CORRECT_2,
20125 WXS_BASIC_CAST use, NULL, 20198 WXS_BASIC_CAST use, NULL,
20126 "The attribute declaration has a 'fixed' value constraint " 20199 "The attribute declaration has a 'fixed' value constraint "
20127 ", thus the attribute use must also have a 'fixed' value " 20200 ", thus the attribute use must also have a 'fixed' value "
20128 "constraint", 20201 "constraint",
20129 NULL); 20202 NULL);
20130 return(ctxt->err); 20203 return(ctxt->err);
20131 } 20204 }
20132 /* 20205 /*
20133 * Compute and check the value constraint's value. 20206 * Compute and check the value constraint's value.
20134 */ 20207 */
20135 if ((use->defVal != NULL) && (WXS_ATTRUSE_TYPEDEF(use) != NULL)) { 20208 if ((use->defVal != NULL) && (WXS_ATTRUSE_TYPEDEF(use) != NULL)) {
20136 int ret; 20209 int ret;
20137 /* 20210 /*
20138 » * TODO: The spec seems to be missing a check of the 20211 » * TODO: The spec seems to be missing a check of the
20139 * value constraint of the attribute use. We will do it here. 20212 * value constraint of the attribute use. We will do it here.
20140 */ 20213 */
20141 /* 20214 /*
20142 * SPEC a-props-correct (3) 20215 * SPEC a-props-correct (3)
20143 */ 20216 */
20144 if (xmlSchemaIsDerivedFromBuiltInType( 20217 if (xmlSchemaIsDerivedFromBuiltInType(
20145 WXS_ATTRUSE_TYPEDEF(use), XML_SCHEMAS_ID)) 20218 WXS_ATTRUSE_TYPEDEF(use), XML_SCHEMAS_ID))
20146 { 20219 {
20147 xmlSchemaCustomErr(ACTXT_CAST ctxt, 20220 xmlSchemaCustomErr(ACTXT_CAST ctxt,
20148 XML_SCHEMAP_AU_PROPS_CORRECT, 20221 XML_SCHEMAP_AU_PROPS_CORRECT,
20149 NULL, WXS_BASIC_CAST use, 20222 NULL, WXS_BASIC_CAST use,
20150 "Value constraints are not allowed if the type definition " 20223 "Value constraints are not allowed if the type definition "
20151 "is or is derived from xs:ID", 20224 "is or is derived from xs:ID",
20152 NULL, NULL); 20225 NULL, NULL);
20153 return(ctxt->err); 20226 return(ctxt->err);
20154 } 20227 }
20155 » 20228
20156 ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST ctxt, 20229 ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST ctxt,
20157 use->node, WXS_ATTRUSE_TYPEDEF(use), 20230 use->node, WXS_ATTRUSE_TYPEDEF(use),
20158 use->defValue, &(use->defVal), 20231 use->defValue, &(use->defVal),
20159 1, 1, 0); 20232 1, 1, 0);
20160 if (ret != 0) { 20233 if (ret != 0) {
20161 if (ret < 0) { 20234 if (ret < 0) {
20162 PERROR_INT2("xmlSchemaCheckAttrUsePropsCorrect", 20235 PERROR_INT2("xmlSchemaCheckAttrUsePropsCorrect",
20163 "calling xmlSchemaVCheckCVCSimpleType()"); 20236 "calling xmlSchemaVCheckCVCSimpleType()");
20164 return(-1); 20237 return(-1);
20165 } 20238 }
(...skipping 30 matching lines...) Expand all
20196 } 20269 }
20197 return(0); 20270 return(0);
20198 } 20271 }
20199 20272
20200 20273
20201 20274
20202 20275
20203 /** 20276 /**
20204 * xmlSchemaResolveAttrTypeReferences: 20277 * xmlSchemaResolveAttrTypeReferences:
20205 * @item: an attribute declaration 20278 * @item: an attribute declaration
20206 * @ctxt: a parser context 20279 * @ctxt: a parser context
20207 * 20280 *
20208 * Resolves the referenced type definition component. 20281 * Resolves the referenced type definition component.
20209 */ 20282 */
20210 static int 20283 static int
20211 xmlSchemaResolveAttrTypeReferences(xmlSchemaAttributePtr item, 20284 xmlSchemaResolveAttrTypeReferences(xmlSchemaAttributePtr item,
20212 xmlSchemaParserCtxtPtr ctxt) 20285 xmlSchemaParserCtxtPtr ctxt)
20213 { 20286 {
20214 /* 20287 /*
20215 * The simple type definition corresponding to the <simpleType> element 20288 * The simple type definition corresponding to the <simpleType> element
20216 * information item in the [children], if present, otherwise the simple 20289 * information item in the [children], if present, otherwise the simple
20217 * type definition ·resolved· to by the ·actual value· of the type 20290 * type definition �resolved� to by the �actual value� of the type
20218 * [attribute], if present, otherwise the ·simple ur-type definition·. 20291 * [attribute], if present, otherwise the �simple ur-type definition�.
20219 */ 20292 */
20220 if (item->flags & XML_SCHEMAS_ATTR_INTERNAL_RESOLVED) 20293 if (item->flags & XML_SCHEMAS_ATTR_INTERNAL_RESOLVED)
20221 return(0); 20294 return(0);
20222 item->flags |= XML_SCHEMAS_ATTR_INTERNAL_RESOLVED; 20295 item->flags |= XML_SCHEMAS_ATTR_INTERNAL_RESOLVED;
20223 if (item->subtypes != NULL) 20296 if (item->subtypes != NULL)
20224 return(0); 20297 return(0);
20225 if (item->typeName != NULL) { 20298 if (item->typeName != NULL) {
20226 xmlSchemaTypePtr type; 20299 xmlSchemaTypePtr type;
20227 20300
20228 type = xmlSchemaGetType(ctxt->schema, item->typeName, 20301 type = xmlSchemaGetType(ctxt->schema, item->typeName,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
20287 NULL, WXS_BASIC_CAST idc, 20360 NULL, WXS_BASIC_CAST idc,
20288 "The keyref references a keyref", 20361 "The keyref references a keyref",
20289 NULL, NULL); 20362 NULL, NULL);
20290 idc->ref->item = NULL; 20363 idc->ref->item = NULL;
20291 return(pctxt->err); 20364 return(pctxt->err);
20292 } else { 20365 } else {
20293 if (idc->nbFields != 20366 if (idc->nbFields !=
20294 ((xmlSchemaIDCPtr) idc->ref->item)->nbFields) { 20367 ((xmlSchemaIDCPtr) idc->ref->item)->nbFields) {
20295 xmlChar *str = NULL; 20368 xmlChar *str = NULL;
20296 xmlSchemaIDCPtr refer; 20369 xmlSchemaIDCPtr refer;
20297 » » 20370
20298 refer = (xmlSchemaIDCPtr) idc->ref->item; 20371 refer = (xmlSchemaIDCPtr) idc->ref->item;
20299 /* 20372 /*
20300 * SPEC c-props-correct(2) 20373 * SPEC c-props-correct(2)
20301 * "If the {identity-constraint category} is keyref, 20374 * "If the {identity-constraint category} is keyref,
20302 * the cardinality of the {fields} must equal that of 20375 * the cardinality of the {fields} must equal that of
20303 * the {fields} of the {referenced key}. 20376 * the {fields} of the {referenced key}.
20304 */ 20377 */
20305 xmlSchemaCustomErr(ACTXT_CAST pctxt, 20378 xmlSchemaCustomErr(ACTXT_CAST pctxt,
20306 XML_SCHEMAP_C_PROPS_CORRECT, 20379 XML_SCHEMAP_C_PROPS_CORRECT,
20307 NULL, WXS_BASIC_CAST idc, 20380 NULL, WXS_BASIC_CAST idc,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
20346 20419
20347 static int 20420 static int
20348 xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt) 20421 xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt)
20349 { 20422 {
20350 int err = 0; 20423 int err = 0;
20351 xmlSchemaRedefPtr redef = WXS_CONSTRUCTOR(pctxt)->redefs; 20424 xmlSchemaRedefPtr redef = WXS_CONSTRUCTOR(pctxt)->redefs;
20352 xmlSchemaBasicItemPtr prev, item; 20425 xmlSchemaBasicItemPtr prev, item;
20353 int wasRedefined; 20426 int wasRedefined;
20354 20427
20355 if (redef == NULL) 20428 if (redef == NULL)
20356 » return(0); » 20429 » return(0);
20357 20430
20358 do { 20431 do {
20359 item = redef->item; 20432 item = redef->item;
20360 /* 20433 /*
20361 * First try to locate the redefined component in the 20434 * First try to locate the redefined component in the
20362 * schema graph starting with the redefined schema. 20435 * schema graph starting with the redefined schema.
20363 * NOTE: According to this schema bug entry: 20436 * NOTE: According to this schema bug entry:
20364 * http://lists.w3.org/Archives/Public/www-xml-schema-comments/2005OctD ec/0019.html 20437 * http://lists.w3.org/Archives/Public/www-xml-schema-comments/2005OctD ec/0019.html
20365 * it's not clear if the referenced component needs to originate 20438 * it's not clear if the referenced component needs to originate
20366 * from the <redefine>d schema _document_ or the schema; the latter 20439 * from the <redefine>d schema _document_ or the schema; the latter
20367 * would include all imported and included sub-schemas of the 20440 * would include all imported and included sub-schemas of the
20368 * <redefine>d schema. Currenlty we latter approach is used. 20441 * <redefine>d schema. Currenlty we latter approach is used.
20369 * SUPPLEMENT: It seems that the WG moves towards the latter 20442 * SUPPLEMENT: It seems that the WG moves towards the latter
20370 * approach, so we are doing it right. 20443 * approach, so we are doing it right.
20371 » * 20444 » *
20372 */ 20445 */
20373 prev = xmlSchemaFindRedefCompInGraph( 20446 prev = xmlSchemaFindRedefCompInGraph(
20374 redef->targetBucket, item->type, 20447 redef->targetBucket, item->type,
20375 redef->refName, redef->refTargetNs); 20448 redef->refName, redef->refTargetNs);
20376 if (prev == NULL) { 20449 if (prev == NULL) {
20377 xmlChar *str = NULL; 20450 xmlChar *str = NULL;
20378 xmlNodePtr node; 20451 xmlNodePtr node;
20379 20452
20380 /* 20453 /*
20381 * SPEC src-redefine: 20454 * SPEC src-redefine:
20382 » * (6.2.1) "The ·actual value· of its own name attribute plus 20455 » * (6.2.1) "The �actual value� of its own name attribute plus
20383 » * target namespace must successfully ·resolve· to a model 20456 » * target namespace must successfully �resolve� to a model
20384 * group definition in I." 20457 * group definition in I."
20385 » * (7.2.1) "The ·actual value· of its own name attribute plus 20458 » * (7.2.1) "The �actual value� of its own name attribute plus
20386 » * target namespace must successfully ·resolve· to an attribute 20459 » * target namespace must successfully �resolve� to an attribute
20387 * group definition in I." 20460 * group definition in I."
20388 20461
20389 * 20462 *
20390 * Note that, if we are redefining with the use of references 20463 * Note that, if we are redefining with the use of references
20391 * to components, the spec assumes the src-resolve to be used; 20464 * to components, the spec assumes the src-resolve to be used;
20392 * but this won't assure that we search only *inside* the 20465 * but this won't assure that we search only *inside* the
20393 * redefined schema. 20466 * redefined schema.
20394 */ 20467 */
20395 if (redef->reference) 20468 if (redef->reference)
20396 node = WXS_ITEM_NODE(redef->reference); 20469 node = WXS_ITEM_NODE(redef->reference);
20397 else 20470 else
20398 node = WXS_ITEM_NODE(item); 20471 node = WXS_ITEM_NODE(item);
20399 xmlSchemaCustomErr(ACTXT_CAST pctxt, 20472 xmlSchemaCustomErr(ACTXT_CAST pctxt,
20400 /* 20473 /*
20401 * TODO: error code. 20474 * TODO: error code.
20402 * Probably XML_SCHEMAP_SRC_RESOLVE, if this is using the 20475 * Probably XML_SCHEMAP_SRC_RESOLVE, if this is using the
20403 » » * reference kind.» » 20476 » » * reference kind.
20404 */ 20477 */
20405 XML_SCHEMAP_SRC_REDEFINE, node, NULL, 20478 XML_SCHEMAP_SRC_REDEFINE, node, NULL,
20406 "The %s '%s' to be redefined could not be found in " 20479 "The %s '%s' to be redefined could not be found in "
20407 "the redefined schema", 20480 "the redefined schema",
20408 WXS_ITEM_TYPE_NAME(item), 20481 WXS_ITEM_TYPE_NAME(item),
20409 xmlSchemaFormatQName(&str, redef->refTargetNs, 20482 xmlSchemaFormatQName(&str, redef->refTargetNs,
20410 redef->refName)); 20483 redef->refName));
20411 » FREE_AND_NULL(str);» 20484 » FREE_AND_NULL(str);
20412 err = pctxt->err; 20485 err = pctxt->err;
20413 redef = redef->next; 20486 redef = redef->next;
20414 continue; 20487 continue;
20415 } 20488 }
20416 /* 20489 /*
20417 * TODO: Obtaining and setting the redefinition state is really 20490 * TODO: Obtaining and setting the redefinition state is really
20418 * clumsy. 20491 * clumsy.
20419 */ 20492 */
20420 wasRedefined = 0; 20493 wasRedefined = 0;
20421 switch (item->type) { 20494 switch (item->type) {
20422 case XML_SCHEMA_TYPE_COMPLEX: 20495 case XML_SCHEMA_TYPE_COMPLEX:
20423 case XML_SCHEMA_TYPE_SIMPLE: 20496 case XML_SCHEMA_TYPE_SIMPLE:
20424 if ((WXS_TYPE_CAST prev)->flags & 20497 if ((WXS_TYPE_CAST prev)->flags &
20425 XML_SCHEMAS_TYPE_REDEFINED) 20498 XML_SCHEMAS_TYPE_REDEFINED)
20426 { 20499 {
20427 wasRedefined = 1; 20500 wasRedefined = 1;
20428 break; 20501 break;
20429 } 20502 }
20430 /* Mark it as redefined. */ 20503 /* Mark it as redefined. */
20431 (WXS_TYPE_CAST prev)->flags |= XML_SCHEMAS_TYPE_REDEFINED; 20504 (WXS_TYPE_CAST prev)->flags |= XML_SCHEMAS_TYPE_REDEFINED;
20432 /* 20505 /*
20433 * Assign the redefined type to the 20506 * Assign the redefined type to the
20434 * base type of the redefining type. 20507 * base type of the redefining type.
20435 * TODO: How 20508 * TODO: How
20436 */ 20509 */
20437 » » ((xmlSchemaTypePtr) item)->baseType = 20510 » » ((xmlSchemaTypePtr) item)->baseType =
20438 (xmlSchemaTypePtr) prev; 20511 (xmlSchemaTypePtr) prev;
20439 break; 20512 break;
20440 case XML_SCHEMA_TYPE_GROUP: 20513 case XML_SCHEMA_TYPE_GROUP:
20441 if ((WXS_MODEL_GROUPDEF_CAST prev)->flags & 20514 if ((WXS_MODEL_GROUPDEF_CAST prev)->flags &
20442 XML_SCHEMA_MODEL_GROUP_DEF_REDEFINED) 20515 XML_SCHEMA_MODEL_GROUP_DEF_REDEFINED)
20443 { 20516 {
20444 wasRedefined = 1; 20517 wasRedefined = 1;
20445 break; 20518 break;
20446 } 20519 }
20447 /* Mark it as redefined. */ 20520 /* Mark it as redefined. */
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
20482 * stage, i.e. when attribute group references 20555 * stage, i.e. when attribute group references
20483 * have beed expanded and simple types have 20556 * have beed expanded and simple types have
20484 * beed fixed. 20557 * beed fixed.
20485 */ 20558 */
20486 redef->target = prev; 20559 redef->target = prev;
20487 } 20560 }
20488 break; 20561 break;
20489 default: 20562 default:
20490 PERROR_INT("xmlSchemaResolveRedefReferences", 20563 PERROR_INT("xmlSchemaResolveRedefReferences",
20491 "Unexpected redefined component type"); 20564 "Unexpected redefined component type");
20492 » » return(-1);» 20565 » » return(-1);
20493 } 20566 }
20494 if (wasRedefined) { 20567 if (wasRedefined) {
20495 xmlChar *str = NULL; 20568 xmlChar *str = NULL;
20496 xmlNodePtr node; 20569 xmlNodePtr node;
20497 20570
20498 if (redef->reference) 20571 if (redef->reference)
20499 node = WXS_ITEM_NODE(redef->reference); 20572 node = WXS_ITEM_NODE(redef->reference);
20500 else 20573 else
20501 node = WXS_ITEM_NODE(redef->item); 20574 node = WXS_ITEM_NODE(redef->item);
20502 » 20575
20503 xmlSchemaCustomErr(ACTXT_CAST pctxt, 20576 xmlSchemaCustomErr(ACTXT_CAST pctxt,
20504 /* TODO: error code. */ 20577 /* TODO: error code. */
20505 XML_SCHEMAP_SRC_REDEFINE, 20578 XML_SCHEMAP_SRC_REDEFINE,
20506 node, NULL, 20579 node, NULL,
20507 "The referenced %s was already redefined. Multiple " 20580 "The referenced %s was already redefined. Multiple "
20508 "redefinition of the same component is not supported", 20581 "redefinition of the same component is not supported",
20509 xmlSchemaGetComponentDesignation(&str, prev), 20582 xmlSchemaGetComponentDesignation(&str, prev),
20510 NULL); 20583 NULL);
20511 » FREE_AND_NULL(str)» 20584 » FREE_AND_NULL(str)
20512 err = pctxt->err; 20585 err = pctxt->err;
20513 redef = redef->next; 20586 redef = redef->next;
20514 continue; 20587 continue;
20515 } 20588 }
20516 » redef = redef->next;» 20589 » redef = redef->next;
20517 } while (redef != NULL); 20590 } while (redef != NULL);
20518 20591
20519 return(err); 20592 return(err);
20520 } 20593 }
20521 20594
20522 static int 20595 static int
20523 xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt) 20596 xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt)
20524 { 20597 {
20525 int err = 0; 20598 int err = 0;
20526 xmlSchemaRedefPtr redef = WXS_CONSTRUCTOR(pctxt)->redefs; 20599 xmlSchemaRedefPtr redef = WXS_CONSTRUCTOR(pctxt)->redefs;
20527 xmlSchemaBasicItemPtr item; 20600 xmlSchemaBasicItemPtr item;
20528 20601
20529 if (redef == NULL) 20602 if (redef == NULL)
20530 » return(0); » 20603 » return(0);
20531 20604
20532 do { 20605 do {
20533 if (redef->target == NULL) { 20606 if (redef->target == NULL) {
20534 redef = redef->next; 20607 redef = redef->next;
20535 continue; 20608 continue;
20536 } 20609 }
20537 item = redef->item; 20610 item = redef->item;
20538 » » 20611
20539 switch (item->type) { 20612 switch (item->type) {
20540 case XML_SCHEMA_TYPE_SIMPLE: 20613 case XML_SCHEMA_TYPE_SIMPLE:
20541 case XML_SCHEMA_TYPE_COMPLEX: 20614 case XML_SCHEMA_TYPE_COMPLEX:
20542 /* 20615 /*
20543 * Since the spec wants the {name} of the redefined 20616 * Since the spec wants the {name} of the redefined
20544 * type to be 'absent', we'll NULL it. 20617 * type to be 'absent', we'll NULL it.
20545 */ 20618 */
20546 (WXS_TYPE_CAST redef->target)->name = NULL; 20619 (WXS_TYPE_CAST redef->target)->name = NULL;
20547 » » 20620
20548 /* 20621 /*
20549 * TODO: Seems like there's nothing more to do. The normal 20622 * TODO: Seems like there's nothing more to do. The normal
20550 * inheritance mechanism is used. But not 100% sure. 20623 * inheritance mechanism is used. But not 100% sure.
20551 */ 20624 */
20552 break; 20625 break;
20553 case XML_SCHEMA_TYPE_GROUP: 20626 case XML_SCHEMA_TYPE_GROUP:
20554 /* 20627 /*
20555 * URGENT TODO: 20628 * URGENT TODO:
20556 * SPEC src-redefine: 20629 * SPEC src-redefine:
20557 * (6.2.2) "The {model group} of the model group definition 20630 * (6.2.2) "The {model group} of the model group definition
20558 * which corresponds to it per XML Representation of Model 20631 * which corresponds to it per XML Representation of Model
20559 » » * Group Definition Schema Components (§3.7.2) must be a 20632 » » * Group Definition Schema Components (�3.7.2) must be a
20560 » » * ·valid restriction· of the {model group} of that model 20633 » » * �valid restriction� of the {model group} of that model
20561 * group definition in I, as defined in Particle Valid 20634 * group definition in I, as defined in Particle Valid
20562 » » * (Restriction) (§3.9.6)." 20635 » » * (Restriction) (�3.9.6)."
20563 */ 20636 */
20564 break; 20637 break;
20565 case XML_SCHEMA_TYPE_ATTRIBUTEGROUP: 20638 case XML_SCHEMA_TYPE_ATTRIBUTEGROUP:
20566 /* 20639 /*
20567 * SPEC src-redefine: 20640 * SPEC src-redefine:
20568 * (7.2.2) "The {attribute uses} and {attribute wildcard} of 20641 * (7.2.2) "The {attribute uses} and {attribute wildcard} of
20569 * the attribute group definition which corresponds to it 20642 * the attribute group definition which corresponds to it
20570 * per XML Representation of Attribute Group Definition Schema 20643 * per XML Representation of Attribute Group Definition Schema
20571 » » * Components (§3.6.2) must be ·valid restrictions· of the 20644 » » * Components (�3.6.2) must be �valid restrictions� of the
20572 * {attribute uses} and {attribute wildcard} of that attribute 20645 * {attribute uses} and {attribute wildcard} of that attribute
20573 * group definition in I, as defined in clause 2, clause 3 and 20646 * group definition in I, as defined in clause 2, clause 3 and
20574 * clause 4 of Derivation Valid (Restriction, Complex) 20647 * clause 4 of Derivation Valid (Restriction, Complex)
20575 » » * (§3.4.6) (where references to the base type definition are 20648 » » * (�3.4.6) (where references to the base type definition are
20576 * understood as references to the attribute group definition 20649 * understood as references to the attribute group definition
20577 * in I)." 20650 * in I)."
20578 */ 20651 */
20579 err = xmlSchemaCheckDerivationOKRestriction2to4(pctxt, 20652 err = xmlSchemaCheckDerivationOKRestriction2to4(pctxt,
20580 XML_SCHEMA_ACTION_REDEFINE, 20653 XML_SCHEMA_ACTION_REDEFINE,
20581 item, redef->target, 20654 item, redef->target,
20582 (WXS_ATTR_GROUP_CAST item)->attrUses, 20655 (WXS_ATTR_GROUP_CAST item)->attrUses,
20583 (WXS_ATTR_GROUP_CAST redef->target)->attrUses, 20656 (WXS_ATTR_GROUP_CAST redef->target)->attrUses,
20584 (WXS_ATTR_GROUP_CAST item)->attributeWildcard, 20657 (WXS_ATTR_GROUP_CAST item)->attributeWildcard,
20585 (WXS_ATTR_GROUP_CAST redef->target)->attributeWildcard); 20658 (WXS_ATTR_GROUP_CAST redef->target)->attributeWildcard);
20586 if (err == -1) 20659 if (err == -1)
20587 return(-1); 20660 return(-1);
20588 break; 20661 break;
20589 default: 20662 default:
20590 break; 20663 break;
20591 } 20664 }
20592 redef = redef->next; 20665 redef = redef->next;
20593 } while (redef != NULL); 20666 } while (redef != NULL);
20594 return(0); 20667 return(0);
20595 } 20668 }
20596 » 20669
20597 20670
20598 static int 20671 static int
20599 xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt, 20672 xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt,
20600 xmlSchemaBucketPtr bucket) 20673 xmlSchemaBucketPtr bucket)
20601 { 20674 {
20602 xmlSchemaBasicItemPtr item; 20675 xmlSchemaBasicItemPtr item;
20603 int err; 20676 int err;
20604 xmlHashTablePtr *table; 20677 xmlHashTablePtr *table;
20605 const xmlChar *name; 20678 const xmlChar *name;
20606 int i; 20679 int i;
(...skipping 13 matching lines...) Expand all
20620 * but if we do then according to: 20693 * but if we do then according to:
20621 * http://www.w3.org/Bugs/Public/show_bug.cgi?id=2224 20694 * http://www.w3.org/Bugs/Public/show_bug.cgi?id=2224
20622 * we would need, if imported directly, to import redefined 20695 * we would need, if imported directly, to import redefined
20623 * components as well to be able to catch clashing components. 20696 * components as well to be able to catch clashing components.
20624 * (I hope I'll still know what this means after some months :-() 20697 * (I hope I'll still know what this means after some months :-()
20625 */ 20698 */
20626 if (bucket == NULL) 20699 if (bucket == NULL)
20627 return(-1); 20700 return(-1);
20628 if (bucket->flags & XML_SCHEMA_BUCKET_COMPS_ADDED) 20701 if (bucket->flags & XML_SCHEMA_BUCKET_COMPS_ADDED)
20629 return(0); 20702 return(0);
20630 bucket->flags |= XML_SCHEMA_BUCKET_COMPS_ADDED; 20703 bucket->flags |= XML_SCHEMA_BUCKET_COMPS_ADDED;
20631 20704
20632 for (i = 0; i < bucket->globals->nbItems; i++) { 20705 for (i = 0; i < bucket->globals->nbItems; i++) {
20633 item = bucket->globals->items[i]; 20706 item = bucket->globals->items[i];
20634 table = NULL; 20707 table = NULL;
20635 switch (item->type) { 20708 switch (item->type) {
20636 case XML_SCHEMA_TYPE_COMPLEX: 20709 case XML_SCHEMA_TYPE_COMPLEX:
20637 case XML_SCHEMA_TYPE_SIMPLE: 20710 case XML_SCHEMA_TYPE_SIMPLE:
20638 if (WXS_REDEFINED_TYPE(item)) 20711 if (WXS_REDEFINED_TYPE(item))
20639 continue; 20712 continue;
20640 name = (WXS_TYPE_CAST item)->name; 20713 name = (WXS_TYPE_CAST item)->name;
20641 WXS_GET_GLOBAL_HASH(bucket, typeDecl) 20714 WXS_GET_GLOBAL_HASH(bucket, typeDecl)
(...skipping 20 matching lines...) Expand all
20662 break; 20735 break;
20663 case XML_SCHEMA_TYPE_IDC_KEY: 20736 case XML_SCHEMA_TYPE_IDC_KEY:
20664 case XML_SCHEMA_TYPE_IDC_UNIQUE: 20737 case XML_SCHEMA_TYPE_IDC_UNIQUE:
20665 case XML_SCHEMA_TYPE_IDC_KEYREF: 20738 case XML_SCHEMA_TYPE_IDC_KEYREF:
20666 name = (WXS_IDC_CAST item)->name; 20739 name = (WXS_IDC_CAST item)->name;
20667 WXS_GET_GLOBAL_HASH(bucket, idcDef) 20740 WXS_GET_GLOBAL_HASH(bucket, idcDef)
20668 break; 20741 break;
20669 case XML_SCHEMA_TYPE_NOTATION: 20742 case XML_SCHEMA_TYPE_NOTATION:
20670 name = ((xmlSchemaNotationPtr) item)->name; 20743 name = ((xmlSchemaNotationPtr) item)->name;
20671 WXS_GET_GLOBAL_HASH(bucket, notaDecl) 20744 WXS_GET_GLOBAL_HASH(bucket, notaDecl)
20672 » » break;» 20745 » » break;
20673 default: 20746 default:
20674 PERROR_INT("xmlSchemaAddComponents", 20747 PERROR_INT("xmlSchemaAddComponents",
20675 "Unexpected global component type"); 20748 "Unexpected global component type");
20676 » » continue; » » 20749 » » continue;
20677 » }» 20750 » }
20678 if (*table == NULL) { 20751 if (*table == NULL) {
20679 *table = xmlHashCreateDict(10, pctxt->dict); 20752 *table = xmlHashCreateDict(10, pctxt->dict);
20680 if (*table == NULL) { 20753 if (*table == NULL) {
20681 PERROR_INT("xmlSchemaAddComponents", 20754 PERROR_INT("xmlSchemaAddComponents",
20682 "failed to create a component hash table"); 20755 "failed to create a component hash table");
20683 return(-1); 20756 return(-1);
20684 } 20757 }
20685 » }» 20758 » }
20686 err = xmlHashAddEntry(*table, name, item); 20759 err = xmlHashAddEntry(*table, name, item);
20687 » if (err != 0) {» 20760 » if (err != 0) {
20688 xmlChar *str = NULL; 20761 xmlChar *str = NULL;
20689 » 20762
20690 xmlSchemaCustomErr(ACTXT_CAST pctxt, 20763 xmlSchemaCustomErr(ACTXT_CAST pctxt,
20691 XML_SCHEMAP_REDEFINED_TYPE, 20764 XML_SCHEMAP_REDEFINED_TYPE,
20692 WXS_ITEM_NODE(item), 20765 WXS_ITEM_NODE(item),
20693 WXS_BASIC_CAST item, 20766 WXS_BASIC_CAST item,
20694 "A global %s '%s' does already exist", 20767 "A global %s '%s' does already exist",
20695 WXS_ITEM_TYPE_NAME(item), 20768 WXS_ITEM_TYPE_NAME(item),
20696 xmlSchemaGetComponentQName(&str, item)); 20769 xmlSchemaGetComponentQName(&str, item));
20697 » FREE_AND_NULL(str);» 20770 » FREE_AND_NULL(str);
20698 } 20771 }
20699 } 20772 }
20700 /* 20773 /*
20701 * Process imported/included schemas. 20774 * Process imported/included schemas.
20702 */ 20775 */
20703 if (bucket->relations != NULL) { 20776 if (bucket->relations != NULL) {
20704 xmlSchemaSchemaRelationPtr rel = bucket->relations; 20777 xmlSchemaSchemaRelationPtr rel = bucket->relations;
20705 do { 20778 do {
20706 if ((rel->bucket != NULL) && 20779 if ((rel->bucket != NULL) &&
20707 ((rel->bucket->flags & XML_SCHEMA_BUCKET_COMPS_ADDED) == 0)) { 20780 ((rel->bucket->flags & XML_SCHEMA_BUCKET_COMPS_ADDED) == 0)) {
(...skipping 13 matching lines...) Expand all
20721 xmlSchemaConstructionCtxtPtr con = pctxt->constructor; 20794 xmlSchemaConstructionCtxtPtr con = pctxt->constructor;
20722 xmlSchemaTreeItemPtr item, *items; 20795 xmlSchemaTreeItemPtr item, *items;
20723 int nbItems, i, ret = 0; 20796 int nbItems, i, ret = 0;
20724 xmlSchemaBucketPtr oldbucket = con->bucket; 20797 xmlSchemaBucketPtr oldbucket = con->bucket;
20725 xmlSchemaElementPtr elemDecl; 20798 xmlSchemaElementPtr elemDecl;
20726 20799
20727 #define FIXHFAILURE if (pctxt->err == XML_SCHEMAP_INTERNAL) goto exit_failure; 20800 #define FIXHFAILURE if (pctxt->err == XML_SCHEMAP_INTERNAL) goto exit_failure;
20728 20801
20729 if ((con->pending == NULL) || 20802 if ((con->pending == NULL) ||
20730 (con->pending->nbItems == 0)) 20803 (con->pending->nbItems == 0))
20731 » return(0); 20804 » return(0);
20732 20805
20733 /* 20806 /*
20734 * Since xmlSchemaFixupComplexType() will create new particles 20807 * Since xmlSchemaFixupComplexType() will create new particles
20735 * (local components), and those particle components need a bucket 20808 * (local components), and those particle components need a bucket
20736 * on the constructor, we'll assure here that the constructor has 20809 * on the constructor, we'll assure here that the constructor has
20737 * a bucket. 20810 * a bucket.
20738 * TODO: Think about storing locals _only_ on the main bucket. 20811 * TODO: Think about storing locals _only_ on the main bucket.
20739 */ 20812 */
20740 if (con->bucket == NULL) 20813 if (con->bucket == NULL)
20741 » con->bucket = rootBucket; 20814 » con->bucket = rootBucket;
20742 20815
20743 /* TODO: 20816 /* TODO:
20744 * SPEC (src-redefine): 20817 * SPEC (src-redefine):
20745 * (6.2) "If it has no such self-reference, then all of the 20818 * (6.2) "If it has no such self-reference, then all of the
20746 * following must be true:" 20819 * following must be true:"
20747 20820
20748 * (6.2.2) The {model group} of the model group definition which 20821 * (6.2.2) The {model group} of the model group definition which
20749 * corresponds to it per XML Representation of Model Group 20822 * corresponds to it per XML Representation of Model Group
20750 * Definition Schema Components (§3.7.2) must be a ·valid 20823 * Definition Schema Components (�3.7.2) must be a �valid
20751 * restriction· of the {model group} of that model group definition 20824 * restriction� of the {model group} of that model group definition
20752 * in I, as defined in Particle Valid (Restriction) (§3.9.6)." 20825 * in I, as defined in Particle Valid (Restriction) (�3.9.6)."
20753 */ 20826 */
20754 xmlSchemaCheckSRCRedefineFirst(pctxt); 20827 xmlSchemaCheckSRCRedefineFirst(pctxt);
20755 20828
20756 /* 20829 /*
20757 * Add global components to the schemata's hash tables. 20830 * Add global components to the schemata's hash tables.
20758 */ 20831 */
20759 xmlSchemaAddComponents(pctxt, rootBucket); 20832 xmlSchemaAddComponents(pctxt, rootBucket);
20760 20833
20761 pctxt->ctxtType = NULL; 20834 pctxt->ctxtType = NULL;
20762 items = (xmlSchemaTreeItemPtr *) con->pending->items; 20835 items = (xmlSchemaTreeItemPtr *) con->pending->items;
20763 nbItems = con->pending->nbItems; 20836 nbItems = con->pending->nbItems;
20764 /* 20837 /*
20765 * Now that we have parsed *all* the schema document(s) and converted 20838 * Now that we have parsed *all* the schema document(s) and converted
20766 * them to schema components, we can resolve references, apply component 20839 * them to schema components, we can resolve references, apply component
20767 * constraints, create the FSA from the content model, etc. 20840 * constraints, create the FSA from the content model, etc.
20768 */ 20841 */
20769 /* 20842 /*
20770 * Resolve references of.. 20843 * Resolve references of..
20771 * 20844 *
20772 * 1. element declarations: 20845 * 1. element declarations:
20773 * - the type definition 20846 * - the type definition
20774 * - the substitution group affiliation 20847 * - the substitution group affiliation
20775 * 2. simple/complex types: 20848 * 2. simple/complex types:
20776 * - the base type definition 20849 * - the base type definition
20777 * - the memberTypes of union types 20850 * - the memberTypes of union types
20778 * - the itemType of list types 20851 * - the itemType of list types
20779 * 3. attributes declarations and attribute uses: 20852 * 3. attributes declarations and attribute uses:
20780 * - the type definition 20853 * - the type definition
20781 * - if an attribute use, then the attribute declaration 20854 * - if an attribute use, then the attribute declaration
20782 * 4. attribute group references: 20855 * 4. attribute group references:
20783 * - the attribute group definition 20856 * - the attribute group definition
20784 * 5. particles: 20857 * 5. particles:
20785 * - the term of the particle (e.g. a model group) 20858 * - the term of the particle (e.g. a model group)
20786 * 6. IDC key-references: 20859 * 6. IDC key-references:
20787 * - the referenced IDC 'key' or 'unique' definition 20860 * - the referenced IDC 'key' or 'unique' definition
20788 * 7. Attribute prohibitions which had a "ref" attribute. 20861 * 7. Attribute prohibitions which had a "ref" attribute.
20789 */ 20862 */
20790 for (i = 0; i < nbItems; i++) { 20863 for (i = 0; i < nbItems; i++) {
20791 item = items[i]; 20864 item = items[i];
20792 switch (item->type) { 20865 switch (item->type) {
20793 case XML_SCHEMA_TYPE_ELEMENT: 20866 case XML_SCHEMA_TYPE_ELEMENT:
20794 xmlSchemaResolveElementReferences( 20867 xmlSchemaResolveElementReferences(
20795 (xmlSchemaElementPtr) item, pctxt); 20868 (xmlSchemaElementPtr) item, pctxt);
20796 FIXHFAILURE; 20869 FIXHFAILURE;
20797 break; 20870 break;
20798 case XML_SCHEMA_TYPE_COMPLEX: 20871 case XML_SCHEMA_TYPE_COMPLEX:
20799 case XML_SCHEMA_TYPE_SIMPLE: 20872 case XML_SCHEMA_TYPE_SIMPLE:
20800 xmlSchemaResolveTypeReferences( 20873 xmlSchemaResolveTypeReferences(
20801 (xmlSchemaTypePtr) item, pctxt); 20874 (xmlSchemaTypePtr) item, pctxt);
20802 FIXHFAILURE; 20875 FIXHFAILURE;
20803 break; 20876 break;
20804 case XML_SCHEMA_TYPE_ATTRIBUTE: 20877 case XML_SCHEMA_TYPE_ATTRIBUTE:
20805 xmlSchemaResolveAttrTypeReferences( 20878 xmlSchemaResolveAttrTypeReferences(
20806 (xmlSchemaAttributePtr) item, pctxt); 20879 (xmlSchemaAttributePtr) item, pctxt);
20807 FIXHFAILURE; 20880 FIXHFAILURE;
20808 break; 20881 break;
20809 case XML_SCHEMA_TYPE_ATTRIBUTE_USE: 20882 case XML_SCHEMA_TYPE_ATTRIBUTE_USE:
20810 xmlSchemaResolveAttrUseReferences( 20883 xmlSchemaResolveAttrUseReferences(
20811 (xmlSchemaAttributeUsePtr) item, pctxt); 20884 (xmlSchemaAttributeUsePtr) item, pctxt);
20812 FIXHFAILURE; 20885 FIXHFAILURE;
20813 break; 20886 break;
20814 case XML_SCHEMA_EXTRA_QNAMEREF: 20887 case XML_SCHEMA_EXTRA_QNAMEREF:
20815 » » if ((WXS_QNAME_CAST item)->itemType == 20888 » » if ((WXS_QNAME_CAST item)->itemType ==
20816 XML_SCHEMA_TYPE_ATTRIBUTEGROUP) 20889 XML_SCHEMA_TYPE_ATTRIBUTEGROUP)
20817 { 20890 {
20818 xmlSchemaResolveAttrGroupReferences( 20891 xmlSchemaResolveAttrGroupReferences(
20819 WXS_QNAME_CAST item, pctxt); 20892 WXS_QNAME_CAST item, pctxt);
20820 } 20893 }
20821 FIXHFAILURE; 20894 FIXHFAILURE;
20822 break; 20895 break;
20823 case XML_SCHEMA_TYPE_SEQUENCE: 20896 case XML_SCHEMA_TYPE_SEQUENCE:
20824 case XML_SCHEMA_TYPE_CHOICE: 20897 case XML_SCHEMA_TYPE_CHOICE:
20825 case XML_SCHEMA_TYPE_ALL: 20898 case XML_SCHEMA_TYPE_ALL:
(...skipping 16 matching lines...) Expand all
20842 xmlSchemaResolveAttrUseProhibReferences( 20915 xmlSchemaResolveAttrUseProhibReferences(
20843 WXS_ATTR_PROHIB_CAST item, pctxt); 20916 WXS_ATTR_PROHIB_CAST item, pctxt);
20844 FIXHFAILURE; 20917 FIXHFAILURE;
20845 break; 20918 break;
20846 default: 20919 default:
20847 break; 20920 break;
20848 } 20921 }
20849 } 20922 }
20850 if (pctxt->nberrors != 0) 20923 if (pctxt->nberrors != 0)
20851 goto exit_error; 20924 goto exit_error;
20852 20925
20853 /* 20926 /*
20854 * Now that all references are resolved we 20927 * Now that all references are resolved we
20855 * can check for circularity of... 20928 * can check for circularity of...
20856 * 1. the base axis of type definitions 20929 * 1. the base axis of type definitions
20857 * 2. nested model group definitions 20930 * 2. nested model group definitions
20858 * 3. nested attribute group definitions 20931 * 3. nested attribute group definitions
20859 * TODO: check for circual substitution groups. 20932 * TODO: check for circual substitution groups.
20860 */ 20933 */
20861 for (i = 0; i < nbItems; i++) { 20934 for (i = 0; i < nbItems; i++) {
20862 item = items[i]; 20935 item = items[i];
20863 /* 20936 /*
20864 * Let's better stop on the first error here. 20937 * Let's better stop on the first error here.
20865 */ 20938 */
20866 switch (item->type) { 20939 switch (item->type) {
(...skipping 14 matching lines...) Expand all
20881 break; 20954 break;
20882 case XML_SCHEMA_TYPE_ATTRIBUTEGROUP: 20955 case XML_SCHEMA_TYPE_ATTRIBUTEGROUP:
20883 xmlSchemaCheckAttrGroupCircular( 20956 xmlSchemaCheckAttrGroupCircular(
20884 (xmlSchemaAttributeGroupPtr) item, pctxt); 20957 (xmlSchemaAttributeGroupPtr) item, pctxt);
20885 FIXHFAILURE; 20958 FIXHFAILURE;
20886 if (pctxt->nberrors != 0) 20959 if (pctxt->nberrors != 0)
20887 goto exit_error; 20960 goto exit_error;
20888 break; 20961 break;
20889 default: 20962 default:
20890 break; 20963 break;
20891 » }» 20964 » }
20892 } 20965 }
20893 if (pctxt->nberrors != 0) 20966 if (pctxt->nberrors != 0)
20894 goto exit_error; 20967 goto exit_error;
20895 /* 20968 /*
20896 * Model group definition references: 20969 * Model group definition references:
20897 * Such a reference is reflected by a particle at the component 20970 * Such a reference is reflected by a particle at the component
20898 * level. Until now the 'term' of such particles pointed 20971 * level. Until now the 'term' of such particles pointed
20899 * to the model group definition; this was done, in order to 20972 * to the model group definition; this was done, in order to
20900 * ease circularity checks. Now we need to set the 'term' of 20973 * ease circularity checks. Now we need to set the 'term' of
20901 * such particles to the model group of the model group definition. 20974 * such particles to the model group of the model group definition.
20902 */ 20975 */
20903 for (i = 0; i < nbItems; i++) { 20976 for (i = 0; i < nbItems; i++) {
20904 item = items[i]; 20977 item = items[i];
20905 switch (item->type) { 20978 switch (item->type) {
20906 case XML_SCHEMA_TYPE_SEQUENCE: 20979 case XML_SCHEMA_TYPE_SEQUENCE:
20907 » case XML_SCHEMA_TYPE_CHOICE:» 20980 » case XML_SCHEMA_TYPE_CHOICE:
20908 xmlSchemaModelGroupToModelGroupDefFixup(pctxt, 20981 xmlSchemaModelGroupToModelGroupDefFixup(pctxt,
20909 WXS_MODEL_GROUP_CAST item); 20982 WXS_MODEL_GROUP_CAST item);
20910 break; 20983 break;
20911 default: 20984 default:
20912 break; 20985 break;
20913 } 20986 }
20914 } 20987 }
20915 if (pctxt->nberrors != 0) 20988 if (pctxt->nberrors != 0)
20916 goto exit_error; 20989 goto exit_error;
20917 /* 20990 /*
(...skipping 10 matching lines...) Expand all
20928 WXS_ATTR_GROUP_CAST item); 21001 WXS_ATTR_GROUP_CAST item);
20929 FIXHFAILURE; 21002 FIXHFAILURE;
20930 } 21003 }
20931 break; 21004 break;
20932 default: 21005 default:
20933 break; 21006 break;
20934 } 21007 }
20935 } 21008 }
20936 if (pctxt->nberrors != 0) 21009 if (pctxt->nberrors != 0)
20937 goto exit_error; 21010 goto exit_error;
20938 /* 21011 /*
20939 * First compute the variety of simple types. This is needed as 21012 * First compute the variety of simple types. This is needed as
20940 * a seperate step, since otherwise we won't be able to detect 21013 * a seperate step, since otherwise we won't be able to detect
20941 * circular union types in all cases. 21014 * circular union types in all cases.
20942 */ 21015 */
20943 for (i = 0; i < nbItems; i++) { 21016 for (i = 0; i < nbItems; i++) {
20944 item = items[i]; 21017 item = items[i];
20945 switch (item->type) { 21018 switch (item->type) {
20946 case XML_SCHEMA_TYPE_SIMPLE: 21019 case XML_SCHEMA_TYPE_SIMPLE:
20947 if (WXS_IS_TYPE_NOT_FIXED_1((xmlSchemaTypePtr) item)) { 21020 if (WXS_IS_TYPE_NOT_FIXED_1((xmlSchemaTypePtr) item)) {
20948 xmlSchemaFixupSimpleTypeStageOne(pctxt, 21021 xmlSchemaFixupSimpleTypeStageOne(pctxt,
20949 (xmlSchemaTypePtr) item); 21022 (xmlSchemaTypePtr) item);
20950 FIXHFAILURE; 21023 FIXHFAILURE;
20951 } 21024 }
20952 break; 21025 break;
20953 default: 21026 default:
20954 break; 21027 break;
20955 } 21028 }
20956 } 21029 }
20957 if (pctxt->nberrors != 0) 21030 if (pctxt->nberrors != 0)
20958 goto exit_error; 21031 goto exit_error;
20959 /* 21032 /*
20960 * Detect circular union types. Note that this needs the variety to 21033 * Detect circular union types. Note that this needs the variety to
20961 * be already computed. 21034 * be already computed.
20962 */ 21035 */
20963 for (i = 0; i < nbItems; i++) { 21036 for (i = 0; i < nbItems; i++) {
20964 item = items[i]; 21037 item = items[i];
20965 switch (item->type) { 21038 switch (item->type) {
20966 case XML_SCHEMA_TYPE_SIMPLE: 21039 case XML_SCHEMA_TYPE_SIMPLE:
20967 if (((xmlSchemaTypePtr) item)->memberTypes != NULL) { 21040 if (((xmlSchemaTypePtr) item)->memberTypes != NULL) {
20968 » » xmlSchemaCheckUnionTypeDefCircular(pctxt,» 21041 » » xmlSchemaCheckUnionTypeDefCircular(pctxt,
20969 (xmlSchemaTypePtr) item); 21042 (xmlSchemaTypePtr) item);
20970 FIXHFAILURE; 21043 FIXHFAILURE;
20971 } 21044 }
20972 break; 21045 break;
20973 default: 21046 default:
20974 break; 21047 break;
20975 } 21048 }
20976 } 21049 }
20977 if (pctxt->nberrors != 0) 21050 if (pctxt->nberrors != 0)
20978 goto exit_error; 21051 goto exit_error;
20979 21052
20980 /* 21053 /*
20981 * Do the complete type fixup for simple types. 21054 * Do the complete type fixup for simple types.
20982 */ 21055 */
20983 for (i = 0; i < nbItems; i++) { 21056 for (i = 0; i < nbItems; i++) {
20984 item = items[i]; 21057 item = items[i];
20985 switch (item->type) { 21058 switch (item->type) {
20986 case XML_SCHEMA_TYPE_SIMPLE: 21059 case XML_SCHEMA_TYPE_SIMPLE:
20987 if (WXS_IS_TYPE_NOT_FIXED(WXS_TYPE_CAST item)) { 21060 if (WXS_IS_TYPE_NOT_FIXED(WXS_TYPE_CAST item)) {
20988 xmlSchemaFixupSimpleTypeStageTwo(pctxt, WXS_TYPE_CAST item); 21061 xmlSchemaFixupSimpleTypeStageTwo(pctxt, WXS_TYPE_CAST item);
20989 FIXHFAILURE; 21062 FIXHFAILURE;
20990 } 21063 }
20991 break; 21064 break;
20992 default: 21065 default:
20993 break; 21066 break;
20994 } 21067 }
20995 } 21068 }
20996 if (pctxt->nberrors != 0) 21069 if (pctxt->nberrors != 0)
20997 goto exit_error; 21070 goto exit_error;
20998 /* 21071 /*
20999 * At this point we need build and check all simple types. 21072 * At this point we need build and check all simple types.
21000 */ 21073 */
21001 /* 21074 /*
21002 * Apply contraints for attribute declarations. 21075 * Apply contraints for attribute declarations.
21003 */ 21076 */
21004 for (i = 0; i < nbItems; i++) { 21077 for (i = 0; i < nbItems; i++) {
21005 item = items[i]; 21078 item = items[i];
21006 switch (item->type) { 21079 switch (item->type) {
21007 » case XML_SCHEMA_TYPE_ATTRIBUTE:» » 21080 » case XML_SCHEMA_TYPE_ATTRIBUTE:
21008 xmlSchemaCheckAttrPropsCorrect(pctxt, WXS_ATTR_CAST item); 21081 xmlSchemaCheckAttrPropsCorrect(pctxt, WXS_ATTR_CAST item);
21009 FIXHFAILURE; 21082 FIXHFAILURE;
21010 » » break;» 21083 » » break;
21011 default: 21084 default:
21012 break; 21085 break;
21013 } 21086 }
21014 } 21087 }
21015 if (pctxt->nberrors != 0) 21088 if (pctxt->nberrors != 0)
21016 goto exit_error; 21089 goto exit_error;
21017 /* 21090 /*
21018 * Apply constraints for attribute uses. 21091 * Apply constraints for attribute uses.
21019 */ 21092 */
21020 for (i = 0; i < nbItems; i++) { 21093 for (i = 0; i < nbItems; i++) {
21021 item = items[i]; 21094 item = items[i];
21022 switch (item->type) { 21095 switch (item->type) {
21023 case XML_SCHEMA_TYPE_ATTRIBUTE_USE: 21096 case XML_SCHEMA_TYPE_ATTRIBUTE_USE:
21024 if (((xmlSchemaAttributeUsePtr)item)->defValue != NULL) { 21097 if (((xmlSchemaAttributeUsePtr)item)->defValue != NULL) {
21025 xmlSchemaCheckAttrUsePropsCorrect(pctxt, 21098 xmlSchemaCheckAttrUsePropsCorrect(pctxt,
21026 WXS_ATTR_USE_CAST item); 21099 WXS_ATTR_USE_CAST item);
21027 FIXHFAILURE; 21100 FIXHFAILURE;
21028 } 21101 }
21029 break; 21102 break;
(...skipping 26 matching lines...) Expand all
21056 goto exit_error; 21129 goto exit_error;
21057 21130
21058 /* 21131 /*
21059 * Apply constraints for redefinitions. 21132 * Apply constraints for redefinitions.
21060 */ 21133 */
21061 if (WXS_CONSTRUCTOR(pctxt)->redefs != NULL) 21134 if (WXS_CONSTRUCTOR(pctxt)->redefs != NULL)
21062 xmlSchemaCheckSRCRedefineSecond(pctxt); 21135 xmlSchemaCheckSRCRedefineSecond(pctxt);
21063 if (pctxt->nberrors != 0) 21136 if (pctxt->nberrors != 0)
21064 goto exit_error; 21137 goto exit_error;
21065 21138
21066 /* 21139 /*
21067 * Complex types are builded and checked. 21140 * Complex types are builded and checked.
21068 */ 21141 */
21069 for (i = 0; i < nbItems; i++) { 21142 for (i = 0; i < nbItems; i++) {
21070 item = con->pending->items[i]; 21143 item = con->pending->items[i];
21071 switch (item->type) { 21144 switch (item->type) {
21072 case XML_SCHEMA_TYPE_COMPLEX: 21145 case XML_SCHEMA_TYPE_COMPLEX:
21073 if (WXS_IS_TYPE_NOT_FIXED(WXS_TYPE_CAST item)) { 21146 if (WXS_IS_TYPE_NOT_FIXED(WXS_TYPE_CAST item)) {
21074 xmlSchemaFixupComplexType(pctxt, WXS_TYPE_CAST item); 21147 xmlSchemaFixupComplexType(pctxt, WXS_TYPE_CAST item);
21075 FIXHFAILURE; 21148 FIXHFAILURE;
21076 } 21149 }
21077 break; 21150 break;
21078 default: 21151 default:
21079 break; 21152 break;
21080 } 21153 }
21081 } 21154 }
21082 if (pctxt->nberrors != 0) 21155 if (pctxt->nberrors != 0)
21083 goto exit_error; 21156 goto exit_error;
21084 21157
21085 /* 21158 /*
21086 * The list could have changed, since xmlSchemaFixupComplexType() 21159 * The list could have changed, since xmlSchemaFixupComplexType()
21087 * will create particles and model groups in some cases. 21160 * will create particles and model groups in some cases.
21088 */ 21161 */
21089 items = (xmlSchemaTreeItemPtr *) con->pending->items; 21162 items = (xmlSchemaTreeItemPtr *) con->pending->items;
21090 nbItems = con->pending->nbItems; 21163 nbItems = con->pending->nbItems;
21091 21164
21092 /* 21165 /*
21093 * Apply some constraints for element declarations. 21166 * Apply some constraints for element declarations.
21094 */ 21167 */
21095 for (i = 0; i < nbItems; i++) { 21168 for (i = 0; i < nbItems; i++) {
21096 item = items[i]; 21169 item = items[i];
21097 switch (item->type) { 21170 switch (item->type) {
21098 case XML_SCHEMA_TYPE_ELEMENT: 21171 case XML_SCHEMA_TYPE_ELEMENT:
21099 elemDecl = (xmlSchemaElementPtr) item; 21172 elemDecl = (xmlSchemaElementPtr) item;
21100 » » 21173
21101 if ((elemDecl->flags & XML_SCHEMAS_ELEM_INTERNAL_CHECKED) == 0) 21174 if ((elemDecl->flags & XML_SCHEMAS_ELEM_INTERNAL_CHECKED) == 0)
21102 { 21175 {
21103 xmlSchemaCheckElementDeclComponent( 21176 xmlSchemaCheckElementDeclComponent(
21104 (xmlSchemaElementPtr) elemDecl, pctxt); 21177 (xmlSchemaElementPtr) elemDecl, pctxt);
21105 FIXHFAILURE; 21178 FIXHFAILURE;
21106 } 21179 }
21107 21180
21108 #ifdef WXS_ELEM_DECL_CONS_ENABLED 21181 #ifdef WXS_ELEM_DECL_CONS_ENABLED
21109 /* 21182 /*
21110 * Schema Component Constraint: Element Declarations Consistent 21183 * Schema Component Constraint: Element Declarations Consistent
21111 * Apply this constraint to local types of element declarations. 21184 * Apply this constraint to local types of element declarations.
21112 */ 21185 */
21113 if ((WXS_ELEM_TYPEDEF(elemDecl) != NULL) && 21186 if ((WXS_ELEM_TYPEDEF(elemDecl) != NULL) &&
21114 (WXS_IS_COMPLEX(WXS_ELEM_TYPEDEF(elemDecl))) && 21187 (WXS_IS_COMPLEX(WXS_ELEM_TYPEDEF(elemDecl))) &&
21115 (WXS_TYPE_IS_LOCAL(WXS_ELEM_TYPEDEF(elemDecl)))) 21188 (WXS_TYPE_IS_LOCAL(WXS_ELEM_TYPEDEF(elemDecl))))
21116 { 21189 {
21117 xmlSchemaCheckElementDeclConsistent(pctxt, 21190 xmlSchemaCheckElementDeclConsistent(pctxt,
21118 WXS_BASIC_CAST elemDecl, 21191 WXS_BASIC_CAST elemDecl,
21119 WXS_TYPE_PARTICLE(WXS_ELEM_TYPEDEF(elemDecl)), 21192 WXS_TYPE_PARTICLE(WXS_ELEM_TYPEDEF(elemDecl)),
21120 NULL, NULL, 0); 21193 NULL, NULL, 0);
21121 } 21194 }
21122 #endif 21195 #endif
21123 break; 21196 break;
21124 default: 21197 default:
21125 break; 21198 break;
21126 } 21199 }
21127 } 21200 }
21128 if (pctxt->nberrors != 0) 21201 if (pctxt->nberrors != 0)
21129 goto exit_error; 21202 goto exit_error;
21130 21203
21131 /* 21204 /*
21132 * Finally we can build the automaton from the content model of 21205 * Finally we can build the automaton from the content model of
21133 * complex types. 21206 * complex types.
21134 */ 21207 */
21135 21208
21136 for (i = 0; i < nbItems; i++) { 21209 for (i = 0; i < nbItems; i++) {
21137 item = items[i]; 21210 item = items[i];
21138 switch (item->type) { 21211 switch (item->type) {
21139 case XML_SCHEMA_TYPE_COMPLEX: 21212 case XML_SCHEMA_TYPE_COMPLEX:
21140 xmlSchemaBuildContentModel((xmlSchemaTypePtr) item, pctxt); 21213 xmlSchemaBuildContentModel((xmlSchemaTypePtr) item, pctxt);
21141 /* FIXHFAILURE; */ 21214 /* FIXHFAILURE; */
21142 break; 21215 break;
21143 default: 21216 default:
21144 break; 21217 break;
21145 } 21218 }
21146 } 21219 }
21147 if (pctxt->nberrors != 0) 21220 if (pctxt->nberrors != 0)
21148 goto exit_error; 21221 goto exit_error;
21149 /* 21222 /*
21150 * URGENT TODO: cos-element-consistent 21223 * URGENT TODO: cos-element-consistent
21151 */ 21224 */
21152 goto exit; 21225 goto exit;
21153 21226
21154 exit_error: 21227 exit_error:
21155 ret = pctxt->err; 21228 ret = pctxt->err;
21156 goto exit; 21229 goto exit;
21157 21230
21158 exit_failure: 21231 exit_failure:
21159 ret = -1; 21232 ret = -1;
21160 21233
21161 exit: 21234 exit:
21162 /* 21235 /*
21163 * Reset the constructor. This is needed for XSI acquisition, since 21236 * Reset the constructor. This is needed for XSI acquisition, since
21164 * those items will be processed over and over again for every XSI 21237 * those items will be processed over and over again for every XSI
21165 * if not cleared here. 21238 * if not cleared here.
21166 */ 21239 */
21167 con->bucket = oldbucket; 21240 con->bucket = oldbucket;
21168 con->pending->nbItems = 0; 21241 con->pending->nbItems = 0;
21169 if (con->substGroups != NULL) { 21242 if (con->substGroups != NULL) {
21170 xmlHashFree(con->substGroups, 21243 xmlHashFree(con->substGroups,
21171 (xmlHashDeallocator) xmlSchemaSubstGroupFree); 21244 (xmlHashDeallocator) xmlSchemaSubstGroupFree);
21172 con->substGroups = NULL; 21245 con->substGroups = NULL;
21173 } 21246 }
21174 if (con->redefs != NULL) { 21247 if (con->redefs != NULL) {
21175 xmlSchemaRedefListFree(con->redefs); 21248 xmlSchemaRedefListFree(con->redefs);
21176 con->redefs = NULL; 21249 con->redefs = NULL;
21177 } 21250 }
21178 return(ret); 21251 return(ret);
21179 } 21252 }
21180 /** 21253 /**
21181 * xmlSchemaParse: 21254 * xmlSchemaParse:
21182 * @ctxt: a schema validation context 21255 * @ctxt: a schema validation context
21183 * 21256 *
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
21226 ctxt->constructor->mainSchema = mainSchema; 21299 ctxt->constructor->mainSchema = mainSchema;
21227 /* 21300 /*
21228 * Locate and add the schema document. 21301 * Locate and add the schema document.
21229 */ 21302 */
21230 res = xmlSchemaAddSchemaDoc(ctxt, XML_SCHEMA_SCHEMA_MAIN, 21303 res = xmlSchemaAddSchemaDoc(ctxt, XML_SCHEMA_SCHEMA_MAIN,
21231 ctxt->URL, ctxt->doc, ctxt->buffer, ctxt->size, NULL, 21304 ctxt->URL, ctxt->doc, ctxt->buffer, ctxt->size, NULL,
21232 NULL, NULL, &bucket); 21305 NULL, NULL, &bucket);
21233 if (res == -1) 21306 if (res == -1)
21234 goto exit_failure; 21307 goto exit_failure;
21235 if (res != 0) 21308 if (res != 0)
21236 » goto exit; 21309 » goto exit;
21237 21310
21238 if (bucket == NULL) { 21311 if (bucket == NULL) {
21239 /* TODO: Error code, actually we failed to *locate* the schema. */ 21312 /* TODO: Error code, actually we failed to *locate* the schema. */
21240 » if (ctxt->URL) 21313 » if (ctxt->URL)
21241 xmlSchemaCustomErr(ACTXT_CAST ctxt, XML_SCHEMAP_FAILED_LOAD, 21314 xmlSchemaCustomErr(ACTXT_CAST ctxt, XML_SCHEMAP_FAILED_LOAD,
21242 NULL, NULL, 21315 NULL, NULL,
21243 "Failed to locate the main schema resource at '%s'", 21316 "Failed to locate the main schema resource at '%s'",
21244 ctxt->URL, NULL); 21317 ctxt->URL, NULL);
21245 else 21318 else
21246 xmlSchemaCustomErr(ACTXT_CAST ctxt, XML_SCHEMAP_FAILED_LOAD, 21319 xmlSchemaCustomErr(ACTXT_CAST ctxt, XML_SCHEMAP_FAILED_LOAD,
21247 NULL, NULL, 21320 NULL, NULL,
21248 "Failed to locate the main schema resource", 21321 "Failed to locate the main schema resource",
21249 NULL, NULL); 21322 NULL, NULL);
21250 goto exit; 21323 goto exit;
21251 } 21324 }
21252 /* Then do the parsing for good. */ 21325 /* Then do the parsing for good. */
21253 if (xmlSchemaParseNewDocWithContext(ctxt, mainSchema, bucket) == -1) 21326 if (xmlSchemaParseNewDocWithContext(ctxt, mainSchema, bucket) == -1)
21254 goto exit_failure; 21327 goto exit_failure;
21255 if (ctxt->nberrors != 0) 21328 if (ctxt->nberrors != 0)
21256 goto exit; 21329 goto exit;
21257 21330
21258 mainSchema->doc = bucket->doc; 21331 mainSchema->doc = bucket->doc;
21259 mainSchema->preserve = ctxt->preserve; 21332 mainSchema->preserve = ctxt->preserve;
21260 21333
21261 ctxt->schema = mainSchema; 21334 ctxt->schema = mainSchema;
21262 21335
21263 if (xmlSchemaFixupComponents(ctxt, WXS_CONSTRUCTOR(ctxt)->mainBucket) == -1) 21336 if (xmlSchemaFixupComponents(ctxt, WXS_CONSTRUCTOR(ctxt)->mainBucket) == -1)
21264 goto exit_failure; 21337 goto exit_failure;
21265 21338
21266 /* 21339 /*
21267 * TODO: This is not nice, since we cannot distinguish from the 21340 * TODO: This is not nice, since we cannot distinguish from the
21268 * result if there was an internal error or not. 21341 * result if there was an internal error or not.
21269 */ 21342 */
21270 exit: 21343 exit:
21271 if (ctxt->nberrors != 0) {» 21344 if (ctxt->nberrors != 0) {
21272 if (mainSchema) { 21345 if (mainSchema) {
21273 xmlSchemaFree(mainSchema); 21346 xmlSchemaFree(mainSchema);
21274 mainSchema = NULL; 21347 mainSchema = NULL;
21275 } 21348 }
21276 if (ctxt->constructor) { 21349 if (ctxt->constructor) {
21277 xmlSchemaConstructionCtxtFree(ctxt->constructor); 21350 xmlSchemaConstructionCtxtFree(ctxt->constructor);
21278 ctxt->constructor = NULL; 21351 ctxt->constructor = NULL;
21279 ctxt->ownsConstructor = 0; 21352 ctxt->ownsConstructor = 0;
21280 } 21353 }
21281 } 21354 }
21282 ctxt->schema = NULL; 21355 ctxt->schema = NULL;
21283 return(mainSchema); 21356 return(mainSchema);
21284 exit_failure: 21357 exit_failure:
21285 /* 21358 /*
21286 * Quite verbose, but should catch internal errors, which were 21359 * Quite verbose, but should catch internal errors, which were
21287 * not communitated. 21360 * not communitated.
21288 */ 21361 */
21289 if (mainSchema) { 21362 if (mainSchema) {
21290 xmlSchemaFree(mainSchema); 21363 xmlSchemaFree(mainSchema);
21291 mainSchema = NULL; 21364 mainSchema = NULL;
21292 } 21365 }
21293 if (ctxt->constructor) { 21366 if (ctxt->constructor) {
21294 xmlSchemaConstructionCtxtFree(ctxt->constructor); 21367 xmlSchemaConstructionCtxtFree(ctxt->constructor);
21295 ctxt->constructor = NULL; 21368 ctxt->constructor = NULL;
21296 ctxt->ownsConstructor = 0; 21369 ctxt->ownsConstructor = 0;
21297 } 21370 }
21298 PERROR_INT2("xmlSchemaParse", 21371 PERROR_INT2("xmlSchemaParse",
21299 » "An internal error occured"); 21372 » "An internal error occured");
21300 ctxt->schema = NULL; 21373 ctxt->schema = NULL;
21301 return(NULL); 21374 return(NULL);
21302 } 21375 }
21303 21376
21304 /** 21377 /**
21305 * xmlSchemaSetParserErrors: 21378 * xmlSchemaSetParserErrors:
21306 * @ctxt: a schema validation context 21379 * @ctxt: a schema validation context
21307 * @err: the error callback 21380 * @err: the error callback
21308 * @warn: the warning callback 21381 * @warn: the warning callback
21309 * @ctx: contextual data for the callbacks 21382 * @ctx: contextual data for the callbacks
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
21426 /* 21499 /*
21427 * Note that we assume a whitespace of preserve for anySimpleType. 21500 * Note that we assume a whitespace of preserve for anySimpleType.
21428 */ 21501 */
21429 if ((type->builtInType == XML_SCHEMAS_STRING) || 21502 if ((type->builtInType == XML_SCHEMAS_STRING) ||
21430 (type->builtInType == XML_SCHEMAS_ANYSIMPLETYPE)) 21503 (type->builtInType == XML_SCHEMAS_ANYSIMPLETYPE))
21431 return(XML_SCHEMA_WHITESPACE_PRESERVE); 21504 return(XML_SCHEMA_WHITESPACE_PRESERVE);
21432 else if (type->builtInType == XML_SCHEMAS_NORMSTRING) 21505 else if (type->builtInType == XML_SCHEMAS_NORMSTRING)
21433 return(XML_SCHEMA_WHITESPACE_REPLACE); 21506 return(XML_SCHEMA_WHITESPACE_REPLACE);
21434 else { 21507 else {
21435 /* 21508 /*
21436 » * For all ·atomic· datatypes other than string (and types ·derived· 21509 » * For all �atomic� datatypes other than string (and types �der ived�
21437 » * by ·restriction· from it) the value of whiteSpace is fixed to 21510 » * by �restriction� from it) the value of whiteSpace is fixed to
21438 * collapse 21511 * collapse
21439 * Note that this includes built-in list datatypes. 21512 * Note that this includes built-in list datatypes.
21440 */ 21513 */
21441 return(XML_SCHEMA_WHITESPACE_COLLAPSE); 21514 return(XML_SCHEMA_WHITESPACE_COLLAPSE);
21442 } 21515 }
21443 } else if (WXS_IS_LIST(type)) { 21516 } else if (WXS_IS_LIST(type)) {
21444 /* 21517 /*
21445 * For list types the facet "whiteSpace" is fixed to "collapse". 21518 * For list types the facet "whiteSpace" is fixed to "collapse".
21446 */ 21519 */
21447 return (XML_SCHEMA_WHITESPACE_COLLAPSE); 21520 return (XML_SCHEMA_WHITESPACE_COLLAPSE);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
21514 * Acquire the schema document. 21587 * Acquire the schema document.
21515 */ 21588 */
21516 location = xmlSchemaBuildAbsoluteURI(pctxt->dict, 21589 location = xmlSchemaBuildAbsoluteURI(pctxt->dict,
21517 location, node); 21590 location, node);
21518 /* 21591 /*
21519 * Note that we pass XML_SCHEMA_SCHEMA_IMPORT here; 21592 * Note that we pass XML_SCHEMA_SCHEMA_IMPORT here;
21520 * the process will automatically change this to 21593 * the process will automatically change this to
21521 * XML_SCHEMA_SCHEMA_MAIN if it is the first schema document. 21594 * XML_SCHEMA_SCHEMA_MAIN if it is the first schema document.
21522 */ 21595 */
21523 ret = xmlSchemaAddSchemaDoc(pctxt, XML_SCHEMA_SCHEMA_IMPORT, 21596 ret = xmlSchemaAddSchemaDoc(pctxt, XML_SCHEMA_SCHEMA_IMPORT,
21524 » location, NULL, NULL, 0, node, NULL, nsName, 21597 » location, NULL, NULL, 0, node, NULL, nsName,
21525 &bucket); 21598 &bucket);
21526 if (ret != 0) 21599 if (ret != 0)
21527 » return(ret); 21600 » return(ret);
21528 if (bucket == NULL) {» 21601 if (bucket == NULL) {
21529 /* 21602 /*
21530 * Generate a warning that the document could not be located. 21603 * Generate a warning that the document could not be located.
21531 */ 21604 */
21532 xmlSchemaCustomWarning(ACTXT_CAST vctxt, XML_SCHEMAV_MISC, 21605 xmlSchemaCustomWarning(ACTXT_CAST vctxt, XML_SCHEMAV_MISC,
21533 node, NULL, 21606 node, NULL,
21534 "The document at location '%s' could not be acquired", 21607 "The document at location '%s' could not be acquired",
21535 location, NULL, NULL); 21608 location, NULL, NULL);
21536 return(ret); 21609 return(ret);
21537 } 21610 }
21538 /* 21611 /*
21539 * The first located schema will be handled as if all other 21612 * The first located schema will be handled as if all other
21540 * schemas imported by XSI were imported by this first schema. 21613 * schemas imported by XSI were imported by this first schema.
21541 */ 21614 */
21542 if ((bucket != NULL) && 21615 if ((bucket != NULL) &&
21543 (WXS_CONSTRUCTOR(pctxt)->bucket == NULL)) 21616 (WXS_CONSTRUCTOR(pctxt)->bucket == NULL))
21544 WXS_CONSTRUCTOR(pctxt)->bucket = bucket; 21617 WXS_CONSTRUCTOR(pctxt)->bucket = bucket;
21545 /* 21618 /*
21546 * TODO: Is this handled like an import? I.e. is it not an error 21619 * TODO: Is this handled like an import? I.e. is it not an error
21547 * if the schema cannot be located? 21620 * if the schema cannot be located?
21548 */ 21621 */
21549 if ((bucket == NULL) || (! CAN_PARSE_SCHEMA(bucket))) 21622 if ((bucket == NULL) || (! CAN_PARSE_SCHEMA(bucket)))
21550 return(0); 21623 return(0);
21551 /* 21624 /*
21552 * We will reuse the parser context for every schema imported 21625 * We will reuse the parser context for every schema imported
21553 * directly via XSI. So reset the context. 21626 * directly via XSI. So reset the context.
21554 */ 21627 */
21555 pctxt->nberrors = 0; 21628 pctxt->nberrors = 0;
21556 pctxt->err = 0; 21629 pctxt->err = 0;
21557 pctxt->doc = bucket->doc; 21630 pctxt->doc = bucket->doc;
21558 21631
21559 ret = xmlSchemaParseNewDocWithContext(pctxt, schema, bucket); 21632 ret = xmlSchemaParseNewDocWithContext(pctxt, schema, bucket);
21560 if (ret == -1) { 21633 if (ret == -1) {
21561 pctxt->doc = NULL; 21634 pctxt->doc = NULL;
21562 goto exit_failure; 21635 goto exit_failure;
21563 } 21636 }
21564 /* Paranoid error channelling. */ 21637 /* Paranoid error channelling. */
21565 if ((ret == 0) && (pctxt->nberrors != 0)) 21638 if ((ret == 0) && (pctxt->nberrors != 0))
21566 » ret = pctxt->err; 21639 » ret = pctxt->err;
21567 if (pctxt->nberrors == 0) {» 21640 if (pctxt->nberrors == 0) {
21568 » /* 21641 » /*
21569 * Only bother to fixup pending components, if there was 21642 * Only bother to fixup pending components, if there was
21570 * no error yet. 21643 * no error yet.
21571 * For every XSI acquired schema (and its sub-schemata) we will 21644 * For every XSI acquired schema (and its sub-schemata) we will
21572 * fixup the components. 21645 * fixup the components.
21573 */ 21646 */
21574 xmlSchemaFixupComponents(pctxt, bucket); 21647 xmlSchemaFixupComponents(pctxt, bucket);
21575 ret = pctxt->err; 21648 ret = pctxt->err;
21576 /* 21649 /*
21577 * Not nice, but we need somehow to channel the schema parser 21650 * Not nice, but we need somehow to channel the schema parser
21578 * error to the validation context. 21651 * error to the validation context.
21579 */ 21652 */
21580 if ((ret != 0) && (vctxt->err == 0)) 21653 if ((ret != 0) && (vctxt->err == 0))
21581 vctxt->err = ret; 21654 vctxt->err = ret;
21582 vctxt->nberrors += pctxt->nberrors; 21655 vctxt->nberrors += pctxt->nberrors;
21583 } else { 21656 } else {
21584 » /* Add to validation error sum. */ 21657 » /* Add to validation error sum. */
21585 vctxt->nberrors += pctxt->nberrors; 21658 vctxt->nberrors += pctxt->nberrors;
21586 } 21659 }
21587 pctxt->doc = NULL; 21660 pctxt->doc = NULL;
21588 return(ret); 21661 return(ret);
21589 exit_failure: 21662 exit_failure:
21590 pctxt->doc = NULL; 21663 pctxt->doc = NULL;
21591 return (-1); 21664 return (-1);
21592 } 21665 }
21593 21666
21594 static xmlSchemaAttrInfoPtr 21667 static xmlSchemaAttrInfoPtr
21595 xmlSchemaGetMetaAttrInfo(xmlSchemaValidCtxtPtr vctxt,» » 21668 xmlSchemaGetMetaAttrInfo(xmlSchemaValidCtxtPtr vctxt,
21596 int metaType) 21669 int metaType)
21597 { 21670 {
21598 if (vctxt->nbAttrInfos == 0) 21671 if (vctxt->nbAttrInfos == 0)
21599 return (NULL); 21672 return (NULL);
21600 { 21673 {
21601 int i; 21674 int i;
21602 xmlSchemaAttrInfoPtr iattr; 21675 xmlSchemaAttrInfoPtr iattr;
21603 21676
21604 for (i = 0; i < vctxt->nbAttrInfos; i++) { 21677 for (i = 0; i < vctxt->nbAttrInfos; i++) {
21605 iattr = vctxt->attrInfos[i]; 21678 iattr = vctxt->attrInfos[i];
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
21675 end = cur; 21748 end = cur;
21676 while ((*end != 0) && (!(IS_BLANK_CH(*end)))) 21749 while ((*end != 0) && (!(IS_BLANK_CH(*end))))
21677 end++; 21750 end++;
21678 if (end == cur) { 21751 if (end == cur) {
21679 if (iattr->metaType == 21752 if (iattr->metaType ==
21680 XML_SCHEMA_ATTR_INFO_META_XSI_SCHEMA_LOC) 21753 XML_SCHEMA_ATTR_INFO_META_XSI_SCHEMA_LOC)
21681 { 21754 {
21682 /* 21755 /*
21683 * If using @schemaLocation then tuples are expected. 21756 * If using @schemaLocation then tuples are expected.
21684 * I.e. the namespace name *and* the document's URI. 21757 * I.e. the namespace name *and* the document's URI.
21685 » » */» » 21758 » » */
21686 xmlSchemaCustomWarning(ACTXT_CAST vctxt, XML_SCHEMAV_MISC, 21759 xmlSchemaCustomWarning(ACTXT_CAST vctxt, XML_SCHEMAV_MISC,
21687 iattr->node, NULL, 21760 iattr->node, NULL,
21688 "The value must consist of tuples: the target namespace " 21761 "The value must consist of tuples: the target namespace "
21689 "name and the document's URI", NULL, NULL, NULL); 21762 "name and the document's URI", NULL, NULL, NULL);
21690 } 21763 }
21691 break; 21764 break;
21692 } 21765 }
21693 count++; /* TODO: Don't use the schema's dict. */ 21766 count++; /* TODO: Don't use the schema's dict. */
21694 location = xmlDictLookup(vctxt->schema->dict, cur, end - cur); 21767 location = xmlDictLookup(vctxt->schema->dict, cur, end - cur);
21695 cur = end; 21768 cur = end;
21696 ret = xmlSchemaAssembleByLocation(vctxt, vctxt->schema, 21769 ret = xmlSchemaAssembleByLocation(vctxt, vctxt->schema,
21697 iattr->node, nsname, location); 21770 iattr->node, nsname, location);
21698 if (ret == -1) { 21771 if (ret == -1) {
21699 VERROR_INT("xmlSchemaAssembleByXSI", 21772 VERROR_INT("xmlSchemaAssembleByXSI",
21700 "assembling schemata"); 21773 "assembling schemata");
21701 return (-1); 21774 return (-1);
21702 } 21775 }
21703 } while (*cur != 0); 21776 } while (*cur != 0);
21704 return (ret); 21777 return (ret);
21705 } 21778 }
21706 21779
21707 static const xmlChar * 21780 static const xmlChar *
21708 xmlSchemaLookupNamespace(xmlSchemaValidCtxtPtr vctxt, 21781 xmlSchemaLookupNamespace(xmlSchemaValidCtxtPtr vctxt,
21709 const xmlChar *prefix) 21782 const xmlChar *prefix)
21710 { 21783 {
21711 if (vctxt->sax != NULL) { 21784 if (vctxt->sax != NULL) {
21712 int i, j; 21785 int i, j;
21713 xmlSchemaNodeInfoPtr inode; 21786 xmlSchemaNodeInfoPtr inode;
21714 » 21787
21715 for (i = vctxt->depth; i >= 0; i--) { 21788 for (i = vctxt->depth; i >= 0; i--) {
21716 if (vctxt->elemInfos[i]->nbNsBindings != 0) { 21789 if (vctxt->elemInfos[i]->nbNsBindings != 0) {
21717 inode = vctxt->elemInfos[i]; 21790 inode = vctxt->elemInfos[i];
21718 for (j = 0; j < inode->nbNsBindings * 2; j += 2) { 21791 for (j = 0; j < inode->nbNsBindings * 2; j += 2) {
21719 if (((prefix == NULL) && 21792 if (((prefix == NULL) &&
21720 (inode->nsBindings[j] == NULL)) || 21793 (inode->nsBindings[j] == NULL)) ||
21721 ((prefix != NULL) && xmlStrEqual(prefix, 21794 ((prefix != NULL) && xmlStrEqual(prefix,
21722 inode->nsBindings[j]))) { 21795 inode->nsBindings[j]))) {
21723 21796
21724 /* 21797 /*
21725 * Note that the namespace bindings are already 21798 * Note that the namespace bindings are already
21726 * in a string dict. 21799 * in a string dict.
21727 */ 21800 */
21728 » » » return (inode->nsBindings[j+1]);» » » 21801 » » » return (inode->nsBindings[j+1]);
21729 } 21802 }
21730 } 21803 }
21731 } 21804 }
21732 } 21805 }
21733 return (NULL); 21806 return (NULL);
21734 #ifdef LIBXML_WRITER_ENABLED 21807 #ifdef LIBXML_READER_ENABLED
21735 } else if (vctxt->reader != NULL) { 21808 } else if (vctxt->reader != NULL) {
21736 xmlChar *nsName; 21809 xmlChar *nsName;
21737 » 21810
21738 nsName = xmlTextReaderLookupNamespace(vctxt->reader, prefix); 21811 nsName = xmlTextReaderLookupNamespace(vctxt->reader, prefix);
21739 if (nsName != NULL) { 21812 if (nsName != NULL) {
21740 const xmlChar *ret; 21813 const xmlChar *ret;
21741 21814
21742 ret = xmlDictLookup(vctxt->dict, nsName, -1); 21815 ret = xmlDictLookup(vctxt->dict, nsName, -1);
21743 xmlFree(nsName); 21816 xmlFree(nsName);
21744 return (ret); 21817 return (ret);
21745 } else 21818 } else
21746 return (NULL); 21819 return (NULL);
21747 #endif 21820 #endif
(...skipping 11 matching lines...) Expand all
21759 if (ns != NULL) 21832 if (ns != NULL)
21760 return (ns->href); 21833 return (ns->href);
21761 return (NULL); 21834 return (NULL);
21762 } 21835 }
21763 } 21836 }
21764 21837
21765 /* 21838 /*
21766 * This one works on the schema of the validation context. 21839 * This one works on the schema of the validation context.
21767 */ 21840 */
21768 static int 21841 static int
21769 xmlSchemaValidateNotation(xmlSchemaValidCtxtPtr vctxt, »» » 21842 xmlSchemaValidateNotation(xmlSchemaValidCtxtPtr vctxt,
21770 xmlSchemaPtr schema, 21843 xmlSchemaPtr schema,
21771 xmlNodePtr node, 21844 xmlNodePtr node,
21772 const xmlChar *value, 21845 const xmlChar *value,
21773 xmlSchemaValPtr *val, 21846 xmlSchemaValPtr *val,
21774 int valNeeded) 21847 int valNeeded)
21775 { 21848 {
21776 int ret; 21849 int ret;
21777 21850
21778 if (vctxt && (vctxt->schema == NULL)) { 21851 if (vctxt && (vctxt->schema == NULL)) {
21779 VERROR_INT("xmlSchemaValidateNotation", 21852 VERROR_INT("xmlSchemaValidateNotation",
21780 "a schema is needed on the validation context"); 21853 "a schema is needed on the validation context");
21781 return (-1); 21854 return (-1);
21782 } 21855 }
21783 ret = xmlValidateQName(value, 1); 21856 ret = xmlValidateQName(value, 1);
21784 if (ret != 0) 21857 if (ret != 0)
21785 return (ret); 21858 return (ret);
21786 { 21859 {
21787 xmlChar *localName = NULL; 21860 xmlChar *localName = NULL;
21788 xmlChar *prefix = NULL; 21861 xmlChar *prefix = NULL;
21789 21862
21790 localName = xmlSplitQName2(value, &prefix); 21863 localName = xmlSplitQName2(value, &prefix);
21791 if (prefix != NULL) { 21864 if (prefix != NULL) {
21792 const xmlChar *nsName = NULL; 21865 const xmlChar *nsName = NULL;
21793 21866
21794 » if (vctxt != NULL) 21867 » if (vctxt != NULL)
21795 nsName = xmlSchemaLookupNamespace(vctxt, BAD_CAST prefix); 21868 nsName = xmlSchemaLookupNamespace(vctxt, BAD_CAST prefix);
21796 else if (node != NULL) { 21869 else if (node != NULL) {
21797 xmlNsPtr ns = xmlSearchNs(node->doc, node, prefix); 21870 xmlNsPtr ns = xmlSearchNs(node->doc, node, prefix);
21798 if (ns != NULL) 21871 if (ns != NULL)
21799 nsName = ns->href; 21872 nsName = ns->href;
21800 } else { 21873 } else {
21801 xmlFree(prefix); 21874 xmlFree(prefix);
21802 xmlFree(localName); 21875 xmlFree(localName);
21803 return (1); 21876 return (1);
21804 } 21877 }
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
22136 * 22209 *
22137 * Frees an IDC binding. Note that the node table-items 22210 * Frees an IDC binding. Note that the node table-items
22138 * are not freed. 22211 * are not freed.
22139 */ 22212 */
22140 static void 22213 static void
22141 xmlSchemaIDCFreeBinding(xmlSchemaPSVIIDCBindingPtr bind) 22214 xmlSchemaIDCFreeBinding(xmlSchemaPSVIIDCBindingPtr bind)
22142 { 22215 {
22143 if (bind->nodeTable != NULL) 22216 if (bind->nodeTable != NULL)
22144 xmlFree(bind->nodeTable); 22217 xmlFree(bind->nodeTable);
22145 if (bind->dupls != NULL) 22218 if (bind->dupls != NULL)
22146 » xmlSchemaItemListFree(bind->dupls);» 22219 » xmlSchemaItemListFree(bind->dupls);
22147 xmlFree(bind); 22220 xmlFree(bind);
22148 } 22221 }
22149 22222
22150 /** 22223 /**
22151 * xmlSchemaIDCFreeIDCTable: 22224 * xmlSchemaIDCFreeIDCTable:
22152 * @bind: the first IDC binding in the list 22225 * @bind: the first IDC binding in the list
22153 * 22226 *
22154 * Frees an IDC table, i.e. all the IDC bindings in the list. 22227 * Frees an IDC table, i.e. all the IDC bindings in the list.
22155 */ 22228 */
22156 static void 22229 static void
(...skipping 14 matching lines...) Expand all
22171 * 22244 *
22172 * Frees a list of IDC matchers. 22245 * Frees a list of IDC matchers.
22173 */ 22246 */
22174 static void 22247 static void
22175 xmlSchemaIDCFreeMatcherList(xmlSchemaIDCMatcherPtr matcher) 22248 xmlSchemaIDCFreeMatcherList(xmlSchemaIDCMatcherPtr matcher)
22176 { 22249 {
22177 xmlSchemaIDCMatcherPtr next; 22250 xmlSchemaIDCMatcherPtr next;
22178 22251
22179 while (matcher != NULL) { 22252 while (matcher != NULL) {
22180 next = matcher->next; 22253 next = matcher->next;
22181 » if (matcher->keySeqs != NULL) {» 22254 » if (matcher->keySeqs != NULL) {
22182 int i; 22255 int i;
22183 for (i = 0; i < matcher->sizeKeySeqs; i++) 22256 for (i = 0; i < matcher->sizeKeySeqs; i++)
22184 if (matcher->keySeqs[i] != NULL) 22257 if (matcher->keySeqs[i] != NULL)
22185 xmlFree(matcher->keySeqs[i]); 22258 xmlFree(matcher->keySeqs[i]);
22186 » xmlFree(matcher->keySeqs);» 22259 » xmlFree(matcher->keySeqs);
22187 } 22260 }
22188 if (matcher->targets != NULL) { 22261 if (matcher->targets != NULL) {
22189 if (matcher->idcType == XML_SCHEMA_TYPE_IDC_KEYREF) { 22262 if (matcher->idcType == XML_SCHEMA_TYPE_IDC_KEYREF) {
22190 int i; 22263 int i;
22191 xmlSchemaPSVIIDCNodePtr idcNode; 22264 xmlSchemaPSVIIDCNodePtr idcNode;
22192 /* 22265 /*
22193 * Node-table items for keyrefs are not stored globally 22266 * Node-table items for keyrefs are not stored globally
22194 * to the validation context, since they are not bubbled. 22267 * to the validation context, since they are not bubbled.
22195 * We need to free them here. 22268 * We need to free them here.
22196 */ 22269 */
(...skipping 19 matching lines...) Expand all
22216 * Caches a list of IDC matchers for reuse. 22289 * Caches a list of IDC matchers for reuse.
22217 */ 22290 */
22218 static void 22291 static void
22219 xmlSchemaIDCReleaseMatcherList(xmlSchemaValidCtxtPtr vctxt, 22292 xmlSchemaIDCReleaseMatcherList(xmlSchemaValidCtxtPtr vctxt,
22220 xmlSchemaIDCMatcherPtr matcher) 22293 xmlSchemaIDCMatcherPtr matcher)
22221 { 22294 {
22222 xmlSchemaIDCMatcherPtr next; 22295 xmlSchemaIDCMatcherPtr next;
22223 22296
22224 while (matcher != NULL) { 22297 while (matcher != NULL) {
22225 next = matcher->next; 22298 next = matcher->next;
22226 » if (matcher->keySeqs != NULL) {» 22299 » if (matcher->keySeqs != NULL) {
22227 int i; 22300 int i;
22228 /* 22301 /*
22229 * Don't free the array, but only the content. 22302 * Don't free the array, but only the content.
22230 */ 22303 */
22231 for (i = 0; i < matcher->sizeKeySeqs; i++) 22304 for (i = 0; i < matcher->sizeKeySeqs; i++)
22232 if (matcher->keySeqs[i] != NULL) { 22305 if (matcher->keySeqs[i] != NULL) {
22233 xmlFree(matcher->keySeqs[i]); 22306 xmlFree(matcher->keySeqs[i]);
22234 matcher->keySeqs[i] = NULL; 22307 matcher->keySeqs[i] = NULL;
22235 } 22308 }
22236 } 22309 }
22237 if (matcher->targets) { 22310 if (matcher->targets) {
22238 if (matcher->idcType == XML_SCHEMA_TYPE_IDC_KEYREF) { 22311 if (matcher->idcType == XML_SCHEMA_TYPE_IDC_KEYREF) {
22239 int i; 22312 int i;
22240 xmlSchemaPSVIIDCNodePtr idcNode; 22313 xmlSchemaPSVIIDCNodePtr idcNode;
22241 /* 22314 /*
22242 * Node-table items for keyrefs are not stored globally 22315 * Node-table items for keyrefs are not stored globally
22243 * to the validation context, since they are not bubbled. 22316 * to the validation context, since they are not bubbled.
22244 * We need to free them here. 22317 * We need to free them here.
22245 */ 22318 */
22246 for (i = 0; i < matcher->targets->nbItems; i++) { 22319 for (i = 0; i < matcher->targets->nbItems; i++) {
22247 idcNode = 22320 idcNode =
22248 (xmlSchemaPSVIIDCNodePtr) matcher->targets->items[i]; 22321 (xmlSchemaPSVIIDCNodePtr) matcher->targets->items[i];
22249 xmlFree(idcNode->keys); 22322 xmlFree(idcNode->keys);
22250 xmlFree(idcNode); 22323 xmlFree(idcNode);
22251 } 22324 }
22252 } 22325 }
22253 xmlSchemaItemListFree(matcher->targets); 22326 xmlSchemaItemListFree(matcher->targets);
22254 matcher->targets = NULL; 22327 matcher->targets = NULL;
22255 » }» 22328 » }
22256 matcher->next = NULL; 22329 matcher->next = NULL;
22257 /* 22330 /*
22258 * Cache the matcher. 22331 * Cache the matcher.
22259 */ 22332 */
22260 if (vctxt->idcMatcherCache != NULL) 22333 if (vctxt->idcMatcherCache != NULL)
22261 matcher->nextCached = vctxt->idcMatcherCache; 22334 matcher->nextCached = vctxt->idcMatcherCache;
22262 vctxt->idcMatcherCache = matcher; 22335 vctxt->idcMatcherCache = matcher;
22263 22336
22264 matcher = next; 22337 matcher = next;
22265 } 22338 }
(...skipping 21 matching lines...) Expand all
22287 { 22360 {
22288 xmlSchemaIDCStateObjPtr sto; 22361 xmlSchemaIDCStateObjPtr sto;
22289 22362
22290 /* 22363 /*
22291 * Reuse the state objects from the pool. 22364 * Reuse the state objects from the pool.
22292 */ 22365 */
22293 if (vctxt->xpathStatePool != NULL) { 22366 if (vctxt->xpathStatePool != NULL) {
22294 sto = vctxt->xpathStatePool; 22367 sto = vctxt->xpathStatePool;
22295 vctxt->xpathStatePool = sto->next; 22368 vctxt->xpathStatePool = sto->next;
22296 sto->next = NULL; 22369 sto->next = NULL;
22297 } else {» 22370 } else {
22298 /* 22371 /*
22299 * Create a new state object. 22372 * Create a new state object.
22300 */ 22373 */
22301 sto = (xmlSchemaIDCStateObjPtr) xmlMalloc(sizeof(xmlSchemaIDCStateObj)); 22374 sto = (xmlSchemaIDCStateObjPtr) xmlMalloc(sizeof(xmlSchemaIDCStateObj));
22302 if (sto == NULL) { 22375 if (sto == NULL) {
22303 xmlSchemaVErrMemory(NULL, 22376 xmlSchemaVErrMemory(NULL,
22304 "allocating an IDC state object", NULL); 22377 "allocating an IDC state object", NULL);
22305 return (-1); 22378 return (-1);
22306 } 22379 }
22307 memset(sto, 0, sizeof(xmlSchemaIDCStateObj)); 22380 memset(sto, 0, sizeof(xmlSchemaIDCStateObj));
22308 }» 22381 }
22309 /* 22382 /*
22310 * Add to global list. 22383 * Add to global list.
22311 */» 22384 */
22312 if (vctxt->xpathStates != NULL) 22385 if (vctxt->xpathStates != NULL)
22313 sto->next = vctxt->xpathStates; 22386 sto->next = vctxt->xpathStates;
22314 vctxt->xpathStates = sto; 22387 vctxt->xpathStates = sto;
22315 22388
22316 /* 22389 /*
22317 * Free the old xpath validation context. 22390 * Free the old xpath validation context.
22318 */ 22391 */
22319 if (sto->xpathCtxt != NULL) 22392 if (sto->xpathCtxt != NULL)
22320 xmlFreeStreamCtxt((xmlStreamCtxtPtr) sto->xpathCtxt); 22393 xmlFreeStreamCtxt((xmlStreamCtxtPtr) sto->xpathCtxt);
22321 22394
22322 /* 22395 /*
22323 * Create a new XPath (pattern) validation context. 22396 * Create a new XPath (pattern) validation context.
22324 */ 22397 */
22325 sto->xpathCtxt = (void *) xmlPatternGetStreamCtxt( 22398 sto->xpathCtxt = (void *) xmlPatternGetStreamCtxt(
22326 (xmlPatternPtr) sel->xpathComp); 22399 (xmlPatternPtr) sel->xpathComp);
22327 if (sto->xpathCtxt == NULL) { 22400 if (sto->xpathCtxt == NULL) {
22328 VERROR_INT("xmlSchemaIDCAddStateObject", 22401 VERROR_INT("xmlSchemaIDCAddStateObject",
22329 "failed to create an XPath validation context"); 22402 "failed to create an XPath validation context");
22330 return (-1); 22403 return (-1);
22331 } 22404 }
22332 sto->type = type; 22405 sto->type = type;
22333 sto->depth = vctxt->depth; 22406 sto->depth = vctxt->depth;
22334 sto->matcher = matcher; 22407 sto->matcher = matcher;
22335 sto->sel = sel; 22408 sto->sel = sel;
22336 sto->nbHistory = 0; 22409 sto->nbHistory = 0;
22337 22410
22338 #ifdef DEBUG_IDC 22411 #ifdef DEBUG_IDC
22339 xmlGenericError(xmlGenericErrorContext, "IDC: STO push '%s'\n", 22412 xmlGenericError(xmlGenericErrorContext, "IDC: STO push '%s'\n",
22340 sto->sel->xpath); 22413 sto->sel->xpath);
22341 #endif 22414 #endif
22342 return (0); 22415 return (0);
22343 } 22416 }
22344 22417
22345 /** 22418 /**
22346 * xmlSchemaXPathEvaluate: 22419 * xmlSchemaXPathEvaluate:
22347 * @vctxt: the WXS validation context 22420 * @vctxt: the WXS validation context
22348 * @nodeType: the nodeType of the current node 22421 * @nodeType: the nodeType of the current node
22349 * 22422 *
22350 * Evaluates all active XPath state objects. 22423 * Evaluates all active XPath state objects.
22351 * 22424 *
22352 * Returns the number of IC "field" state objects which resolved to 22425 * Returns the number of IC "field" state objects which resolved to
22353 * this node, 0 if none resolved and -1 on internal errors. 22426 * this node, 0 if none resolved and -1 on internal errors.
22354 */ 22427 */
22355 static int 22428 static int
22356 xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt, 22429 xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
22357 xmlElementType nodeType) 22430 xmlElementType nodeType)
22358 { 22431 {
22359 xmlSchemaIDCStateObjPtr sto, head = NULL, first; 22432 xmlSchemaIDCStateObjPtr sto, head = NULL, first;
22360 int res, resolved = 0, depth = vctxt->depth; 22433 int res, resolved = 0, depth = vctxt->depth;
22361 22434
22362 if (vctxt->xpathStates == NULL) 22435 if (vctxt->xpathStates == NULL)
22363 return (0); 22436 return (0);
22364 22437
22365 if (nodeType == XML_ATTRIBUTE_NODE) 22438 if (nodeType == XML_ATTRIBUTE_NODE)
22366 depth++; 22439 depth++;
22367 #ifdef DEBUG_IDC 22440 #ifdef DEBUG_IDC
22368 { 22441 {
22369 xmlChar *str = NULL; 22442 xmlChar *str = NULL;
22370 » xmlGenericError(xmlGenericErrorContext, 22443 » xmlGenericError(xmlGenericErrorContext,
22371 » "IDC: EVAL on %s, depth %d, type %d\n",» 22444 » "IDC: EVAL on %s, depth %d, type %d\n",
22372 xmlSchemaFormatQName(&str, vctxt->inode->nsName, 22445 xmlSchemaFormatQName(&str, vctxt->inode->nsName,
22373 vctxt->inode->localName), depth, nodeType); 22446 vctxt->inode->localName), depth, nodeType);
22374 FREE_AND_NULL(str) 22447 FREE_AND_NULL(str)
22375 } 22448 }
22376 #endif 22449 #endif
22377 /* 22450 /*
22378 * Process all active XPath state objects. 22451 * Process all active XPath state objects.
22379 */ 22452 */
22380 first = vctxt->xpathStates; 22453 first = vctxt->xpathStates;
22381 sto = first; 22454 sto = first;
22382 while (sto != head) { 22455 while (sto != head) {
22383 #ifdef DEBUG_IDC 22456 #ifdef DEBUG_IDC
22384 if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) 22457 if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR)
22385 » xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] selector '%s' \n", 22458 » xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] selector '%s' \n",
22386 sto->matcher->aidc->def->name, sto->sel->xpath); 22459 sto->matcher->aidc->def->name, sto->sel->xpath);
22387 else 22460 else
22388 » xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] field '%s'\n" , 22461 » xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] field '%s'\n" ,
22389 sto->matcher->aidc->def->name, sto->sel->xpath); 22462 sto->matcher->aidc->def->name, sto->sel->xpath);
22390 #endif 22463 #endif
22391 if (nodeType == XML_ELEMENT_NODE) 22464 if (nodeType == XML_ELEMENT_NODE)
22392 res = xmlStreamPush((xmlStreamCtxtPtr) sto->xpathCtxt, 22465 res = xmlStreamPush((xmlStreamCtxtPtr) sto->xpathCtxt,
22393 vctxt->inode->localName, vctxt->inode->nsName); 22466 vctxt->inode->localName, vctxt->inode->nsName);
22394 else 22467 else
22395 res = xmlStreamPushAttr((xmlStreamCtxtPtr) sto->xpathCtxt, 22468 res = xmlStreamPushAttr((xmlStreamCtxtPtr) sto->xpathCtxt,
22396 vctxt->inode->localName, vctxt->inode->nsName); 22469 vctxt->inode->localName, vctxt->inode->nsName);
22397 22470
22398 if (res == -1) { 22471 if (res == -1) {
22399 VERROR_INT("xmlSchemaXPathEvaluate", 22472 VERROR_INT("xmlSchemaXPathEvaluate",
22400 "calling xmlStreamPush()"); 22473 "calling xmlStreamPush()");
22401 return (-1); 22474 return (-1);
22402 } 22475 }
22403 if (res == 0) 22476 if (res == 0)
22404 goto next_sto; 22477 goto next_sto;
22405 /* 22478 /*
22406 * Full match. 22479 * Full match.
22407 */ 22480 */
22408 #ifdef DEBUG_IDC 22481 #ifdef DEBUG_IDC
22409 xmlGenericError(xmlGenericErrorContext, "IDC: " 22482 xmlGenericError(xmlGenericErrorContext, "IDC: "
22410 "MATCH\n"); 22483 "MATCH\n");
22411 #endif 22484 #endif
22412 /* 22485 /*
22413 * Register a match in the state object history. 22486 * Register a match in the state object history.
22414 */ 22487 */
22415 if (sto->history == NULL) { 22488 if (sto->history == NULL) {
22416 sto->history = (int *) xmlMalloc(5 * sizeof(int)); 22489 sto->history = (int *) xmlMalloc(5 * sizeof(int));
22417 if (sto->history == NULL) { 22490 if (sto->history == NULL) {
22418 » » xmlSchemaVErrMemory(NULL, 22491 » » xmlSchemaVErrMemory(NULL,
22419 "allocating the state object history", NULL); 22492 "allocating the state object history", NULL);
22420 return(-1); 22493 return(-1);
22421 } 22494 }
22422 sto->sizeHistory = 5; 22495 sto->sizeHistory = 5;
22423 } else if (sto->sizeHistory <= sto->nbHistory) { 22496 } else if (sto->sizeHistory <= sto->nbHistory) {
22424 sto->sizeHistory *= 2; 22497 sto->sizeHistory *= 2;
22425 sto->history = (int *) xmlRealloc(sto->history, 22498 sto->history = (int *) xmlRealloc(sto->history,
22426 sto->sizeHistory * sizeof(int)); 22499 sto->sizeHistory * sizeof(int));
22427 if (sto->history == NULL) { 22500 if (sto->history == NULL) {
22428 » » xmlSchemaVErrMemory(NULL, 22501 » » xmlSchemaVErrMemory(NULL,
22429 "re-allocating the state object history", NULL); 22502 "re-allocating the state object history", NULL);
22430 return(-1); 22503 return(-1);
22431 } 22504 }
22432 » }» » 22505 » }
22433 sto->history[sto->nbHistory++] = depth; 22506 sto->history[sto->nbHistory++] = depth;
22434 22507
22435 #ifdef DEBUG_IDC 22508 #ifdef DEBUG_IDC
22436 xmlGenericError(xmlGenericErrorContext, "IDC: push match '%d'\n", 22509 xmlGenericError(xmlGenericErrorContext, "IDC: push match '%d'\n",
22437 vctxt->depth); 22510 vctxt->depth);
22438 #endif 22511 #endif
22439 22512
22440 if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) { 22513 if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) {
22441 xmlSchemaIDCSelectPtr sel; 22514 xmlSchemaIDCSelectPtr sel;
22442 /* 22515 /*
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
22491 xmlChar **buf, 22564 xmlChar **buf,
22492 xmlSchemaPSVIIDCKeyPtr *seq, 22565 xmlSchemaPSVIIDCKeyPtr *seq,
22493 int count) 22566 int count)
22494 { 22567 {
22495 int i, res; 22568 int i, res;
22496 xmlChar *value = NULL; 22569 xmlChar *value = NULL;
22497 22570
22498 *buf = xmlStrdup(BAD_CAST "["); 22571 *buf = xmlStrdup(BAD_CAST "[");
22499 for (i = 0; i < count; i++) { 22572 for (i = 0; i < count; i++) {
22500 *buf = xmlStrcat(*buf, BAD_CAST "'"); 22573 *buf = xmlStrcat(*buf, BAD_CAST "'");
22501 » res = xmlSchemaGetCanonValueWhtspExt(seq[i]->val, 22574 » res = xmlSchemaGetCanonValueWhtspExt(seq[i]->val,
22502 xmlSchemaGetWhiteSpaceFacetValue(seq[i]->type), 22575 xmlSchemaGetWhiteSpaceFacetValue(seq[i]->type),
22503 &value); 22576 &value);
22504 if (res == 0) 22577 if (res == 0)
22505 *buf = xmlStrcat(*buf, BAD_CAST value); 22578 *buf = xmlStrcat(*buf, BAD_CAST value);
22506 else { 22579 else {
22507 VERROR_INT("xmlSchemaFormatIDCKeySequence", 22580 VERROR_INT("xmlSchemaFormatIDCKeySequence",
22508 "failed to compute a canonical value"); 22581 "failed to compute a canonical value");
22509 *buf = xmlStrcat(*buf, BAD_CAST "???"); 22582 *buf = xmlStrcat(*buf, BAD_CAST "???");
22510 } 22583 }
22511 if (i < count -1) 22584 if (i < count -1)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
22549 } 22622 }
22550 22623
22551 /** 22624 /**
22552 * xmlSchemaXPathProcessHistory: 22625 * xmlSchemaXPathProcessHistory:
22553 * @vctxt: the WXS validation context 22626 * @vctxt: the WXS validation context
22554 * @type: the simple/complex type of the current node if any at all 22627 * @type: the simple/complex type of the current node if any at all
22555 * @val: the precompiled value 22628 * @val: the precompiled value
22556 * 22629 *
22557 * Processes and pops the history items of the IDC state objects. 22630 * Processes and pops the history items of the IDC state objects.
22558 * IDC key-sequences are validated/created on IDC bindings. 22631 * IDC key-sequences are validated/created on IDC bindings.
22559 * 22632 *
22560 * Returns 0 on success and -1 on internal errors. 22633 * Returns 0 on success and -1 on internal errors.
22561 */ 22634 */
22562 static int 22635 static int
22563 xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt, 22636 xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
22564 int depth) 22637 int depth)
22565 { 22638 {
22566 xmlSchemaIDCStateObjPtr sto, nextsto; 22639 xmlSchemaIDCStateObjPtr sto, nextsto;
22567 int res, matchDepth; 22640 int res, matchDepth;
22568 xmlSchemaPSVIIDCKeyPtr key = NULL; 22641 xmlSchemaPSVIIDCKeyPtr key = NULL;
22569 xmlSchemaTypePtr type = vctxt->inode->typeDef, simpleType = NULL; 22642 xmlSchemaTypePtr type = vctxt->inode->typeDef, simpleType = NULL;
22570 22643
22571 if (vctxt->xpathStates == NULL) 22644 if (vctxt->xpathStates == NULL)
22572 return (0); 22645 return (0);
22573 sto = vctxt->xpathStates; 22646 sto = vctxt->xpathStates;
22574 22647
22575 #ifdef DEBUG_IDC 22648 #ifdef DEBUG_IDC
22576 { 22649 {
22577 xmlChar *str = NULL; 22650 xmlChar *str = NULL;
22578 » xmlGenericError(xmlGenericErrorContext, 22651 » xmlGenericError(xmlGenericErrorContext,
22579 "IDC: BACK on %s, depth %d\n", 22652 "IDC: BACK on %s, depth %d\n",
22580 xmlSchemaFormatQName(&str, vctxt->inode->nsName, 22653 xmlSchemaFormatQName(&str, vctxt->inode->nsName,
22581 vctxt->inode->localName), vctxt->depth); 22654 vctxt->inode->localName), vctxt->depth);
22582 FREE_AND_NULL(str) 22655 FREE_AND_NULL(str)
22583 } 22656 }
22584 #endif 22657 #endif
22585 /* 22658 /*
22586 * Evaluate the state objects. 22659 * Evaluate the state objects.
22587 */ 22660 */
22588 while (sto != NULL) { 22661 while (sto != NULL) {
22589 res = xmlStreamPop((xmlStreamCtxtPtr) sto->xpathCtxt); 22662 res = xmlStreamPop((xmlStreamCtxtPtr) sto->xpathCtxt);
22590 if (res == -1) { 22663 if (res == -1) {
22591 VERROR_INT("xmlSchemaXPathProcessHistory", 22664 VERROR_INT("xmlSchemaXPathProcessHistory",
22592 "calling xmlStreamPop()"); 22665 "calling xmlStreamPop()");
22593 return (-1); 22666 return (-1);
22594 } 22667 }
22595 #ifdef DEBUG_IDC 22668 #ifdef DEBUG_IDC
22596 xmlGenericError(xmlGenericErrorContext, "IDC: stream pop '%s'\n", 22669 xmlGenericError(xmlGenericErrorContext, "IDC: stream pop '%s'\n",
22597 sto->sel->xpath); 22670 sto->sel->xpath);
22598 #endif 22671 #endif
22599 if (sto->nbHistory == 0) 22672 if (sto->nbHistory == 0)
22600 goto deregister_check; 22673 goto deregister_check;
22601 22674
22602 matchDepth = sto->history[sto->nbHistory -1]; 22675 matchDepth = sto->history[sto->nbHistory -1];
22603 22676
22604 /* 22677 /*
22605 * Only matches at the current depth are of interest. 22678 * Only matches at the current depth are of interest.
22606 */ 22679 */
22607 if (matchDepth != depth) { 22680 if (matchDepth != depth) {
22608 sto = sto->next; 22681 sto = sto->next;
22609 continue; 22682 continue;
22610 » }» 22683 » }
22611 if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_FIELD) { 22684 if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_FIELD) {
22612 /* 22685 /*
22613 * NOTE: According to 22686 * NOTE: According to
22614 * http://www.w3.org/Bugs/Public/show_bug.cgi?id=2198 22687 * http://www.w3.org/Bugs/Public/show_bug.cgi?id=2198
22615 * ... the simple-content of complex types is also allowed. 22688 * ... the simple-content of complex types is also allowed.
22616 */ 22689 */
22617 » 22690
22618 if (WXS_IS_COMPLEX(type)) { 22691 if (WXS_IS_COMPLEX(type)) {
22619 if (WXS_HAS_SIMPLE_CONTENT(type)) { 22692 if (WXS_HAS_SIMPLE_CONTENT(type)) {
22620 /* 22693 /*
22621 * Sanity check for complex types with simple content. 22694 * Sanity check for complex types with simple content.
22622 */ 22695 */
22623 simpleType = type->contentTypeDef; 22696 simpleType = type->contentTypeDef;
22624 if (simpleType == NULL) { 22697 if (simpleType == NULL) {
22625 VERROR_INT("xmlSchemaXPathProcessHistory", 22698 VERROR_INT("xmlSchemaXPathProcessHistory",
22626 "field resolves to a CT with simple content " 22699 "field resolves to a CT with simple content "
22627 "but the CT is missing the ST definition"); 22700 "but the CT is missing the ST definition");
22628 return (-1); 22701 return (-1);
22629 } 22702 }
22630 } else 22703 } else
22631 simpleType = NULL; 22704 simpleType = NULL;
22632 » } else 22705 » } else
22633 simpleType = type; 22706 simpleType = type;
22634 if (simpleType == NULL) { 22707 if (simpleType == NULL) {
22635 xmlChar *str = NULL; 22708 xmlChar *str = NULL;
22636 » 22709
22637 /* 22710 /*
22638 * Not qualified if the field resolves to a node of non 22711 * Not qualified if the field resolves to a node of non
22639 * simple type. 22712 * simple type.
22640 » » */» 22713 » » */
22641 xmlSchemaCustomErr(ACTXT_CAST vctxt, 22714 xmlSchemaCustomErr(ACTXT_CAST vctxt,
22642 » » XML_SCHEMAV_CVC_IDC, NULL,» » 22715 » » XML_SCHEMAV_CVC_IDC, NULL,
22643 WXS_BASIC_CAST sto->matcher->aidc->def, 22716 WXS_BASIC_CAST sto->matcher->aidc->def,
22644 "The XPath '%s' of a field of %s does evaluate to a node of " 22717 "The XPath '%s' of a field of %s does evaluate to a node of "
22645 "non-simple type", 22718 "non-simple type",
22646 sto->sel->xpath, 22719 sto->sel->xpath,
22647 xmlSchemaGetIDCDesignation(&str, sto->matcher->aidc->def)); 22720 xmlSchemaGetIDCDesignation(&str, sto->matcher->aidc->def));
22648 FREE_AND_NULL(str); 22721 FREE_AND_NULL(str);
22649 sto->nbHistory--; 22722 sto->nbHistory--;
22650 goto deregister_check; 22723 goto deregister_check;
22651 } 22724 }
22652 » 22725
22653 if ((key == NULL) && (vctxt->inode->val == NULL)) { 22726 if ((key == NULL) && (vctxt->inode->val == NULL)) {
22654 /* 22727 /*
22655 * Failed to provide the normalized value; maybe 22728 * Failed to provide the normalized value; maybe
22656 * the value was invalid. 22729 * the value was invalid.
22657 */ 22730 */
22658 VERROR(XML_SCHEMAV_CVC_IDC, 22731 VERROR(XML_SCHEMAV_CVC_IDC,
22659 WXS_BASIC_CAST sto->matcher->aidc->def, 22732 WXS_BASIC_CAST sto->matcher->aidc->def,
22660 "Warning: No precomputed value available, the value " 22733 "Warning: No precomputed value available, the value "
22661 "was either invalid or something strange happend"); 22734 "was either invalid or something strange happend");
22662 sto->nbHistory--; 22735 sto->nbHistory--;
22663 goto deregister_check; 22736 goto deregister_check;
22664 } else { 22737 } else {
22665 xmlSchemaIDCMatcherPtr matcher = sto->matcher; 22738 xmlSchemaIDCMatcherPtr matcher = sto->matcher;
22666 xmlSchemaPSVIIDCKeyPtr *keySeq; 22739 xmlSchemaPSVIIDCKeyPtr *keySeq;
22667 int pos, idx; 22740 int pos, idx;
22668 » » 22741
22669 /* 22742 /*
22670 * The key will be anchored on the matcher's list of 22743 * The key will be anchored on the matcher's list of
22671 * key-sequences. The position in this list is determined 22744 * key-sequences. The position in this list is determined
22672 * by the target node's depth relative to the matcher's 22745 * by the target node's depth relative to the matcher's
22673 * depth of creation (i.e. the depth of the scope element). 22746 * depth of creation (i.e. the depth of the scope element).
22674 » » * 22747 » » *
22675 * Element Depth Pos List-entries 22748 * Element Depth Pos List-entries
22676 * <scope> 0 NULL 22749 * <scope> 0 NULL
22677 * <bar> 1 NULL 22750 * <bar> 1 NULL
22678 * <target/> 2 2 target 22751 * <target/> 2 2 target
22679 * <bar> 22752 * <bar>
22680 * </scope> 22753 * </scope>
22681 * 22754 *
22682 * The size of the list is only dependant on the depth of 22755 * The size of the list is only dependant on the depth of
22683 * the tree. 22756 * the tree.
22684 * An entry will be NULLed in selector_leave, i.e. when 22757 * An entry will be NULLed in selector_leave, i.e. when
22685 » » * we hit the target's 22758 » » * we hit the target's
22686 » » */» » 22759 » » */
22687 pos = sto->depth - matcher->depth; 22760 pos = sto->depth - matcher->depth;
22688 idx = sto->sel->index; 22761 idx = sto->sel->index;
22689 » » 22762
22690 /* 22763 /*
22691 * Create/grow the array of key-sequences. 22764 * Create/grow the array of key-sequences.
22692 */ 22765 */
22693 if (matcher->keySeqs == NULL) { 22766 if (matcher->keySeqs == NULL) {
22694 » » if (pos > 9) 22767 » » if (pos > 9)
22695 matcher->sizeKeySeqs = pos * 2; 22768 matcher->sizeKeySeqs = pos * 2;
22696 else 22769 else
22697 matcher->sizeKeySeqs = 10; 22770 matcher->sizeKeySeqs = 10;
22698 » » matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **) 22771 » » matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **)
22699 xmlMalloc(matcher->sizeKeySeqs * 22772 xmlMalloc(matcher->sizeKeySeqs *
22700 » » » sizeof(xmlSchemaPSVIIDCKeyPtr *));» » » 22773 » » » sizeof(xmlSchemaPSVIIDCKeyPtr *));
22701 » » if (matcher->keySeqs == NULL) {» » 22774 » » if (matcher->keySeqs == NULL) {
22702 xmlSchemaVErrMemory(NULL, 22775 xmlSchemaVErrMemory(NULL,
22703 "allocating an array of key-sequences", 22776 "allocating an array of key-sequences",
22704 NULL); 22777 NULL);
22705 return(-1); 22778 return(-1);
22706 } 22779 }
22707 memset(matcher->keySeqs, 0, 22780 memset(matcher->keySeqs, 0,
22708 matcher->sizeKeySeqs * 22781 matcher->sizeKeySeqs *
22709 sizeof(xmlSchemaPSVIIDCKeyPtr *)); 22782 sizeof(xmlSchemaPSVIIDCKeyPtr *));
22710 » » } else if (pos >= matcher->sizeKeySeqs) {» 22783 » » } else if (pos >= matcher->sizeKeySeqs) {
22711 int i = matcher->sizeKeySeqs; 22784 int i = matcher->sizeKeySeqs;
22712 » » 22785
22713 matcher->sizeKeySeqs *= 2; 22786 matcher->sizeKeySeqs *= 2;
22714 matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **) 22787 matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **)
22715 xmlRealloc(matcher->keySeqs, 22788 xmlRealloc(matcher->keySeqs,
22716 matcher->sizeKeySeqs * 22789 matcher->sizeKeySeqs *
22717 sizeof(xmlSchemaPSVIIDCKeyPtr *)); 22790 sizeof(xmlSchemaPSVIIDCKeyPtr *));
22718 if (matcher->keySeqs == NULL) { 22791 if (matcher->keySeqs == NULL) {
22719 xmlSchemaVErrMemory(NULL, 22792 xmlSchemaVErrMemory(NULL,
22720 "reallocating an array of key-sequences", 22793 "reallocating an array of key-sequences",
22721 NULL); 22794 NULL);
22722 return (-1); 22795 return (-1);
22723 } 22796 }
22724 /* 22797 /*
22725 * The array needs to be NULLed. 22798 * The array needs to be NULLed.
22726 * TODO: Use memset? 22799 * TODO: Use memset?
22727 */ 22800 */
22728 » » for (; i < matcher->sizeKeySeqs; i++) 22801 » » for (; i < matcher->sizeKeySeqs; i++)
22729 » » » matcher->keySeqs[i] = NULL;» » » 22802 » » » matcher->keySeqs[i] = NULL;
22730 } 22803 }
22731 » » 22804
22732 /* 22805 /*
22733 * Get/create the key-sequence. 22806 * Get/create the key-sequence.
22734 */ 22807 */
22735 » » keySeq = matcher->keySeqs[pos];»» 22808 » » keySeq = matcher->keySeqs[pos];
22736 » » if (keySeq == NULL) {» 22809 » » if (keySeq == NULL) {
22737 goto create_sequence; 22810 goto create_sequence;
22738 } else if (keySeq[idx] != NULL) { 22811 } else if (keySeq[idx] != NULL) {
22739 xmlChar *str = NULL; 22812 xmlChar *str = NULL;
22740 /* 22813 /*
22741 * cvc-identity-constraint: 22814 * cvc-identity-constraint:
22742 » » * 3 For each node in the ·target node set· all 22815 » » * 3 For each node in the �target node set� all
22743 * of the {fields}, with that node as the context 22816 * of the {fields}, with that node as the context
22744 * node, evaluate to either an empty node-set or 22817 * node, evaluate to either an empty node-set or
22745 * a node-set with exactly one member, which must 22818 * a node-set with exactly one member, which must
22746 * have a simple type. 22819 * have a simple type.
22747 » » * 22820 » » *
22748 * The key was already set; report an error. 22821 * The key was already set; report an error.
22749 */ 22822 */
22750 » » xmlSchemaCustomErr(ACTXT_CAST vctxt, 22823 » » xmlSchemaCustomErr(ACTXT_CAST vctxt,
22751 XML_SCHEMAV_CVC_IDC, NULL, 22824 XML_SCHEMAV_CVC_IDC, NULL,
22752 WXS_BASIC_CAST matcher->aidc->def, 22825 WXS_BASIC_CAST matcher->aidc->def,
22753 "The XPath '%s' of a field of %s evaluates to a " 22826 "The XPath '%s' of a field of %s evaluates to a "
22754 "node-set with more than one member", 22827 "node-set with more than one member",
22755 sto->sel->xpath, 22828 sto->sel->xpath,
22756 xmlSchemaGetIDCDesignation(&str, matcher->aidc->def)); 22829 xmlSchemaGetIDCDesignation(&str, matcher->aidc->def));
22757 FREE_AND_NULL(str); 22830 FREE_AND_NULL(str);
22758 sto->nbHistory--; 22831 sto->nbHistory--;
22759 goto deregister_check; 22832 goto deregister_check;
22760 } else 22833 } else
22761 » » goto create_key;» » 22834 » » goto create_key;
22762 » » 22835
22763 create_sequence: 22836 create_sequence:
22764 /* 22837 /*
22765 * Create a key-sequence. 22838 * Create a key-sequence.
22766 */ 22839 */
22767 keySeq = (xmlSchemaPSVIIDCKeyPtr *) xmlMalloc( 22840 keySeq = (xmlSchemaPSVIIDCKeyPtr *) xmlMalloc(
22768 » » matcher->aidc->def->nbFields * 22841 » » matcher->aidc->def->nbFields *
22769 sizeof(xmlSchemaPSVIIDCKeyPtr)); 22842 sizeof(xmlSchemaPSVIIDCKeyPtr));
22770 if (keySeq == NULL) { 22843 if (keySeq == NULL) {
22771 » » xmlSchemaVErrMemory(NULL, 22844 » » xmlSchemaVErrMemory(NULL,
22772 "allocating an IDC key-sequence", NULL); 22845 "allocating an IDC key-sequence", NULL);
22773 » » return(-1);»» » 22846 » » return(-1);
22774 » » }» 22847 » » }
22775 » » memset(keySeq, 0, matcher->aidc->def->nbFields * 22848 » » memset(keySeq, 0, matcher->aidc->def->nbFields *
22776 sizeof(xmlSchemaPSVIIDCKeyPtr)); 22849 sizeof(xmlSchemaPSVIIDCKeyPtr));
22777 matcher->keySeqs[pos] = keySeq; 22850 matcher->keySeqs[pos] = keySeq;
22778 create_key: 22851 create_key:
22779 /* 22852 /*
22780 * Create a key once per node only. 22853 * Create a key once per node only.
22781 » » */ 22854 » » */
22782 if (key == NULL) { 22855 if (key == NULL) {
22783 key = (xmlSchemaPSVIIDCKeyPtr) xmlMalloc( 22856 key = (xmlSchemaPSVIIDCKeyPtr) xmlMalloc(
22784 sizeof(xmlSchemaPSVIIDCKey)); 22857 sizeof(xmlSchemaPSVIIDCKey));
22785 if (key == NULL) { 22858 if (key == NULL) {
22786 xmlSchemaVErrMemory(NULL, 22859 xmlSchemaVErrMemory(NULL,
22787 "allocating a IDC key", NULL); 22860 "allocating a IDC key", NULL);
22788 xmlFree(keySeq); 22861 xmlFree(keySeq);
22789 matcher->keySeqs[pos] = NULL; 22862 matcher->keySeqs[pos] = NULL;
22790 » » » return(-1);» » » 22863 » » » return(-1);
22791 } 22864 }
22792 /* 22865 /*
22793 * Consume the compiled value. 22866 * Consume the compiled value.
22794 */ 22867 */
22795 key->type = simpleType; 22868 key->type = simpleType;
22796 key->val = vctxt->inode->val; 22869 key->val = vctxt->inode->val;
22797 vctxt->inode->val = NULL; 22870 vctxt->inode->val = NULL;
22798 /* 22871 /*
22799 * Store the key in a global list. 22872 * Store the key in a global list.
22800 */ 22873 */
22801 if (xmlSchemaIDCStoreKey(vctxt, key) == -1) { 22874 if (xmlSchemaIDCStoreKey(vctxt, key) == -1) {
22802 xmlSchemaIDCFreeKey(key); 22875 xmlSchemaIDCFreeKey(key);
22803 return (-1); 22876 return (-1);
22804 } 22877 }
22805 } 22878 }
22806 » » keySeq[idx] = key;» » 22879 » » keySeq[idx] = key;
22807 } 22880 }
22808 } else if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) { 22881 } else if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) {
22809 » » 22882
22810 xmlSchemaPSVIIDCKeyPtr **keySeq = NULL; 22883 xmlSchemaPSVIIDCKeyPtr **keySeq = NULL;
22811 /* xmlSchemaPSVIIDCBindingPtr bind; */ 22884 /* xmlSchemaPSVIIDCBindingPtr bind; */
22812 xmlSchemaPSVIIDCNodePtr ntItem; 22885 xmlSchemaPSVIIDCNodePtr ntItem;
22813 xmlSchemaIDCMatcherPtr matcher; 22886 xmlSchemaIDCMatcherPtr matcher;
22814 xmlSchemaIDCPtr idc; 22887 xmlSchemaIDCPtr idc;
22815 xmlSchemaItemListPtr targets; 22888 xmlSchemaItemListPtr targets;
22816 int pos, i, j, nbKeys; 22889 int pos, i, j, nbKeys;
22817 /* 22890 /*
22818 * Here we have the following scenario: 22891 * Here we have the following scenario:
22819 * An IDC 'selector' state object resolved to a target node, 22892 * An IDC 'selector' state object resolved to a target node,
22820 » * during the time this target node was in the 22893 » * during the time this target node was in the
22821 » * ancestor-or-self axis, the 'field' state object(s) looked 22894 » * ancestor-or-self axis, the 'field' state object(s) looked
22822 » * out for matching nodes to create a key-sequence for this 22895 » * out for matching nodes to create a key-sequence for this
22823 * target node. Now we are back to this target node and need 22896 * target node. Now we are back to this target node and need
22824 » * to put the key-sequence, together with the target node 22897 » * to put the key-sequence, together with the target node
22825 » * itself, into the node-table of the corresponding IDC 22898 » * itself, into the node-table of the corresponding IDC
22826 * binding. 22899 * binding.
22827 */ 22900 */
22828 matcher = sto->matcher; 22901 matcher = sto->matcher;
22829 idc = matcher->aidc->def; 22902 idc = matcher->aidc->def;
22830 nbKeys = idc->nbFields; 22903 nbKeys = idc->nbFields;
22831 » pos = depth - matcher->depth;» » 22904 » pos = depth - matcher->depth;
22832 /* 22905 /*
22833 * Check if the matcher has any key-sequences at all, plus 22906 * Check if the matcher has any key-sequences at all, plus
22834 * if it has a key-sequence for the current target node. 22907 * if it has a key-sequence for the current target node.
22835 » */» » 22908 » */
22836 if ((matcher->keySeqs == NULL) || 22909 if ((matcher->keySeqs == NULL) ||
22837 (matcher->sizeKeySeqs <= pos)) { 22910 (matcher->sizeKeySeqs <= pos)) {
22838 if (idc->type == XML_SCHEMA_TYPE_IDC_KEY) 22911 if (idc->type == XML_SCHEMA_TYPE_IDC_KEY)
22839 goto selector_key_error; 22912 goto selector_key_error;
22840 else 22913 else
22841 goto selector_leave; 22914 goto selector_leave;
22842 } 22915 }
22843 » 22916
22844 » keySeq = &(matcher->keySeqs[pos]);» » 22917 » keySeq = &(matcher->keySeqs[pos]);
22845 if (*keySeq == NULL) { 22918 if (*keySeq == NULL) {
22846 if (idc->type == XML_SCHEMA_TYPE_IDC_KEY) 22919 if (idc->type == XML_SCHEMA_TYPE_IDC_KEY)
22847 goto selector_key_error; 22920 goto selector_key_error;
22848 else 22921 else
22849 goto selector_leave; 22922 goto selector_leave;
22850 } 22923 }
22851 » 22924
22852 for (i = 0; i < nbKeys; i++) { 22925 for (i = 0; i < nbKeys; i++) {
22853 if ((*keySeq)[i] == NULL) { 22926 if ((*keySeq)[i] == NULL) {
22854 /* 22927 /*
22855 * Not qualified, if not all fields did resolve. 22928 * Not qualified, if not all fields did resolve.
22856 */ 22929 */
22857 if (idc->type == XML_SCHEMA_TYPE_IDC_KEY) { 22930 if (idc->type == XML_SCHEMA_TYPE_IDC_KEY) {
22858 /* 22931 /*
22859 * All fields of a "key" IDC must resolve. 22932 * All fields of a "key" IDC must resolve.
22860 */ 22933 */
22861 goto selector_key_error; 22934 goto selector_key_error;
22862 » » }» » 22935 » » }
22863 goto selector_leave; 22936 goto selector_leave;
22864 } 22937 }
22865 } 22938 }
22866 /* 22939 /*
22867 * All fields did resolve. 22940 * All fields did resolve.
22868 */ 22941 */
22869 » 22942
22870 /* 22943 /*
22871 * 4.1 If the {identity-constraint category} is unique(/key), 22944 * 4.1 If the {identity-constraint category} is unique(/key),
22872 » * then no two members of the ·qualified node set· have 22945 » * then no two members of the �qualified node set� have
22873 » * ·key-sequences· whose members are pairwise equal, as 22946 » * �key-sequences� whose members are pairwise equal, as
22874 * defined by Equal in [XML Schemas: Datatypes]. 22947 * defined by Equal in [XML Schemas: Datatypes].
22875 * 22948 *
22876 * Get the IDC binding from the matcher and check for 22949 * Get the IDC binding from the matcher and check for
22877 * duplicate key-sequences. 22950 * duplicate key-sequences.
22878 */ 22951 */
22879 #if 0 22952 #if 0
22880 bind = xmlSchemaIDCAcquireBinding(vctxt, matcher); 22953 bind = xmlSchemaIDCAcquireBinding(vctxt, matcher);
22881 #endif 22954 #endif
22882 targets = xmlSchemaIDCAcquireTargetList(vctxt, matcher); 22955 targets = xmlSchemaIDCAcquireTargetList(vctxt, matcher);
22883 » if ((idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) && 22956 » if ((idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) &&
22884 (targets->nbItems != 0)) { 22957 (targets->nbItems != 0)) {
22885 xmlSchemaPSVIIDCKeyPtr ckey, bkey, *bkeySeq; 22958 xmlSchemaPSVIIDCKeyPtr ckey, bkey, *bkeySeq;
22886 » » 22959
22887 i = 0; 22960 i = 0;
22888 res = 0; 22961 res = 0;
22889 /* 22962 /*
22890 * Compare the key-sequences, key by key. 22963 * Compare the key-sequences, key by key.
22891 */ 22964 */
22892 do { 22965 do {
22893 bkeySeq = 22966 bkeySeq =
22894 ((xmlSchemaPSVIIDCNodePtr) targets->items[i])->keys; 22967 ((xmlSchemaPSVIIDCNodePtr) targets->items[i])->keys;
22895 for (j = 0; j < nbKeys; j++) { 22968 for (j = 0; j < nbKeys; j++) {
22896 ckey = (*keySeq)[j]; 22969 ckey = (*keySeq)[j];
22897 » » » bkey = bkeySeq[j];» » » » » » » 22970 » » » bkey = bkeySeq[j];
22898 res = xmlSchemaAreValuesEqual(ckey->val, bkey->val); 22971 res = xmlSchemaAreValuesEqual(ckey->val, bkey->val);
22899 if (res == -1) { 22972 if (res == -1) {
22900 return (-1); 22973 return (-1);
22901 } else if (res == 0) { 22974 } else if (res == 0) {
22902 /* 22975 /*
22903 * One of the keys differs, so the key-sequence 22976 * One of the keys differs, so the key-sequence
22904 * won't be equal; get out. 22977 * won't be equal; get out.
22905 */ 22978 */
22906 break; 22979 break;
22907 } 22980 }
22908 } 22981 }
22909 if (res == 1) { 22982 if (res == 1) {
22910 /* 22983 /*
22911 * Duplicate key-sequence found. 22984 * Duplicate key-sequence found.
22912 */ 22985 */
22913 break; 22986 break;
22914 } 22987 }
22915 i++; 22988 i++;
22916 } while (i < targets->nbItems); 22989 } while (i < targets->nbItems);
22917 if (i != targets->nbItems) { 22990 if (i != targets->nbItems) {
22918 xmlChar *str = NULL, *strB = NULL; 22991 xmlChar *str = NULL, *strB = NULL;
22919 » » /* 22992 » » /*
22920 * TODO: Try to report the key-sequence. 22993 * TODO: Try to report the key-sequence.
22921 */ 22994 */
22922 » » xmlSchemaCustomErr(ACTXT_CAST vctxt, 22995 » » xmlSchemaCustomErr(ACTXT_CAST vctxt,
22923 XML_SCHEMAV_CVC_IDC, NULL, 22996 XML_SCHEMAV_CVC_IDC, NULL,
22924 WXS_BASIC_CAST idc, 22997 WXS_BASIC_CAST idc,
22925 "Duplicate key-sequence %s in %s", 22998 "Duplicate key-sequence %s in %s",
22926 xmlSchemaFormatIDCKeySequence(vctxt, &str, 22999 xmlSchemaFormatIDCKeySequence(vctxt, &str,
22927 (*keySeq), nbKeys), 23000 (*keySeq), nbKeys),
22928 xmlSchemaGetIDCDesignation(&strB, idc)); 23001 xmlSchemaGetIDCDesignation(&strB, idc));
22929 FREE_AND_NULL(str); 23002 FREE_AND_NULL(str);
22930 FREE_AND_NULL(strB); 23003 FREE_AND_NULL(strB);
22931 goto selector_leave; 23004 goto selector_leave;
22932 } 23005 }
22933 } 23006 }
22934 /* 23007 /*
22935 * Add a node-table item to the IDC binding. 23008 * Add a node-table item to the IDC binding.
22936 */ 23009 */
22937 ntItem = (xmlSchemaPSVIIDCNodePtr) xmlMalloc( 23010 ntItem = (xmlSchemaPSVIIDCNodePtr) xmlMalloc(
22938 sizeof(xmlSchemaPSVIIDCNode)); 23011 sizeof(xmlSchemaPSVIIDCNode));
22939 if (ntItem == NULL) { 23012 if (ntItem == NULL) {
22940 » » xmlSchemaVErrMemory(NULL, 23013 » » xmlSchemaVErrMemory(NULL,
22941 "allocating an IDC node-table item", NULL); 23014 "allocating an IDC node-table item", NULL);
22942 xmlFree(*keySeq); 23015 xmlFree(*keySeq);
22943 *keySeq = NULL; 23016 *keySeq = NULL;
22944 return(-1); 23017 return(-1);
22945 » }» 23018 » }
22946 memset(ntItem, 0, sizeof(xmlSchemaPSVIIDCNode)); 23019 memset(ntItem, 0, sizeof(xmlSchemaPSVIIDCNode));
22947 » 23020
22948 » /* 23021 » /*
22949 * Store the node-table item in a global list. 23022 * Store the node-table item in a global list.
22950 */ 23023 */
22951 if (idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) { 23024 if (idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) {
22952 if (xmlSchemaIDCStoreNodeTableItem(vctxt, ntItem) == -1) { 23025 if (xmlSchemaIDCStoreNodeTableItem(vctxt, ntItem) == -1) {
22953 xmlFree(ntItem); 23026 xmlFree(ntItem);
22954 xmlFree(*keySeq); 23027 xmlFree(*keySeq);
22955 *keySeq = NULL; 23028 *keySeq = NULL;
22956 return (-1); 23029 return (-1);
22957 } 23030 }
22958 ntItem->nodeQNameID = -1; 23031 ntItem->nodeQNameID = -1;
22959 } else { 23032 } else {
22960 /* 23033 /*
22961 * Save a cached QName for this node on the IDC node, to be 23034 * Save a cached QName for this node on the IDC node, to be
22962 * able to report it, even if the node is not saved. 23035 * able to report it, even if the node is not saved.
22963 */ 23036 */
22964 ntItem->nodeQNameID = xmlSchemaVAddNodeQName(vctxt, 23037 ntItem->nodeQNameID = xmlSchemaVAddNodeQName(vctxt,
22965 vctxt->inode->localName, vctxt->inode->nsName); 23038 vctxt->inode->localName, vctxt->inode->nsName);
22966 if (ntItem->nodeQNameID == -1) { 23039 if (ntItem->nodeQNameID == -1) {
22967 xmlFree(ntItem); 23040 xmlFree(ntItem);
22968 xmlFree(*keySeq); 23041 xmlFree(*keySeq);
22969 *keySeq = NULL; 23042 *keySeq = NULL;
22970 » » return (-1);» » 23043 » » return (-1);
22971 } 23044 }
22972 } 23045 }
22973 /* 23046 /*
22974 * Init the node-table item: Save the node, position and 23047 * Init the node-table item: Save the node, position and
22975 * consume the key-sequence. 23048 * consume the key-sequence.
22976 */ 23049 */
22977 ntItem->node = vctxt->node; 23050 ntItem->node = vctxt->node;
22978 ntItem->nodeLine = vctxt->inode->nodeLine; 23051 ntItem->nodeLine = vctxt->inode->nodeLine;
22979 ntItem->keys = *keySeq; 23052 ntItem->keys = *keySeq;
22980 *keySeq = NULL; 23053 *keySeq = NULL;
22981 #if 0 23054 #if 0
22982 » if (xmlSchemaIDCAppendNodeTableItem(bind, ntItem) == -1) { 23055 » if (xmlSchemaIDCAppendNodeTableItem(bind, ntItem) == -1)
22983 #endif 23056 #endif
22984 if (xmlSchemaItemListAdd(targets, ntItem) == -1) { 23057 if (xmlSchemaItemListAdd(targets, ntItem) == -1) {
22985 if (idc->type == XML_SCHEMA_TYPE_IDC_KEYREF) { 23058 if (idc->type == XML_SCHEMA_TYPE_IDC_KEYREF) {
22986 » » /* 23059 » » /*
22987 * Free the item, since keyref items won't be 23060 * Free the item, since keyref items won't be
22988 * put on a global list. 23061 * put on a global list.
22989 */ 23062 */
22990 xmlFree(ntItem->keys); 23063 xmlFree(ntItem->keys);
22991 xmlFree(ntItem); 23064 xmlFree(ntItem);
22992 } 23065 }
22993 return (-1); 23066 return (-1);
22994 } 23067 }
22995 » 23068
22996 goto selector_leave; 23069 goto selector_leave;
22997 selector_key_error: 23070 selector_key_error:
22998 { 23071 {
22999 xmlChar *str = NULL; 23072 xmlChar *str = NULL;
23000 /* 23073 /*
23001 » » * 4.2.1 (KEY) The ·target node set· and the 23074 » » * 4.2.1 (KEY) The �target node set� and the
23002 » » * ·qualified node set· are equal, that is, every 23075 » » * �qualified node set� are equal, that is, every
23003 » » * member of the ·target node set· is also a member 23076 » » * member of the �target node set� is also a member
23004 » » * of the ·qualified node set· and vice versa. 23077 » » * of the �qualified node set� and vice versa.
23005 */ 23078 */
23006 » » xmlSchemaCustomErr(ACTXT_CAST vctxt, 23079 » » xmlSchemaCustomErr(ACTXT_CAST vctxt,
23007 XML_SCHEMAV_CVC_IDC, NULL, 23080 XML_SCHEMAV_CVC_IDC, NULL,
23008 WXS_BASIC_CAST idc, 23081 WXS_BASIC_CAST idc,
23009 "Not all fields of %s evaluate to a node", 23082 "Not all fields of %s evaluate to a node",
23010 xmlSchemaGetIDCDesignation(&str, idc), NULL); 23083 xmlSchemaGetIDCDesignation(&str, idc), NULL);
23011 FREE_AND_NULL(str); 23084 FREE_AND_NULL(str);
23012 } 23085 }
23013 selector_leave: 23086 selector_leave:
23014 /* 23087 /*
23015 * Free the key-sequence if not added to the IDC table. 23088 * Free the key-sequence if not added to the IDC table.
23016 */ 23089 */
23017 if ((keySeq != NULL) && (*keySeq != NULL)) { 23090 if ((keySeq != NULL) && (*keySeq != NULL)) {
23018 xmlFree(*keySeq); 23091 xmlFree(*keySeq);
23019 *keySeq = NULL; 23092 *keySeq = NULL;
23020 } 23093 }
23021 } /* if selector */ 23094 } /* if selector */
23022 » 23095
23023 sto->nbHistory--; 23096 sto->nbHistory--;
23024 23097
23025 deregister_check: 23098 deregister_check:
23026 /* 23099 /*
23027 * Deregister state objects if they reach the depth of creation. 23100 * Deregister state objects if they reach the depth of creation.
23028 */ 23101 */
23029 if ((sto->nbHistory == 0) && (sto->depth == depth)) { 23102 if ((sto->nbHistory == 0) && (sto->depth == depth)) {
23030 #ifdef DEBUG_IDC 23103 #ifdef DEBUG_IDC
23031 xmlGenericError(xmlGenericErrorContext, "IDC: STO pop '%s'\n", 23104 xmlGenericError(xmlGenericErrorContext, "IDC: STO pop '%s'\n",
23032 sto->sel->xpath); 23105 sto->sel->xpath);
(...skipping 30 matching lines...) Expand all
23063 * 23136 *
23064 * Returns 0 if OK and -1 on internal errors. 23137 * Returns 0 if OK and -1 on internal errors.
23065 */ 23138 */
23066 static int 23139 static int
23067 xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt, 23140 xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt,
23068 xmlSchemaElementPtr elemDecl) 23141 xmlSchemaElementPtr elemDecl)
23069 { 23142 {
23070 xmlSchemaIDCMatcherPtr matcher, last = NULL; 23143 xmlSchemaIDCMatcherPtr matcher, last = NULL;
23071 xmlSchemaIDCPtr idc, refIdc; 23144 xmlSchemaIDCPtr idc, refIdc;
23072 xmlSchemaIDCAugPtr aidc; 23145 xmlSchemaIDCAugPtr aidc;
23073 23146
23074 idc = (xmlSchemaIDCPtr) elemDecl->idcs; 23147 idc = (xmlSchemaIDCPtr) elemDecl->idcs;
23075 if (idc == NULL) 23148 if (idc == NULL)
23076 return (0); 23149 return (0);
23077 23150
23078 #ifdef DEBUG_IDC 23151 #ifdef DEBUG_IDC
23079 { 23152 {
23080 xmlChar *str = NULL; 23153 xmlChar *str = NULL;
23081 » xmlGenericError(xmlGenericErrorContext, 23154 » xmlGenericError(xmlGenericErrorContext,
23082 "IDC: REGISTER on %s, depth %d\n", 23155 "IDC: REGISTER on %s, depth %d\n",
23083 (char *) xmlSchemaFormatQName(&str, vctxt->inode->nsName, 23156 (char *) xmlSchemaFormatQName(&str, vctxt->inode->nsName,
23084 vctxt->inode->localName), vctxt->depth); 23157 vctxt->inode->localName), vctxt->depth);
23085 FREE_AND_NULL(str) 23158 FREE_AND_NULL(str)
23086 } 23159 }
23087 #endif 23160 #endif
23088 if (vctxt->inode->idcMatchers != NULL) { 23161 if (vctxt->inode->idcMatchers != NULL) {
23089 VERROR_INT("xmlSchemaIDCRegisterMatchers", 23162 VERROR_INT("xmlSchemaIDCRegisterMatchers",
23090 "The chain of IDC matchers is expected to be empty"); 23163 "The chain of IDC matchers is expected to be empty");
23091 return (-1); 23164 return (-1);
(...skipping 20 matching lines...) Expand all
23112 while (aidc != NULL) { 23185 while (aidc != NULL) {
23113 if (aidc->def == refIdc) 23186 if (aidc->def == refIdc)
23114 break; 23187 break;
23115 aidc = aidc->next; 23188 aidc = aidc->next;
23116 } 23189 }
23117 if (aidc == NULL) { 23190 if (aidc == NULL) {
23118 VERROR_INT("xmlSchemaIDCRegisterMatchers", 23191 VERROR_INT("xmlSchemaIDCRegisterMatchers",
23119 "Could not find an augmented IDC item for an IDC " 23192 "Could not find an augmented IDC item for an IDC "
23120 "definition"); 23193 "definition");
23121 return (-1); 23194 return (-1);
23122 » » }» » 23195 » » }
23123 if ((aidc->keyrefDepth == -1) || 23196 if ((aidc->keyrefDepth == -1) ||
23124 (vctxt->depth < aidc->keyrefDepth)) 23197 (vctxt->depth < aidc->keyrefDepth))
23125 aidc->keyrefDepth = vctxt->depth; 23198 aidc->keyrefDepth = vctxt->depth;
23126 } 23199 }
23127 } 23200 }
23128 /* 23201 /*
23129 * Lookup the augmented IDC item for the IDC definition. 23202 * Lookup the augmented IDC item for the IDC definition.
23130 */ 23203 */
23131 aidc = vctxt->aidcs; 23204 aidc = vctxt->aidcs;
23132 while (aidc != NULL) { 23205 while (aidc != NULL) {
(...skipping 10 matching lines...) Expand all
23143 * Create an IDC matcher for every IDC definition. 23216 * Create an IDC matcher for every IDC definition.
23144 */ 23217 */
23145 if (vctxt->idcMatcherCache != NULL) { 23218 if (vctxt->idcMatcherCache != NULL) {
23146 /* 23219 /*
23147 * Reuse a cached matcher. 23220 * Reuse a cached matcher.
23148 */ 23221 */
23149 matcher = vctxt->idcMatcherCache; 23222 matcher = vctxt->idcMatcherCache;
23150 vctxt->idcMatcherCache = matcher->nextCached; 23223 vctxt->idcMatcherCache = matcher->nextCached;
23151 matcher->nextCached = NULL; 23224 matcher->nextCached = NULL;
23152 } else { 23225 } else {
23153 » matcher = (xmlSchemaIDCMatcherPtr) 23226 » matcher = (xmlSchemaIDCMatcherPtr)
23154 xmlMalloc(sizeof(xmlSchemaIDCMatcher)); 23227 xmlMalloc(sizeof(xmlSchemaIDCMatcher));
23155 if (matcher == NULL) { 23228 if (matcher == NULL) {
23156 » » xmlSchemaVErrMemory(vctxt, 23229 » » xmlSchemaVErrMemory(vctxt,
23157 "allocating an IDC matcher", NULL); 23230 "allocating an IDC matcher", NULL);
23158 return (-1); 23231 return (-1);
23159 } 23232 }
23160 memset(matcher, 0, sizeof(xmlSchemaIDCMatcher)); 23233 memset(matcher, 0, sizeof(xmlSchemaIDCMatcher));
23161 } 23234 }
23162 if (last == NULL) 23235 if (last == NULL)
23163 vctxt->inode->idcMatchers = matcher; 23236 vctxt->inode->idcMatchers = matcher;
23164 else 23237 else
23165 last->next = matcher; 23238 last->next = matcher;
23166 last = matcher; 23239 last = matcher;
23167 23240
23168 matcher->type = IDC_MATCHER; 23241 matcher->type = IDC_MATCHER;
23169 » matcher->depth = vctxt->depth;» 23242 » matcher->depth = vctxt->depth;
23170 matcher->aidc = aidc; 23243 matcher->aidc = aidc;
23171 matcher->idcType = aidc->def->type; 23244 matcher->idcType = aidc->def->type;
23172 #ifdef DEBUG_IDC» 23245 #ifdef DEBUG_IDC
23173 xmlGenericError(xmlGenericErrorContext, "IDC: register matcher\n"); 23246 xmlGenericError(xmlGenericErrorContext, "IDC: register matcher\n");
23174 #endif 23247 #endif
23175 /* 23248 /*
23176 » * Init the automaton state object. 23249 » * Init the automaton state object.
23177 */ 23250 */
23178 » if (xmlSchemaIDCAddStateObject(vctxt, matcher, 23251 » if (xmlSchemaIDCAddStateObject(vctxt, matcher,
23179 idc->selector, XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) == -1) 23252 idc->selector, XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) == -1)
23180 return (-1); 23253 return (-1);
23181 23254
23182 idc = idc->next; 23255 idc = idc->next;
23183 } while (idc != NULL); 23256 } while (idc != NULL);
23184 return (0); 23257 return (0);
23185 } 23258 }
23186 23259
23187 static int 23260 static int
23188 xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt, 23261 xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt,
23189 xmlSchemaNodeInfoPtr ielem) 23262 xmlSchemaNodeInfoPtr ielem)
23190 { 23263 {
23191 xmlSchemaPSVIIDCBindingPtr bind; 23264 xmlSchemaPSVIIDCBindingPtr bind;
23192 int res, i, j, k, nbTargets, nbFields, nbDupls, nbNodeTable; 23265 int res, i, j, k, nbTargets, nbFields, nbDupls, nbNodeTable;
23193 xmlSchemaPSVIIDCKeyPtr *keys, *ntkeys; 23266 xmlSchemaPSVIIDCKeyPtr *keys, *ntkeys;
23194 xmlSchemaPSVIIDCNodePtr *targets, *dupls; 23267 xmlSchemaPSVIIDCNodePtr *targets, *dupls;
23195 23268
23196 xmlSchemaIDCMatcherPtr matcher = ielem->idcMatchers; 23269 xmlSchemaIDCMatcherPtr matcher = ielem->idcMatchers;
23197 /* vctxt->createIDCNodeTables */ 23270 /* vctxt->createIDCNodeTables */
23198 while (matcher != NULL) { 23271 while (matcher != NULL) {
23199 /* 23272 /*
23200 * Skip keyref IDCs and empty IDC target-lists. 23273 * Skip keyref IDCs and empty IDC target-lists.
23201 */ 23274 */
23202 if ((matcher->aidc->def->type == XML_SCHEMA_TYPE_IDC_KEYREF) || 23275 if ((matcher->aidc->def->type == XML_SCHEMA_TYPE_IDC_KEYREF) ||
23203 WXS_ILIST_IS_EMPTY(matcher->targets)) 23276 WXS_ILIST_IS_EMPTY(matcher->targets))
23204 { 23277 {
23205 matcher = matcher->next; 23278 matcher = matcher->next;
(...skipping 13 matching lines...) Expand all
23219 /* 23292 /*
23220 * Get/create the IDC binding on this element for the IDC definition. 23293 * Get/create the IDC binding on this element for the IDC definition.
23221 */ 23294 */
23222 bind = xmlSchemaIDCAcquireBinding(vctxt, matcher); 23295 bind = xmlSchemaIDCAcquireBinding(vctxt, matcher);
23223 23296
23224 if (! WXS_ILIST_IS_EMPTY(bind->dupls)) { 23297 if (! WXS_ILIST_IS_EMPTY(bind->dupls)) {
23225 dupls = (xmlSchemaPSVIIDCNodePtr *) bind->dupls->items; 23298 dupls = (xmlSchemaPSVIIDCNodePtr *) bind->dupls->items;
23226 nbDupls = bind->dupls->nbItems; 23299 nbDupls = bind->dupls->nbItems;
23227 } else { 23300 } else {
23228 dupls = NULL; 23301 dupls = NULL;
23229 » nbDupls = 0;» 23302 » nbDupls = 0;
23230 } 23303 }
23231 if (bind->nodeTable != NULL) { 23304 if (bind->nodeTable != NULL) {
23232 nbNodeTable = bind->nbNodes; 23305 nbNodeTable = bind->nbNodes;
23233 } else { 23306 } else {
23234 nbNodeTable = 0; 23307 nbNodeTable = 0;
23235 } 23308 }
23236 23309
23237 if ((nbNodeTable == 0) && (nbDupls == 0)) { 23310 if ((nbNodeTable == 0) && (nbDupls == 0)) {
23238 /* 23311 /*
23239 * Transfer all IDC target-nodes to the IDC node-table. 23312 * Transfer all IDC target-nodes to the IDC node-table.
23240 */ 23313 */
23241 bind->nodeTable = 23314 bind->nodeTable =
23242 » » (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items;» » 23315 » » (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items;
23243 bind->sizeNodes = matcher->targets->sizeItems; 23316 bind->sizeNodes = matcher->targets->sizeItems;
23244 bind->nbNodes = matcher->targets->nbItems; 23317 bind->nbNodes = matcher->targets->nbItems;
23245 23318
23246 matcher->targets->items = NULL; 23319 matcher->targets->items = NULL;
23247 matcher->targets->sizeItems = 0; 23320 matcher->targets->sizeItems = 0;
23248 » matcher->targets->nbItems = 0;» 23321 » matcher->targets->nbItems = 0;
23249 } else { 23322 } else {
23250 /* 23323 /*
23251 * Compare the key-sequences and add to the IDC node-table. 23324 * Compare the key-sequences and add to the IDC node-table.
23252 */ 23325 */
23253 nbTargets = matcher->targets->nbItems; 23326 nbTargets = matcher->targets->nbItems;
23254 » targets = (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items;» 23327 » targets = (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items;
23255 nbFields = matcher->aidc->def->nbFields; 23328 nbFields = matcher->aidc->def->nbFields;
23256 i = 0; 23329 i = 0;
23257 do { 23330 do {
23258 keys = targets[i]->keys; 23331 keys = targets[i]->keys;
23259 » » if (nbDupls) {» » » 23332 » » if (nbDupls) {
23260 /* 23333 /*
23261 * Search in already found duplicates first. 23334 * Search in already found duplicates first.
23262 */ 23335 */
23263 j = 0; 23336 j = 0;
23264 » » do {» » » » » » 23337 » » do {
23265 if (nbFields == 1) { 23338 if (nbFields == 1) {
23266 res = xmlSchemaAreValuesEqual(keys[0]->val, 23339 res = xmlSchemaAreValuesEqual(keys[0]->val,
23267 dupls[j]->keys[0]->val); 23340 dupls[j]->keys[0]->val);
23268 if (res == -1) 23341 if (res == -1)
23269 goto internal_error; 23342 goto internal_error;
23270 if (res == 1) { 23343 if (res == 1) {
23271 /* 23344 /*
23272 * Equal key-sequence. 23345 * Equal key-sequence.
23273 */ 23346 */
23274 goto next_target; 23347 goto next_target;
(...skipping 14 matching lines...) Expand all
23289 } 23362 }
23290 } 23363 }
23291 if (res == 1) { 23364 if (res == 1) {
23292 /* 23365 /*
23293 * Equal key-sequence found. 23366 * Equal key-sequence found.
23294 */ 23367 */
23295 goto next_target; 23368 goto next_target;
23296 } 23369 }
23297 } 23370 }
23298 j++; 23371 j++;
23299 » » } while (j < nbDupls);» » 23372 » » } while (j < nbDupls);
23300 } 23373 }
23301 if (nbNodeTable) { 23374 if (nbNodeTable) {
23302 j = 0; 23375 j = 0;
23303 » » do {» » » » » » 23376 » » do {
23304 if (nbFields == 1) { 23377 if (nbFields == 1) {
23305 res = xmlSchemaAreValuesEqual(keys[0]->val, 23378 res = xmlSchemaAreValuesEqual(keys[0]->val,
23306 bind->nodeTable[j]->keys[0]->val); 23379 bind->nodeTable[j]->keys[0]->val);
23307 if (res == -1) 23380 if (res == -1)
23308 goto internal_error; 23381 goto internal_error;
23309 if (res == 0) { 23382 if (res == 0) {
23310 /* 23383 /*
23311 * The key-sequence differs. 23384 * The key-sequence differs.
23312 */ 23385 */
23313 goto next_node_table_entry; 23386 goto next_node_table_entry;
23314 } 23387 }
23315 } else { 23388 } else {
23316 res = 0; 23389 res = 0;
23317 ntkeys = bind->nodeTable[j]->keys; 23390 ntkeys = bind->nodeTable[j]->keys;
23318 for (k = 0; k < nbFields; k++) { 23391 for (k = 0; k < nbFields; k++) {
23319 res = xmlSchemaAreValuesEqual(keys[k]->val, 23392 res = xmlSchemaAreValuesEqual(keys[k]->val,
23320 ntkeys[k]->val); 23393 ntkeys[k]->val);
23321 if (res == -1) 23394 if (res == -1)
23322 goto internal_error; 23395 goto internal_error;
23323 if (res == 0) { 23396 if (res == 0) {
23324 /* 23397 /*
23325 * One of the keys differs. 23398 * One of the keys differs.
23326 */ 23399 */
23327 goto next_node_table_entry; 23400 goto next_node_table_entry;
23328 } 23401 }
23329 } 23402 }
23330 » » » }» » » 23403 » » » }
23331 /* 23404 /*
23332 * Add the duplicate to the list of duplicates. 23405 * Add the duplicate to the list of duplicates.
23333 */ 23406 */
23334 if (bind->dupls == NULL) { 23407 if (bind->dupls == NULL) {
23335 bind->dupls = xmlSchemaItemListCreate(); 23408 bind->dupls = xmlSchemaItemListCreate();
23336 if (bind->dupls == NULL) 23409 if (bind->dupls == NULL)
23337 goto internal_error; 23410 goto internal_error;
23338 » » » }» » 23411 » » » }
23339 if (xmlSchemaItemListAdd(bind->dupls, bind->nodeTable[j] ) == -1) 23412 if (xmlSchemaItemListAdd(bind->dupls, bind->nodeTable[j] ) == -1)
23340 goto internal_error; 23413 goto internal_error;
23341 /* 23414 /*
23342 * Remove the duplicate entry from the IDC node-table. 23415 * Remove the duplicate entry from the IDC node-table.
23343 */ 23416 */
23344 bind->nodeTable[j] = bind->nodeTable[bind->nbNodes -1]; 23417 bind->nodeTable[j] = bind->nodeTable[bind->nbNodes -1];
23345 bind->nbNodes--; 23418 bind->nbNodes--;
23346 23419
23347 goto next_target; 23420 goto next_target;
23348 23421
(...skipping 14 matching lines...) Expand all
23363 } 23436 }
23364 matcher = matcher->next; 23437 matcher = matcher->next;
23365 } 23438 }
23366 return(0); 23439 return(0);
23367 23440
23368 internal_error: 23441 internal_error:
23369 return(-1); 23442 return(-1);
23370 } 23443 }
23371 23444
23372 /** 23445 /**
23373 * xmlSchemaBubbleIDCNodeTables: 23446 * xmlSchemaBubbleIDCNodeTables:
23374 * @depth: the current tree depth 23447 * @depth: the current tree depth
23375 * 23448 *
23376 * Merges IDC bindings of an element at @depth into the corresponding IDC 23449 * Merges IDC bindings of an element at @depth into the corresponding IDC
23377 * bindings of its parent element. If a duplicate note-table entry is found, 23450 * bindings of its parent element. If a duplicate note-table entry is found,
23378 * both, the parent node-table entry and child entry are discarded from the 23451 * both, the parent node-table entry and child entry are discarded from the
23379 * node-table of the parent. 23452 * node-table of the parent.
23380 * 23453 *
23381 * Returns 0 if OK and -1 on internal errors. 23454 * Returns 0 if OK and -1 on internal errors.
23382 */ 23455 */
23383 static int 23456 static int
23384 xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) 23457 xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
23385 { 23458 {
23386 xmlSchemaPSVIIDCBindingPtr bind; /* IDC bindings of the current node. */ 23459 xmlSchemaPSVIIDCBindingPtr bind; /* IDC bindings of the current node. */
23387 xmlSchemaPSVIIDCBindingPtr *parTable, parBind = NULL; /* parent IDC bindings . */ 23460 xmlSchemaPSVIIDCBindingPtr *parTable, parBind = NULL; /* parent IDC bindings . */
23388 xmlSchemaPSVIIDCNodePtr node, parNode = NULL, *dupls, *parNodes; /* node-tab le entries. */ 23461 xmlSchemaPSVIIDCNodePtr node, parNode = NULL, *dupls, *parNodes; /* node-tab le entries. */
23389 xmlSchemaIDCAugPtr aidc; 23462 xmlSchemaIDCAugPtr aidc;
23390 int i, j, k, ret = 0, nbFields, oldNum, oldDupls; 23463 int i, j, k, ret = 0, nbFields, oldNum, oldDupls;
23391 23464
23392 bind = vctxt->inode->idcTable; 23465 bind = vctxt->inode->idcTable;
23393 if (bind == NULL) { 23466 if (bind == NULL) {
23394 /* Fine, no table, no bubbles. */ 23467 /* Fine, no table, no bubbles. */
23395 return (0); 23468 return (0);
23396 } 23469 }
23397 23470
23398 parTable = &(vctxt->elemInfos[vctxt->depth -1]->idcTable); 23471 parTable = &(vctxt->elemInfos[vctxt->depth -1]->idcTable);
23399 /* 23472 /*
23400 * Walk all bindings; create new or add to existing bindings. 23473 * Walk all bindings; create new or add to existing bindings.
23401 * Remove duplicate key-sequences. 23474 * Remove duplicate key-sequences.
23402 */ 23475 */
23403 while (bind != NULL) { 23476 while (bind != NULL) {
23404 » 23477
23405 if ((bind->nbNodes == 0) && WXS_ILIST_IS_EMPTY(bind->dupls)) 23478 if ((bind->nbNodes == 0) && WXS_ILIST_IS_EMPTY(bind->dupls))
23406 goto next_binding; 23479 goto next_binding;
23407 /* 23480 /*
23408 * Check if the key/unique IDC table needs to be bubbled. 23481 * Check if the key/unique IDC table needs to be bubbled.
23409 */ 23482 */
23410 if (! vctxt->createIDCNodeTables) { 23483 if (! vctxt->createIDCNodeTables) {
23411 aidc = vctxt->aidcs; 23484 aidc = vctxt->aidcs;
23412 do { 23485 do {
23413 if (aidc->def == bind->definition) { 23486 if (aidc->def == bind->definition) {
23414 » » if ((aidc->keyrefDepth == -1) || 23487 » » if ((aidc->keyrefDepth == -1) ||
23415 (aidc->keyrefDepth >= vctxt->depth)) { 23488 (aidc->keyrefDepth >= vctxt->depth)) {
23416 goto next_binding; 23489 goto next_binding;
23417 } 23490 }
23418 break; 23491 break;
23419 } 23492 }
23420 aidc = aidc->next; 23493 aidc = aidc->next;
23421 } while (aidc != NULL); 23494 } while (aidc != NULL);
23422 } 23495 }
23423 23496
23424 if (parTable != NULL) 23497 if (parTable != NULL)
23425 parBind = *parTable; 23498 parBind = *parTable;
23426 /* 23499 /*
23427 * Search a matching parent binding for the 23500 * Search a matching parent binding for the
23428 * IDC definition. 23501 * IDC definition.
23429 */ 23502 */
23430 » while (parBind != NULL) {» 23503 » while (parBind != NULL) {
23431 if (parBind->definition == bind->definition) 23504 if (parBind->definition == bind->definition)
23432 break; 23505 break;
23433 parBind = parBind->next; 23506 parBind = parBind->next;
23434 } 23507 }
23435 23508
23436 if (parBind != NULL) { 23509 if (parBind != NULL) {
23437 /* 23510 /*
23438 » * Compare every node-table entry of the child node, 23511 » * Compare every node-table entry of the child node,
23439 * i.e. the key-sequence within, ... 23512 * i.e. the key-sequence within, ...
23440 */ 23513 */
23441 oldNum = parBind->nbNodes; /* Skip newly added items. */ 23514 oldNum = parBind->nbNodes; /* Skip newly added items. */
23442 23515
23443 if (! WXS_ILIST_IS_EMPTY(parBind->dupls)) { 23516 if (! WXS_ILIST_IS_EMPTY(parBind->dupls)) {
23444 oldDupls = parBind->dupls->nbItems; 23517 oldDupls = parBind->dupls->nbItems;
23445 dupls = (xmlSchemaPSVIIDCNodePtr *) parBind->dupls->items; 23518 dupls = (xmlSchemaPSVIIDCNodePtr *) parBind->dupls->items;
23446 } else { 23519 } else {
23447 dupls = NULL; 23520 dupls = NULL;
23448 » » oldDupls = 0;» » 23521 » » oldDupls = 0;
23449 } 23522 }
23450 » 23523
23451 parNodes = parBind->nodeTable; 23524 parNodes = parBind->nodeTable;
23452 nbFields = bind->definition->nbFields; 23525 nbFields = bind->definition->nbFields;
23453 » 23526
23454 for (i = 0; i < bind->nbNodes; i++) { 23527 for (i = 0; i < bind->nbNodes; i++) {
23455 node = bind->nodeTable[i]; 23528 node = bind->nodeTable[i];
23456 if (node == NULL) 23529 if (node == NULL)
23457 continue; 23530 continue;
23458 /* 23531 /*
23459 * ...with every key-sequence of the parent node, already 23532 * ...with every key-sequence of the parent node, already
23460 * evaluated to be a duplicate key-sequence. 23533 * evaluated to be a duplicate key-sequence.
23461 */ 23534 */
23462 if (oldDupls) { 23535 if (oldDupls) {
23463 » » j = 0; 23536 » » j = 0;
23464 while (j < oldDupls) { 23537 while (j < oldDupls) {
23465 if (nbFields == 1) { 23538 if (nbFields == 1) {
23466 ret = xmlSchemaAreValuesEqual( 23539 ret = xmlSchemaAreValuesEqual(
23467 node->keys[0]->val, 23540 node->keys[0]->val,
23468 dupls[j]->keys[0]->val); 23541 dupls[j]->keys[0]->val);
23469 if (ret == -1) 23542 if (ret == -1)
23470 goto internal_error; 23543 goto internal_error;
23471 if (ret == 0) { 23544 if (ret == 0) {
23472 j++; 23545 j++;
23473 continue; 23546 continue;
(...skipping 12 matching lines...) Expand all
23486 } 23559 }
23487 if (ret == 1) 23560 if (ret == 1)
23488 /* Duplicate found. */ 23561 /* Duplicate found. */
23489 break; 23562 break;
23490 j++; 23563 j++;
23491 } 23564 }
23492 if (j != oldDupls) { 23565 if (j != oldDupls) {
23493 /* Duplicate found. Skip this entry. */ 23566 /* Duplicate found. Skip this entry. */
23494 continue; 23567 continue;
23495 } 23568 }
23496 » » }» » 23569 » » }
23497 /* 23570 /*
23498 * ... and with every key-sequence of the parent node. 23571 * ... and with every key-sequence of the parent node.
23499 */ 23572 */
23500 if (oldNum) { 23573 if (oldNum) {
23501 » » j = 0; 23574 » » j = 0;
23502 while (j < oldNum) { 23575 while (j < oldNum) {
23503 parNode = parNodes[j]; 23576 parNode = parNodes[j];
23504 if (nbFields == 1) { 23577 if (nbFields == 1) {
23505 ret = xmlSchemaAreValuesEqual( 23578 ret = xmlSchemaAreValuesEqual(
23506 node->keys[0]->val, 23579 node->keys[0]->val,
23507 parNode->keys[0]->val); 23580 parNode->keys[0]->val);
23508 if (ret == -1) 23581 if (ret == -1)
23509 goto internal_error; 23582 goto internal_error;
23510 if (ret == 0) { 23583 if (ret == 0) {
23511 j++; 23584 j++;
23512 continue; 23585 continue;
23513 } 23586 }
23514 » » » } else {» » » 23587 » » » } else {
23515 for (k = 0; k < nbFields; k++) { 23588 for (k = 0; k < nbFields; k++) {
23516 ret = xmlSchemaAreValuesEqual( 23589 ret = xmlSchemaAreValuesEqual(
23517 node->keys[k]->val, 23590 node->keys[k]->val,
23518 parNode->keys[k]->val); 23591 parNode->keys[k]->val);
23519 if (ret == -1) 23592 if (ret == -1)
23520 goto internal_error; 23593 goto internal_error;
23521 if (ret == 0) 23594 if (ret == 0)
23522 break; 23595 break;
23523 } 23596 }
23524 } 23597 }
23525 if (ret == 1) 23598 if (ret == 1)
23526 /* Duplicate found. */ 23599 /* Duplicate found. */
23527 break; 23600 break;
23528 j++; 23601 j++;
23529 } 23602 }
23530 if (j != oldNum) { 23603 if (j != oldNum) {
23531 /* 23604 /*
23532 * Handle duplicates. Move the duplicate in 23605 * Handle duplicates. Move the duplicate in
23533 * the parent's node-table to the list of 23606 * the parent's node-table to the list of
23534 * duplicates. 23607 * duplicates.
23535 » » » */» » » 23608 » » » */
23536 oldNum--; 23609 oldNum--;
23537 parBind->nbNodes--; 23610 parBind->nbNodes--;
23538 /* 23611 /*
23539 * Move last old item to pos of duplicate. 23612 * Move last old item to pos of duplicate.
23540 */ 23613 */
23541 parNodes[j] = parNodes[oldNum]; 23614 parNodes[j] = parNodes[oldNum];
23542 » » » 23615
23543 if (parBind->nbNodes != oldNum) { 23616 if (parBind->nbNodes != oldNum) {
23544 /* 23617 /*
23545 » » » * If new items exist, move last new item to 23618 » » » * If new items exist, move last new item to
23546 * last of old items. 23619 * last of old items.
23547 */ 23620 */
23548 » » » parNodes[oldNum] = 23621 » » » parNodes[oldNum] =
23549 parNodes[parBind->nbNodes]; 23622 parNodes[parBind->nbNodes];
23550 } 23623 }
23551 if (parBind->dupls == NULL) { 23624 if (parBind->dupls == NULL) {
23552 parBind->dupls = xmlSchemaItemListCreate(); 23625 parBind->dupls = xmlSchemaItemListCreate();
23553 if (parBind->dupls == NULL) 23626 if (parBind->dupls == NULL)
23554 goto internal_error; 23627 goto internal_error;
23555 } 23628 }
23556 » » » xmlSchemaItemListAdd(parBind->dupls, parNode);» » » 23629 » » » xmlSchemaItemListAdd(parBind->dupls, parNode);
23557 } else { 23630 } else {
23558 /* 23631 /*
23559 » » » * Add the node-table entry (node and key-sequence) of 23632 » » » * Add the node-table entry (node and key-sequence) of
23560 * the child node to the node table of the parent node. 23633 * the child node to the node table of the parent node.
23561 */ 23634 */
23562 » » » if (parBind->nodeTable == NULL) {» » » 23635 » » » if (parBind->nodeTable == NULL) {
23563 » » » parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *) 23636 » » » parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
23564 xmlMalloc(10 * sizeof(xmlSchemaPSVIIDCNodePtr)); 23637 xmlMalloc(10 * sizeof(xmlSchemaPSVIIDCNodePtr));
23565 if (parBind->nodeTable == NULL) { 23638 if (parBind->nodeTable == NULL) {
23566 » » » » xmlSchemaVErrMemory(NULL, 23639 » » » » xmlSchemaVErrMemory(NULL,
23567 "allocating IDC list of node-table items", N ULL); 23640 "allocating IDC list of node-table items", N ULL);
23568 goto internal_error; 23641 goto internal_error;
23569 } 23642 }
23570 parBind->sizeNodes = 1; 23643 parBind->sizeNodes = 1;
23571 } else if (parBind->nbNodes >= parBind->sizeNodes) { 23644 } else if (parBind->nbNodes >= parBind->sizeNodes) {
23572 parBind->sizeNodes *= 2; 23645 parBind->sizeNodes *= 2;
23573 » » » parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *) 23646 » » » parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
23574 » » » » xmlRealloc(parBind->nodeTable, parBind->sizeNode s * 23647 » » » » xmlRealloc(parBind->nodeTable, parBind->sizeNode s *
23575 sizeof(xmlSchemaPSVIIDCNodePtr)); 23648 sizeof(xmlSchemaPSVIIDCNodePtr));
23576 if (parBind->nodeTable == NULL) { 23649 if (parBind->nodeTable == NULL) {
23577 » » » » xmlSchemaVErrMemory(NULL, 23650 » » » » xmlSchemaVErrMemory(NULL,
23578 "re-allocating IDC list of node-table items" , NULL); 23651 "re-allocating IDC list of node-table items" , NULL);
23579 goto internal_error; 23652 goto internal_error;
23580 » » » }» » » 23653 » » » }
23581 } 23654 }
23582 parNodes = parBind->nodeTable; 23655 parNodes = parBind->nodeTable;
23583 /* 23656 /*
23584 * Append the new node-table entry to the 'new node-table 23657 * Append the new node-table entry to the 'new node-table
23585 * entries' section. 23658 * entries' section.
23586 */ 23659 */
23587 parNodes[parBind->nbNodes++] = node; 23660 parNodes[parBind->nbNodes++] = node;
23588 } 23661 }
23589 23662
23590 » » }» 23663 » » }
23591 » » 23664
23592 » }» 23665 » }
23593 } else { 23666 } else {
23594 /* 23667 /*
23595 * No binding for the IDC was found: create a new one and 23668 * No binding for the IDC was found: create a new one and
23596 * copy all node-tables. 23669 * copy all node-tables.
23597 */ 23670 */
23598 parBind = xmlSchemaIDCNewBinding(bind->definition); 23671 parBind = xmlSchemaIDCNewBinding(bind->definition);
23599 if (parBind == NULL) 23672 if (parBind == NULL)
23600 goto internal_error; 23673 goto internal_error;
23601 » 23674
23602 /* 23675 /*
23603 * TODO: Hmm, how to optimize the initial number of 23676 * TODO: Hmm, how to optimize the initial number of
23604 * allocated entries? 23677 * allocated entries?
23605 */ 23678 */
23606 if (bind->nbNodes != 0) { 23679 if (bind->nbNodes != 0) {
23607 /* 23680 /*
23608 * Add all IDC node-table entries. 23681 * Add all IDC node-table entries.
23609 */ 23682 */
23610 if (! vctxt->psviExposeIDCNodeTables) { 23683 if (! vctxt->psviExposeIDCNodeTables) {
23611 /* 23684 /*
23612 * Just move the entries. 23685 * Just move the entries.
23613 * NOTE: this is quite save here, since 23686 * NOTE: this is quite save here, since
23614 * all the keyref lookups have already been 23687 * all the keyref lookups have already been
23615 * performed. 23688 * performed.
23616 */ 23689 */
23617 parBind->nodeTable = bind->nodeTable; 23690 parBind->nodeTable = bind->nodeTable;
23618 bind->nodeTable = NULL; 23691 bind->nodeTable = NULL;
23619 parBind->sizeNodes = bind->sizeNodes; 23692 parBind->sizeNodes = bind->sizeNodes;
23620 bind->sizeNodes = 0; 23693 bind->sizeNodes = 0;
23621 parBind->nbNodes = bind->nbNodes; 23694 parBind->nbNodes = bind->nbNodes;
23622 bind->nbNodes = 0; 23695 bind->nbNodes = 0;
23623 } else { 23696 } else {
23624 /* 23697 /*
23625 * Copy the entries. 23698 * Copy the entries.
23626 */ 23699 */
23627 » » parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *) 23700 » » parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
23628 xmlMalloc(bind->nbNodes * 23701 xmlMalloc(bind->nbNodes *
23629 sizeof(xmlSchemaPSVIIDCNodePtr)); 23702 sizeof(xmlSchemaPSVIIDCNodePtr));
23630 if (parBind->nodeTable == NULL) { 23703 if (parBind->nodeTable == NULL) {
23631 » » » xmlSchemaVErrMemory(NULL, 23704 » » » xmlSchemaVErrMemory(NULL,
23632 "allocating an array of IDC node-table " 23705 "allocating an array of IDC node-table "
23633 "items", NULL); 23706 "items", NULL);
23634 xmlSchemaIDCFreeBinding(parBind); 23707 xmlSchemaIDCFreeBinding(parBind);
23635 goto internal_error; 23708 goto internal_error;
23636 } 23709 }
23637 parBind->sizeNodes = bind->nbNodes; 23710 parBind->sizeNodes = bind->nbNodes;
23638 parBind->nbNodes = bind->nbNodes; 23711 parBind->nbNodes = bind->nbNodes;
23639 memcpy(parBind->nodeTable, bind->nodeTable, 23712 memcpy(parBind->nodeTable, bind->nodeTable,
23640 bind->nbNodes * sizeof(xmlSchemaPSVIIDCNodePtr)); 23713 bind->nbNodes * sizeof(xmlSchemaPSVIIDCNodePtr));
23641 } 23714 }
23642 } 23715 }
23643 if (bind->dupls) { 23716 if (bind->dupls) {
23644 /* 23717 /*
23645 * Move the duplicates. 23718 * Move the duplicates.
23646 */ 23719 */
23647 if (parBind->dupls != NULL) 23720 if (parBind->dupls != NULL)
23648 xmlSchemaItemListFree(parBind->dupls); 23721 xmlSchemaItemListFree(parBind->dupls);
23649 parBind->dupls = bind->dupls; 23722 parBind->dupls = bind->dupls;
23650 » » bind->dupls = NULL;» » 23723 » » bind->dupls = NULL;
23651 } 23724 }
23652 » if (*parTable == NULL) 23725 if (parTable != NULL) {
23653 » » *parTable = parBind; 23726 if (*parTable == NULL)
23654 » else { 23727 *parTable = parBind;
23655 » » parBind->next = *parTable; 23728 else {
23656 » » *parTable = parBind; 23729 parBind->next = *parTable;
23657 » }» 23730 *parTable = parBind;
23658 » }» 23731 }
23732 }
23733 » }
23659 23734
23660 next_binding: 23735 next_binding:
23661 bind = bind->next; 23736 bind = bind->next;
23662 } 23737 }
23663 return (0); 23738 return (0);
23664 23739
23665 internal_error: 23740 internal_error:
23666 return(-1); 23741 return(-1);
23667 } 23742 }
23668 23743
23669 /** 23744 /**
23670 * xmlSchemaCheckCVCIDCKeyRef: 23745 * xmlSchemaCheckCVCIDCKeyRef:
23671 * @vctxt: the WXS validation context 23746 * @vctxt: the WXS validation context
23672 * @elemDecl: the element declaration 23747 * @elemDecl: the element declaration
23673 * 23748 *
23674 * Check the cvc-idc-keyref constraints. 23749 * Check the cvc-idc-keyref constraints.
23675 */ 23750 */
23676 static int 23751 static int
23677 xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt) 23752 xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt)
23678 { 23753 {
23679 xmlSchemaIDCMatcherPtr matcher; 23754 xmlSchemaIDCMatcherPtr matcher;
23680 xmlSchemaPSVIIDCBindingPtr bind; 23755 xmlSchemaPSVIIDCBindingPtr bind;
23681 23756
23682 matcher = vctxt->inode->idcMatchers; 23757 matcher = vctxt->inode->idcMatchers;
23683 /* 23758 /*
23684 * Find a keyref. 23759 * Find a keyref.
23685 */ 23760 */
23686 while (matcher != NULL) { 23761 while (matcher != NULL) {
23687 if ((matcher->idcType == XML_SCHEMA_TYPE_IDC_KEYREF) && 23762 if ((matcher->idcType == XML_SCHEMA_TYPE_IDC_KEYREF) &&
23688 matcher->targets && 23763 matcher->targets &&
23689 matcher->targets->nbItems) 23764 matcher->targets->nbItems)
23690 { 23765 {
23691 int i, j, k, res, nbFields, hasDupls; 23766 int i, j, k, res, nbFields, hasDupls;
23692 xmlSchemaPSVIIDCKeyPtr *refKeys, *keys; 23767 xmlSchemaPSVIIDCKeyPtr *refKeys, *keys;
23693 xmlSchemaPSVIIDCNodePtr refNode = NULL; 23768 xmlSchemaPSVIIDCNodePtr refNode = NULL;
23694 23769
23695 nbFields = matcher->aidc->def->nbFields; 23770 nbFields = matcher->aidc->def->nbFields;
23696 23771
23697 /* 23772 /*
23698 * Find the IDC node-table for the referenced IDC key/unique. 23773 * Find the IDC node-table for the referenced IDC key/unique.
23699 */ 23774 */
23700 bind = vctxt->inode->idcTable; 23775 bind = vctxt->inode->idcTable;
23701 while (bind != NULL) { 23776 while (bind != NULL) {
23702 » » if ((xmlSchemaIDCPtr) matcher->aidc->def->ref->item == 23777 » » if ((xmlSchemaIDCPtr) matcher->aidc->def->ref->item ==
23703 bind->definition) 23778 bind->definition)
23704 break; 23779 break;
23705 bind = bind->next; 23780 bind = bind->next;
23706 } 23781 }
23707 hasDupls = (bind && bind->dupls && bind->dupls->nbItems) ? 1 : 0; 23782 hasDupls = (bind && bind->dupls && bind->dupls->nbItems) ? 1 : 0;
23708 /* 23783 /*
23709 * Search for a matching key-sequences. 23784 * Search for a matching key-sequences.
23710 */ 23785 */
23711 for (i = 0; i < matcher->targets->nbItems; i++) { 23786 for (i = 0; i < matcher->targets->nbItems; i++) {
23712 res = 0; 23787 res = 0;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
23761 refNode->keys, nbFields), 23836 refNode->keys, nbFields),
23762 xmlSchemaGetComponentQName(&strB, 23837 xmlSchemaGetComponentQName(&strB,
23763 matcher->aidc->def)); 23838 matcher->aidc->def));
23764 FREE_AND_NULL(str); 23839 FREE_AND_NULL(str);
23765 FREE_AND_NULL(strB); 23840 FREE_AND_NULL(strB);
23766 break; 23841 break;
23767 } 23842 }
23768 } 23843 }
23769 } 23844 }
23770 } 23845 }
23771 » » 23846
23772 if (res == 0) { 23847 if (res == 0) {
23773 xmlChar *str = NULL, *strB = NULL; 23848 xmlChar *str = NULL, *strB = NULL;
23774 xmlSchemaKeyrefErr(vctxt, 23849 xmlSchemaKeyrefErr(vctxt,
23775 XML_SCHEMAV_CVC_IDC, refNode, 23850 XML_SCHEMAV_CVC_IDC, refNode,
23776 (xmlSchemaTypePtr) matcher->aidc->def, 23851 (xmlSchemaTypePtr) matcher->aidc->def,
23777 "No match found for key-sequence %s of keyref '%s'", 23852 "No match found for key-sequence %s of keyref '%s'",
23778 xmlSchemaFormatIDCKeySequence(vctxt, &str, 23853 xmlSchemaFormatIDCKeySequence(vctxt, &str,
23779 refNode->keys, nbFields), 23854 refNode->keys, nbFields),
23780 xmlSchemaGetComponentQName(&strB, matcher->aidc->def)); 23855 xmlSchemaGetComponentQName(&strB, matcher->aidc->def));
23781 FREE_AND_NULL(str); 23856 FREE_AND_NULL(str);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
23845 vctxt->attrInfos[vctxt->nbAttrInfos++] = iattr; 23920 vctxt->attrInfos[vctxt->nbAttrInfos++] = iattr;
23846 23921
23847 return (iattr); 23922 return (iattr);
23848 } 23923 }
23849 23924
23850 static int 23925 static int
23851 xmlSchemaValidatorPushAttribute(xmlSchemaValidCtxtPtr vctxt, 23926 xmlSchemaValidatorPushAttribute(xmlSchemaValidCtxtPtr vctxt,
23852 xmlNodePtr attrNode, 23927 xmlNodePtr attrNode,
23853 int nodeLine, 23928 int nodeLine,
23854 const xmlChar *localName, 23929 const xmlChar *localName,
23855 » » » const xmlChar *nsName,» » » 23930 » » » const xmlChar *nsName,
23856 int ownedNames, 23931 int ownedNames,
23857 xmlChar *value, 23932 xmlChar *value,
23858 int ownedValue) 23933 int ownedValue)
23859 { 23934 {
23860 xmlSchemaAttrInfoPtr attr; 23935 xmlSchemaAttrInfoPtr attr;
23861 23936
23862 attr = xmlSchemaGetFreshAttrInfo(vctxt); 23937 attr = xmlSchemaGetFreshAttrInfo(vctxt);
23863 if (attr == NULL) { 23938 if (attr == NULL) {
23864 VERROR_INT("xmlSchemaPushAttribute", 23939 VERROR_INT("xmlSchemaPushAttribute",
23865 "calling xmlSchemaGetFreshAttrInfo()"); 23940 "calling xmlSchemaGetFreshAttrInfo()");
23866 return (-1); 23941 return (-1);
23867 } 23942 }
23868 attr->node = attrNode; 23943 attr->node = attrNode;
23869 attr->nodeLine = nodeLine; 23944 attr->nodeLine = nodeLine;
23870 attr->state = XML_SCHEMAS_ATTR_UNKNOWN; 23945 attr->state = XML_SCHEMAS_ATTR_UNKNOWN;
23871 attr->localName = localName; 23946 attr->localName = localName;
23872 attr->nsName = nsName; 23947 attr->nsName = nsName;
23873 if (ownedNames) 23948 if (ownedNames)
23874 attr->flags |= XML_SCHEMA_NODE_INFO_FLAG_OWNED_NAMES; 23949 attr->flags |= XML_SCHEMA_NODE_INFO_FLAG_OWNED_NAMES;
23875 /* 23950 /*
23876 * Evaluate if it's an XSI attribute. 23951 * Evaluate if it's an XSI attribute.
23877 */ 23952 */
23878 if (nsName != NULL) { 23953 if (nsName != NULL) {
23879 if (xmlStrEqual(localName, BAD_CAST "nil")) { 23954 if (xmlStrEqual(localName, BAD_CAST "nil")) {
23880 if (xmlStrEqual(attr->nsName, xmlSchemaInstanceNs)) { 23955 if (xmlStrEqual(attr->nsName, xmlSchemaInstanceNs)) {
23881 » » attr->metaType = XML_SCHEMA_ATTR_INFO_META_XSI_NIL;» » 23956 » » attr->metaType = XML_SCHEMA_ATTR_INFO_META_XSI_NIL;
23882 } 23957 }
23883 } else if (xmlStrEqual(localName, BAD_CAST "type")) { 23958 } else if (xmlStrEqual(localName, BAD_CAST "type")) {
23884 if (xmlStrEqual(attr->nsName, xmlSchemaInstanceNs)) { 23959 if (xmlStrEqual(attr->nsName, xmlSchemaInstanceNs)) {
23885 attr->metaType = XML_SCHEMA_ATTR_INFO_META_XSI_TYPE; 23960 attr->metaType = XML_SCHEMA_ATTR_INFO_META_XSI_TYPE;
23886 } 23961 }
23887 } else if (xmlStrEqual(localName, BAD_CAST "schemaLocation")) { 23962 } else if (xmlStrEqual(localName, BAD_CAST "schemaLocation")) {
23888 if (xmlStrEqual(attr->nsName, xmlSchemaInstanceNs)) { 23963 if (xmlStrEqual(attr->nsName, xmlSchemaInstanceNs)) {
23889 attr->metaType = XML_SCHEMA_ATTR_INFO_META_XSI_SCHEMA_LOC; 23964 attr->metaType = XML_SCHEMA_ATTR_INFO_META_XSI_SCHEMA_LOC;
23890 } 23965 }
23891 } else if (xmlStrEqual(localName, BAD_CAST "noNamespaceSchemaLocation")) { 23966 } else if (xmlStrEqual(localName, BAD_CAST "noNamespaceSchemaLocation")) {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
24092 ws = XML_SCHEMA_WHITESPACE_COLLAPSE; 24167 ws = XML_SCHEMA_WHITESPACE_COLLAPSE;
24093 /* 24168 /*
24094 * If the value was not computed (for string or 24169 * If the value was not computed (for string or
24095 * anySimpleType based types), then use the provided 24170 * anySimpleType based types), then use the provided
24096 * type. 24171 * type.
24097 */ 24172 */
24098 if (val == NULL) 24173 if (val == NULL)
24099 valType = valType; 24174 valType = valType;
24100 else 24175 else
24101 valType = xmlSchemaGetValType(val); 24176 valType = xmlSchemaGetValType(val);
24102 24177
24103 ret = 0; 24178 ret = 0;
24104 for (facetLink = type->facetSet; facetLink != NULL; 24179 for (facetLink = type->facetSet; facetLink != NULL;
24105 facetLink = facetLink->next) { 24180 facetLink = facetLink->next) {
24106 /* 24181 /*
24107 * Skip the pattern "whiteSpace": it is used to 24182 * Skip the pattern "whiteSpace": it is used to
24108 * format the character content beforehand. 24183 * format the character content beforehand.
24109 */ 24184 */
24110 switch (facetLink->facet->type) { 24185 switch (facetLink->facet->type) {
24111 case XML_SCHEMA_FACET_WHITESPACE: 24186 case XML_SCHEMA_FACET_WHITESPACE:
24112 case XML_SCHEMA_FACET_PATTERN: 24187 case XML_SCHEMA_FACET_PATTERN:
(...skipping 28 matching lines...) Expand all
24141 24216
24142 WXS_IS_LIST: 24217 WXS_IS_LIST:
24143 if (! WXS_IS_LIST(type)) 24218 if (! WXS_IS_LIST(type))
24144 goto pattern_and_enum; 24219 goto pattern_and_enum;
24145 /* 24220 /*
24146 * "length", "minLength" and "maxLength" of list types. 24221 * "length", "minLength" and "maxLength" of list types.
24147 */ 24222 */
24148 ret = 0; 24223 ret = 0;
24149 for (facetLink = type->facetSet; facetLink != NULL; 24224 for (facetLink = type->facetSet; facetLink != NULL;
24150 facetLink = facetLink->next) { 24225 facetLink = facetLink->next) {
24151 » 24226
24152 switch (facetLink->facet->type) { 24227 switch (facetLink->facet->type) {
24153 case XML_SCHEMA_FACET_LENGTH: 24228 case XML_SCHEMA_FACET_LENGTH:
24154 case XML_SCHEMA_FACET_MINLENGTH: 24229 case XML_SCHEMA_FACET_MINLENGTH:
24155 » case XML_SCHEMA_FACET_MAXLENGTH:» » 24230 » case XML_SCHEMA_FACET_MAXLENGTH:
24156 ret = xmlSchemaValidateListSimpleTypeFacet(facetLink->facet, 24231 ret = xmlSchemaValidateListSimpleTypeFacet(facetLink->facet,
24157 value, length, NULL); 24232 value, length, NULL);
24158 break; 24233 break;
24159 default: 24234 default:
24160 continue; 24235 continue;
24161 } 24236 }
24162 if (ret < 0) { 24237 if (ret < 0) {
24163 AERROR_INT("xmlSchemaValidateFacets", 24238 AERROR_INT("xmlSchemaValidateFacets",
24164 "validating against a list type facet"); 24239 "validating against a list type facet");
24165 return (-1); 24240 return (-1);
24166 } else if (ret > 0) { 24241 } else if (ret > 0) {
24167 » if (fireErrors)» » 24242 » if (fireErrors)
24168 xmlSchemaFacetErr(actxt, ret, node, 24243 xmlSchemaFacetErr(actxt, ret, node,
24169 value, length, type, facetLink->facet, NULL, NULL, NULL); 24244 value, length, type, facetLink->facet, NULL, NULL, NULL);
24170 else 24245 else
24171 return (ret); 24246 return (ret);
24172 if (error == 0) 24247 if (error == 0)
24173 error = ret; 24248 error = ret;
24174 } 24249 }
24175 ret = 0; 24250 ret = 0;
24176 } 24251 }
24177 24252
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
24234 */ 24309 */
24235 tmpType = type; 24310 tmpType = type;
24236 facet = NULL; 24311 facet = NULL;
24237 do { 24312 do {
24238 found = 0; 24313 found = 0;
24239 for (facetLink = tmpType->facetSet; facetLink != NULL; 24314 for (facetLink = tmpType->facetSet; facetLink != NULL;
24240 facetLink = facetLink->next) { 24315 facetLink = facetLink->next) {
24241 if (facetLink->facet->type != XML_SCHEMA_FACET_PATTERN) 24316 if (facetLink->facet->type != XML_SCHEMA_FACET_PATTERN)
24242 continue; 24317 continue;
24243 found = 1; 24318 found = 1;
24244 » » /* 24319 » » /*
24245 * NOTE that for patterns, @value needs to be the 24320 * NOTE that for patterns, @value needs to be the
24246 * normalized vaule. 24321 * normalized vaule.
24247 */ 24322 */
24248 ret = xmlRegexpExec(facetLink->facet->regexp, value); 24323 ret = xmlRegexpExec(facetLink->facet->regexp, value);
24249 if (ret == 1) 24324 if (ret == 1)
24250 break; 24325 break;
24251 else if (ret < 0) { 24326 else if (ret < 0) {
24252 AERROR_INT("xmlSchemaValidateFacets", 24327 AERROR_INT("xmlSchemaValidateFacets",
24253 "validating against a pattern facet"); 24328 "validating against a pattern facet");
24254 return (-1); 24329 return (-1);
24255 } else { 24330 } else {
24256 » » /* 24331 » » /*
24257 * Save the last non-validating facet. 24332 * Save the last non-validating facet.
24258 */ 24333 */
24259 facet = facetLink->facet; 24334 facet = facetLink->facet;
24260 } 24335 }
24261 } 24336 }
24262 if (found && (ret != 1)) { 24337 if (found && (ret != 1)) {
24263 ret = XML_SCHEMAV_CVC_PATTERN_VALID; 24338 ret = XML_SCHEMAV_CVC_PATTERN_VALID;
24264 if (fireErrors) { 24339 if (fireErrors) {
24265 xmlSchemaFacetErr(actxt, ret, node, 24340 xmlSchemaFacetErr(actxt, ret, node,
24266 value, 0, type, facet, NULL, NULL, NULL); 24341 value, 0, type, facet, NULL, NULL, NULL);
24267 } else 24342 } else
24268 return (ret); 24343 return (ret);
24269 if (error == 0) 24344 if (error == 0)
24270 error = ret; 24345 error = ret;
24271 break; 24346 break;
24272 } 24347 }
24273 tmpType = tmpType->baseType; 24348 tmpType = tmpType->baseType;
24274 } while ((tmpType != NULL) && (tmpType->type != XML_SCHEMA_TYPE_BASIC)); 24349 } while ((tmpType != NULL) && (tmpType->type != XML_SCHEMA_TYPE_BASIC));
24275 } 24350 }
24276 24351
24277 return (error); 24352 return (error);
24278 } 24353 }
24279 24354
24280 static xmlChar * 24355 static xmlChar *
24281 xmlSchemaNormalizeValue(xmlSchemaTypePtr type, 24356 xmlSchemaNormalizeValue(xmlSchemaTypePtr type,
24282 const xmlChar *value) 24357 const xmlChar *value)
24283 { 24358 {
24284 switch (xmlSchemaGetWhiteSpaceFacetValue(type)) {» 24359 switch (xmlSchemaGetWhiteSpaceFacetValue(type)) {
24285 case XML_SCHEMA_WHITESPACE_COLLAPSE: 24360 case XML_SCHEMA_WHITESPACE_COLLAPSE:
24286 return (xmlSchemaCollapseString(value)); 24361 return (xmlSchemaCollapseString(value));
24287 case XML_SCHEMA_WHITESPACE_REPLACE: 24362 case XML_SCHEMA_WHITESPACE_REPLACE:
24288 return (xmlSchemaWhiteSpaceReplace(value)); 24363 return (xmlSchemaWhiteSpaceReplace(value));
24289 default: 24364 default:
24290 return (NULL); 24365 return (NULL);
24291 } 24366 }
24292 } 24367 }
24293 24368
24294 static int 24369 static int
24295 xmlSchemaValidateQName(xmlSchemaValidCtxtPtr vctxt, 24370 xmlSchemaValidateQName(xmlSchemaValidCtxtPtr vctxt,
24296 const xmlChar *value, 24371 const xmlChar *value,
24297 xmlSchemaValPtr *val, 24372 xmlSchemaValPtr *val,
24298 int valNeeded) 24373 int valNeeded)
24299 { 24374 {
24300 int ret; 24375 int ret;
24301 const xmlChar *nsName; 24376 const xmlChar *nsName;
24302 xmlChar *local, *prefix = NULL; 24377 xmlChar *local, *prefix = NULL;
24303 24378
24304 ret = xmlValidateQName(value, 1); 24379 ret = xmlValidateQName(value, 1);
24305 if (ret != 0) { 24380 if (ret != 0) {
24306 if (ret == -1) { 24381 if (ret == -1) {
24307 VERROR_INT("xmlSchemaValidateQName", 24382 VERROR_INT("xmlSchemaValidateQName",
24308 "calling xmlValidateQName()"); 24383 "calling xmlValidateQName()");
24309 return (-1); 24384 return (-1);
24310 } 24385 }
24311 return( XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1); 24386 return( XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1);
24312 } 24387 }
24313 /* 24388 /*
24314 * NOTE: xmlSplitQName2 will always return a duplicated 24389 * NOTE: xmlSplitQName2 will always return a duplicated
24315 * strings. 24390 * strings.
24316 */ 24391 */
24317 local = xmlSplitQName2(value, &prefix); 24392 local = xmlSplitQName2(value, &prefix);
24318 if (local == NULL) 24393 if (local == NULL)
24319 local = xmlStrdup(value); 24394 local = xmlStrdup(value);
24320 /* 24395 /*
24321 * OPTIMIZE TODO: Use flags for: 24396 * OPTIMIZE TODO: Use flags for:
24322 * - is there any namespace binding? 24397 * - is there any namespace binding?
24323 * - is there a default namespace? 24398 * - is there a default namespace?
24324 */ 24399 */
24325 nsName = xmlSchemaLookupNamespace(vctxt, prefix); 24400 nsName = xmlSchemaLookupNamespace(vctxt, prefix);
24326 24401
24327 if (prefix != NULL) { 24402 if (prefix != NULL) {
24328 xmlFree(prefix); 24403 xmlFree(prefix);
24329 /* 24404 /*
24330 * A namespace must be found if the prefix is 24405 * A namespace must be found if the prefix is
24331 * NOT NULL. 24406 * NOT NULL.
24332 */ 24407 */
24333 if (nsName == NULL) { 24408 if (nsName == NULL) {
24334 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1; 24409 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
24335 xmlSchemaCustomErr(ACTXT_CAST vctxt, ret, NULL, 24410 xmlSchemaCustomErr(ACTXT_CAST vctxt, ret, NULL,
24336 WXS_BASIC_CAST xmlSchemaGetBuiltInType(XML_SCHEMAS_QNAME), 24411 WXS_BASIC_CAST xmlSchemaGetBuiltInType(XML_SCHEMAS_QNAME),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
24373 xmlChar *normValue = NULL; 24448 xmlChar *normValue = NULL;
24374 24449
24375 #define NORMALIZE(atype) \ 24450 #define NORMALIZE(atype) \
24376 if ((! isNormalized) && \ 24451 if ((! isNormalized) && \
24377 (normalize || (type->flags & XML_SCHEMAS_TYPE_NORMVALUENEEDED))) { \ 24452 (normalize || (type->flags & XML_SCHEMAS_TYPE_NORMVALUENEEDED))) { \
24378 normValue = xmlSchemaNormalizeValue(atype, value); \ 24453 normValue = xmlSchemaNormalizeValue(atype, value); \
24379 if (normValue != NULL) \ 24454 if (normValue != NULL) \
24380 value = normValue; \ 24455 value = normValue; \
24381 isNormalized = 1; \ 24456 isNormalized = 1; \
24382 } 24457 }
24383 24458
24384 if ((retVal != NULL) && (*retVal != NULL)) { 24459 if ((retVal != NULL) && (*retVal != NULL)) {
24385 xmlSchemaFreeValue(*retVal); 24460 xmlSchemaFreeValue(*retVal);
24386 *retVal = NULL; 24461 *retVal = NULL;
24387 } 24462 }
24388 /* 24463 /*
24389 * 3.14.4 Simple Type Definition Validation Rules 24464 * 3.14.4 Simple Type Definition Validation Rules
24390 * Validation Rule: String Valid 24465 * Validation Rule: String Valid
24391 */ 24466 */
24392 /* 24467 /*
24393 * 1 It is schema-valid with respect to that definition as defined 24468 * 1 It is schema-valid with respect to that definition as defined
24394 * by Datatype Valid in [XML Schemas: Datatypes]. 24469 * by Datatype Valid in [XML Schemas: Datatypes].
24395 */ 24470 */
24396 /* 24471 /*
24397 * 2.1 If The definition is ENTITY or is validly derived from ENTITY given 24472 * 2.1 If The definition is ENTITY or is validly derived from ENTITY given
24398 * the empty set, as defined in Type Derivation OK (Simple) (§3.14.6), then 24473 * the empty set, as defined in Type Derivation OK (Simple) (�3.14.6), then
24399 * the string must be a ·declared entity name·. 24474 * the string must be a �declared entity name�.
24400 */ 24475 */
24401 /* 24476 /*
24402 * 2.2 If The definition is ENTITIES or is validly derived from ENTITIES 24477 * 2.2 If The definition is ENTITIES or is validly derived from ENTITIES
24403 * given the empty set, as defined in Type Derivation OK (Simple) (§3.14.6), 24478 * given the empty set, as defined in Type Derivation OK (Simple) (�3.14.6) ,
24404 * then every whitespace-delimited substring of the string must be a ·declare d 24479 * then every whitespace-delimited substring of the string must be a �decla red
24405 * entity name·. 24480 * entity name�.
24406 */ 24481 */
24407 /* 24482 /*
24408 * 2.3 otherwise no further condition applies. 24483 * 2.3 otherwise no further condition applies.
24409 */ 24484 */
24410 if ((! valNeeded) && (type->flags & XML_SCHEMAS_TYPE_FACETSNEEDVALUE)) 24485 if ((! valNeeded) && (type->flags & XML_SCHEMAS_TYPE_FACETSNEEDVALUE))
24411 valNeeded = 1; 24486 valNeeded = 1;
24412 if (value == NULL) 24487 if (value == NULL)
24413 value = BAD_CAST ""; 24488 value = BAD_CAST "";
24414 if (WXS_IS_ANY_SIMPLE_TYPE(type) || WXS_IS_ATOMIC(type)) { 24489 if (WXS_IS_ANY_SIMPLE_TYPE(type) || WXS_IS_ATOMIC(type)) {
24415 xmlSchemaTypePtr biType; /* The built-in type. */ 24490 xmlSchemaTypePtr biType; /* The built-in type. */
24416 /* 24491 /*
24417 » * SPEC (1.2.1) "if {variety} is ·atomic· then the string must ·match· 24492 » * SPEC (1.2.1) "if {variety} is �atomic� then the string must �mat ch�
24418 » * a literal in the ·lexical space· of {base type definition}" 24493 » * a literal in the �lexical space� of {base type definition}"
24419 */ 24494 */
24420 /* 24495 /*
24421 * Whitespace-normalize. 24496 * Whitespace-normalize.
24422 */ 24497 */
24423 NORMALIZE(type); 24498 NORMALIZE(type);
24424 if (type->type != XML_SCHEMA_TYPE_BASIC) { 24499 if (type->type != XML_SCHEMA_TYPE_BASIC) {
24425 /* 24500 /*
24426 * Get the built-in type. 24501 * Get the built-in type.
24427 */ 24502 */
24428 biType = type->baseType; 24503 biType = type->baseType;
24429 while ((biType != NULL) && 24504 while ((biType != NULL) &&
24430 (biType->type != XML_SCHEMA_TYPE_BASIC)) 24505 (biType->type != XML_SCHEMA_TYPE_BASIC))
24431 biType = biType->baseType; 24506 biType = biType->baseType;
24432 24507
24433 if (biType == NULL) { 24508 if (biType == NULL) {
24434 AERROR_INT("xmlSchemaVCheckCVCSimpleType", 24509 AERROR_INT("xmlSchemaVCheckCVCSimpleType",
24435 "could not get the built-in type"); 24510 "could not get the built-in type");
24436 goto internal_error; 24511 goto internal_error;
24437 } 24512 }
24438 } else 24513 } else
24439 biType = type; 24514 biType = type;
24440 /* 24515 /*
24441 * NOTATIONs need to be processed here, since they need 24516 * NOTATIONs need to be processed here, since they need
24442 * to lookup in the hashtable of NOTATION declarations of the schema. 24517 * to lookup in the hashtable of NOTATION declarations of the schema.
24443 */ 24518 */
24444 » if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR) {» 24519 » if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR) {
24445 » switch (biType->builtInType) {» » 24520 » switch (biType->builtInType) {
24446 » » case XML_SCHEMAS_NOTATION:» » 24521 » » case XML_SCHEMAS_NOTATION:
24447 ret = xmlSchemaValidateNotation( 24522 ret = xmlSchemaValidateNotation(
24448 (xmlSchemaValidCtxtPtr) actxt, 24523 (xmlSchemaValidCtxtPtr) actxt,
24449 ((xmlSchemaValidCtxtPtr) actxt)->schema, 24524 ((xmlSchemaValidCtxtPtr) actxt)->schema,
24450 NULL, value, &val, valNeeded); 24525 NULL, value, &val, valNeeded);
24451 break; 24526 break;
24452 case XML_SCHEMAS_QNAME: 24527 case XML_SCHEMAS_QNAME:
24453 ret = xmlSchemaValidateQName((xmlSchemaValidCtxtPtr) actxt, 24528 ret = xmlSchemaValidateQName((xmlSchemaValidCtxtPtr) actxt,
24454 value, &val, valNeeded); 24529 value, &val, valNeeded);
24455 break; 24530 break;
24456 default: 24531 default:
24457 /* ws = xmlSchemaGetWhiteSpaceFacetValue(type); */ 24532 /* ws = xmlSchemaGetWhiteSpaceFacetValue(type); */
24458 if (valNeeded) 24533 if (valNeeded)
24459 ret = xmlSchemaValPredefTypeNodeNoNorm(biType, 24534 ret = xmlSchemaValPredefTypeNodeNoNorm(biType,
24460 » » » value, &val, NULL); 24535 » » » value, &val, node);
24461 else 24536 else
24462 ret = xmlSchemaValPredefTypeNodeNoNorm(biType, 24537 ret = xmlSchemaValPredefTypeNodeNoNorm(biType,
24463 » » » value, NULL, NULL); 24538 » » » value, NULL, node);
24464 break; 24539 break;
24465 } 24540 }
24466 » } else if (actxt->type == XML_SCHEMA_CTXT_PARSER) {» 24541 » } else if (actxt->type == XML_SCHEMA_CTXT_PARSER) {
24467 » switch (biType->builtInType) {» » 24542 » switch (biType->builtInType) {
24468 case XML_SCHEMAS_NOTATION: 24543 case XML_SCHEMAS_NOTATION:
24469 ret = xmlSchemaValidateNotation(NULL, 24544 ret = xmlSchemaValidateNotation(NULL,
24470 ((xmlSchemaParserCtxtPtr) actxt)->schema, node, 24545 ((xmlSchemaParserCtxtPtr) actxt)->schema, node,
24471 value, &val, valNeeded); 24546 value, &val, valNeeded);
24472 break; 24547 break;
24473 default: 24548 default:
24474 /* ws = xmlSchemaGetWhiteSpaceFacetValue(type); */ 24549 /* ws = xmlSchemaGetWhiteSpaceFacetValue(type); */
24475 if (valNeeded) 24550 if (valNeeded)
24476 ret = xmlSchemaValPredefTypeNodeNoNorm(biType, 24551 ret = xmlSchemaValPredefTypeNodeNoNorm(biType,
24477 value, &val, node); 24552 value, &val, node);
24478 else 24553 else
24479 ret = xmlSchemaValPredefTypeNodeNoNorm(biType, 24554 ret = xmlSchemaValPredefTypeNodeNoNorm(biType,
24480 value, NULL, node); 24555 value, NULL, node);
24481 break; 24556 break;
24482 » }» 24557 » }
24483 } else { 24558 } else {
24484 /* 24559 /*
24485 * Validation via a public API is not implemented yet. 24560 * Validation via a public API is not implemented yet.
24486 */ 24561 */
24487 TODO 24562 TODO
24488 goto internal_error; 24563 goto internal_error;
24489 } 24564 }
24490 if (ret != 0) { 24565 if (ret != 0) {
24491 if (ret < 0) { 24566 if (ret < 0) {
24492 AERROR_INT("xmlSchemaVCheckCVCSimpleType", 24567 AERROR_INT("xmlSchemaVCheckCVCSimpleType",
24493 "validating against a built-in type"); 24568 "validating against a built-in type");
24494 goto internal_error; 24569 goto internal_error;
24495 } 24570 }
24496 if (WXS_IS_LIST(type)) 24571 if (WXS_IS_LIST(type))
24497 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2; 24572 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
24498 else 24573 else
24499 » » ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;» 24574 » » ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
24500 } 24575 }
24501 if ((ret == 0) && (type->flags & XML_SCHEMAS_TYPE_HAS_FACETS)) { 24576 if ((ret == 0) && (type->flags & XML_SCHEMAS_TYPE_HAS_FACETS)) {
24502 /* 24577 /*
24503 * Check facets. 24578 * Check facets.
24504 */ 24579 */
24505 ret = xmlSchemaValidateFacets(actxt, node, type, 24580 ret = xmlSchemaValidateFacets(actxt, node, type,
24506 (xmlSchemaValType) biType->builtInType, value, val, 24581 (xmlSchemaValType) biType->builtInType, value, val,
24507 0, fireErrors); 24582 0, fireErrors);
24508 if (ret != 0) { 24583 if (ret != 0) {
24509 if (ret < 0) { 24584 if (ret < 0) {
24510 AERROR_INT("xmlSchemaVCheckCVCSimpleType", 24585 AERROR_INT("xmlSchemaVCheckCVCSimpleType",
24511 "validating facets of atomic simple type"); 24586 "validating facets of atomic simple type");
24512 goto internal_error; 24587 goto internal_error;
24513 } 24588 }
24514 » » if (WXS_IS_LIST(type)) 24589 » » if (WXS_IS_LIST(type))
24515 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2; 24590 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
24516 else 24591 else
24517 » » ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;»» 24592 » » ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
24518 } 24593 }
24519 } 24594 }
24520 if (fireErrors && (ret > 0)) 24595 if (fireErrors && (ret > 0))
24521 xmlSchemaSimpleTypeErr(actxt, ret, node, value, type, 1); 24596 xmlSchemaSimpleTypeErr(actxt, ret, node, value, type, 1);
24522 } else if (WXS_IS_LIST(type)) { 24597 } else if (WXS_IS_LIST(type)) {
24523 24598
24524 xmlSchemaTypePtr itemType; 24599 xmlSchemaTypePtr itemType;
24525 const xmlChar *cur, *end; 24600 const xmlChar *cur, *end;
24526 xmlChar *tmpValue = NULL; 24601 xmlChar *tmpValue = NULL;
24527 unsigned long len = 0; 24602 unsigned long len = 0;
24528 xmlSchemaValPtr prevVal = NULL, curVal = NULL; 24603 xmlSchemaValPtr prevVal = NULL, curVal = NULL;
24529 » /* 1.2.2 if {variety} is ·list· then the string must be a sequence 24604 » /* 1.2.2 if {variety} is �list� then the string must be a sequence
24530 » * of white space separated tokens, each of which ·match·es a literal 24605 » * of white space separated tokens, each of which �match�es a literal
24531 » * in the ·lexical space· of {item type definition} 24606 » * in the �lexical space� of {item type definition}
24532 */ 24607 */
24533 /* 24608 /*
24534 * Note that XML_SCHEMAS_TYPE_NORMVALUENEEDED will be set if 24609 * Note that XML_SCHEMAS_TYPE_NORMVALUENEEDED will be set if
24535 * the list type has an enum or pattern facet. 24610 * the list type has an enum or pattern facet.
24536 */ 24611 */
24537 NORMALIZE(type); 24612 NORMALIZE(type);
24538 /* 24613 /*
24539 * VAL TODO: Optimize validation of empty values. 24614 * VAL TODO: Optimize validation of empty values.
24540 * VAL TODO: We do not have computed values for lists. 24615 * VAL TODO: We do not have computed values for lists.
24541 */ 24616 */
24542 » itemType = WXS_LIST_ITEMTYPE(type);» 24617 » itemType = WXS_LIST_ITEMTYPE(type);
24543 cur = value; 24618 cur = value;
24544 do { 24619 do {
24545 while (IS_BLANK_CH(*cur)) 24620 while (IS_BLANK_CH(*cur))
24546 cur++; 24621 cur++;
24547 end = cur; 24622 end = cur;
24548 while ((*end != 0) && (!(IS_BLANK_CH(*end)))) 24623 while ((*end != 0) && (!(IS_BLANK_CH(*end))))
24549 end++; 24624 end++;
24550 if (end == cur) 24625 if (end == cur)
24551 break; 24626 break;
24552 tmpValue = xmlStrndup(cur, end - cur); 24627 tmpValue = xmlStrndup(cur, end - cur);
(...skipping 18 matching lines...) Expand all
24571 curVal = NULL; 24646 curVal = NULL;
24572 } 24647 }
24573 if (ret != 0) { 24648 if (ret != 0) {
24574 if (ret < 0) { 24649 if (ret < 0) {
24575 AERROR_INT("xmlSchemaVCheckCVCSimpleType", 24650 AERROR_INT("xmlSchemaVCheckCVCSimpleType",
24576 "validating an item of list simple type"); 24651 "validating an item of list simple type");
24577 goto internal_error; 24652 goto internal_error;
24578 } 24653 }
24579 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2; 24654 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
24580 break; 24655 break;
24581 » }» 24656 » }
24582 cur = end; 24657 cur = end;
24583 } while (*cur != 0); 24658 } while (*cur != 0);
24584 FREE_AND_NULL(tmpValue); 24659 FREE_AND_NULL(tmpValue);
24585 if ((ret == 0) && (type->flags & XML_SCHEMAS_TYPE_HAS_FACETS)) { 24660 if ((ret == 0) && (type->flags & XML_SCHEMAS_TYPE_HAS_FACETS)) {
24586 /* 24661 /*
24587 * Apply facets (pattern, enumeration). 24662 * Apply facets (pattern, enumeration).
24588 */ 24663 */
24589 ret = xmlSchemaValidateFacets(actxt, node, type, 24664 ret = xmlSchemaValidateFacets(actxt, node, type,
24590 XML_SCHEMAS_UNKNOWN, value, val, 24665 XML_SCHEMAS_UNKNOWN, value, val,
24591 len, fireErrors); 24666 len, fireErrors);
24592 if (ret != 0) { 24667 if (ret != 0) {
24593 if (ret < 0) { 24668 if (ret < 0) {
24594 AERROR_INT("xmlSchemaVCheckCVCSimpleType", 24669 AERROR_INT("xmlSchemaVCheckCVCSimpleType",
24595 "validating facets of list simple type"); 24670 "validating facets of list simple type");
24596 goto internal_error; 24671 goto internal_error;
24597 } 24672 }
24598 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2; 24673 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
24599 } 24674 }
24600 } 24675 }
24601 if (fireErrors && (ret > 0)) { 24676 if (fireErrors && (ret > 0)) {
24602 » /* 24677 » /*
24603 * Report the normalized value. 24678 * Report the normalized value.
24604 */ 24679 */
24605 normalize = 1; 24680 normalize = 1;
24606 NORMALIZE(type); 24681 NORMALIZE(type);
24607 xmlSchemaSimpleTypeErr(actxt, ret, node, value, type, 1); 24682 xmlSchemaSimpleTypeErr(actxt, ret, node, value, type, 1);
24608 } 24683 }
24609 } else if (WXS_IS_UNION(type)) { 24684 } else if (WXS_IS_UNION(type)) {
24610 xmlSchemaTypeLinkPtr memberLink; 24685 xmlSchemaTypeLinkPtr memberLink;
24611 /* 24686 /*
24612 » * TODO: For all datatypes ·derived· by ·union· whiteSpace does 24687 » * TODO: For all datatypes �derived� by �union� whiteSpace does
24613 » * not apply directly; however, the normalization behavior of ·union· 24688 » * not apply directly; however, the normalization behavior of �union�
24614 * types is controlled by the value of whiteSpace on that one of the 24689 * types is controlled by the value of whiteSpace on that one of the
24615 » * ·memberTypes· against which the ·union· is successfully validated. 24690 » * �memberTypes� against which the �union� is successfully valida ted.
24616 * 24691 *
24617 * This means that the value is normalized by the first validating 24692 * This means that the value is normalized by the first validating
24618 * member type, then the facets of the union type are applied. This 24693 * member type, then the facets of the union type are applied. This
24619 * needs changing of the value! 24694 * needs changing of the value!
24620 */ 24695 */
24621 24696
24622 /* 24697 /*
24623 » * 1.2.3 if {variety} is ·union· then the string must ·match· a 24698 » * 1.2.3 if {variety} is �union� then the string must �match� a
24624 » * literal in the ·lexical space· of at least one member of 24699 » * literal in the �lexical space� of at least one member of
24625 * {member type definitions} 24700 * {member type definitions}
24626 */ 24701 */
24627 memberLink = xmlSchemaGetUnionSimpleTypeMemberTypes(type); 24702 memberLink = xmlSchemaGetUnionSimpleTypeMemberTypes(type);
24628 if (memberLink == NULL) { 24703 if (memberLink == NULL) {
24629 AERROR_INT("xmlSchemaVCheckCVCSimpleType", 24704 AERROR_INT("xmlSchemaVCheckCVCSimpleType",
24630 "union simple type has no member types"); 24705 "union simple type has no member types");
24631 goto internal_error; 24706 goto internal_error;
24632 » }» 24707 » }
24633 /* 24708 /*
24634 * Always normalize union type values, since we currently 24709 * Always normalize union type values, since we currently
24635 * cannot store the whitespace information with the value 24710 * cannot store the whitespace information with the value
24636 * itself; otherwise a later value-comparison would be 24711 * itself; otherwise a later value-comparison would be
24637 * not possible. 24712 * not possible.
24638 */ 24713 */
24639 while (memberLink != NULL) { 24714 while (memberLink != NULL) {
24640 » if (valNeeded) 24715 » if (valNeeded)
24641 ret = xmlSchemaVCheckCVCSimpleType(actxt, node, 24716 ret = xmlSchemaVCheckCVCSimpleType(actxt, node,
24642 memberLink->type, value, &val, 0, 1, 0); 24717 memberLink->type, value, &val, 0, 1, 0);
24643 else 24718 else
24644 ret = xmlSchemaVCheckCVCSimpleType(actxt, node, 24719 ret = xmlSchemaVCheckCVCSimpleType(actxt, node,
24645 memberLink->type, value, NULL, 0, 1, 0); 24720 memberLink->type, value, NULL, 0, 1, 0);
24646 if (ret <= 0) 24721 if (ret <= 0)
24647 break; 24722 break;
24648 memberLink = memberLink->next; 24723 memberLink = memberLink->next;
24649 } 24724 }
24650 if (ret != 0) { 24725 if (ret != 0) {
24651 if (ret < 0) { 24726 if (ret < 0) {
24652 AERROR_INT("xmlSchemaVCheckCVCSimpleType", 24727 AERROR_INT("xmlSchemaVCheckCVCSimpleType",
24653 "validating members of union simple type"); 24728 "validating members of union simple type");
24654 goto internal_error; 24729 goto internal_error;
24655 } 24730 }
24656 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3; 24731 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3;
24657 } 24732 }
24658 /* 24733 /*
24659 * Apply facets (pattern, enumeration). 24734 * Apply facets (pattern, enumeration).
24660 */ 24735 */
24661 if ((ret == 0) && (type->flags & XML_SCHEMAS_TYPE_HAS_FACETS)) { 24736 if ((ret == 0) && (type->flags & XML_SCHEMAS_TYPE_HAS_FACETS)) {
24662 /* 24737 /*
24663 » * The normalization behavior of ·union· types is controlled by 24738 » * The normalization behavior of �union� types is controlled by
24664 » * the value of whiteSpace on that one of the ·memberTypes· 24739 » * the value of whiteSpace on that one of the �memberTypes�
24665 » * against which the ·union· is successfully validated. 24740 » * against which the �union� is successfully validated.
24666 */ 24741 */
24667 NORMALIZE(memberLink->type); 24742 NORMALIZE(memberLink->type);
24668 ret = xmlSchemaValidateFacets(actxt, node, type, 24743 ret = xmlSchemaValidateFacets(actxt, node, type,
24669 XML_SCHEMAS_UNKNOWN, value, val, 24744 XML_SCHEMAS_UNKNOWN, value, val,
24670 0, fireErrors); 24745 0, fireErrors);
24671 if (ret != 0) { 24746 if (ret != 0) {
24672 if (ret < 0) { 24747 if (ret < 0) {
24673 AERROR_INT("xmlSchemaVCheckCVCSimpleType", 24748 AERROR_INT("xmlSchemaVCheckCVCSimpleType",
24674 "validating facets of union simple type"); 24749 "validating facets of union simple type");
24675 goto internal_error; 24750 goto internal_error;
24676 } 24751 }
24677 » » ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3;» » 24752 » » ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3;
24678 } 24753 }
24679 } 24754 }
24680 if (fireErrors && (ret > 0)) 24755 if (fireErrors && (ret > 0))
24681 xmlSchemaSimpleTypeErr(actxt, ret, node, value, type, 1); 24756 xmlSchemaSimpleTypeErr(actxt, ret, node, value, type, 1);
24682 } 24757 }
24683 24758
24684 if (normValue != NULL) 24759 if (normValue != NULL)
24685 xmlFree(normValue); 24760 xmlFree(normValue);
24686 if (ret == 0) { 24761 if (ret == 0) {
24687 if (retVal != NULL) 24762 if (retVal != NULL)
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
24815 xmlSchemaFormatQName(&str, nsName, local), NULL); 24890 xmlSchemaFormatQName(&str, nsName, local), NULL);
24816 FREE_AND_NULL(str); 24891 FREE_AND_NULL(str);
24817 ret = vctxt->err; 24892 ret = vctxt->err;
24818 goto exit; 24893 goto exit;
24819 } 24894 }
24820 if (elemDecl != NULL) { 24895 if (elemDecl != NULL) {
24821 int set = 0; 24896 int set = 0;
24822 24897
24823 /* 24898 /*
24824 * SPEC cvc-elt (3.3.4) : (4.3) (Type Derivation OK) 24899 * SPEC cvc-elt (3.3.4) : (4.3) (Type Derivation OK)
24825 » * "The ·local type definition· must be validly 24900 » * "The �local type definition� must be validly
24826 * derived from the {type definition} given the union of 24901 * derived from the {type definition} given the union of
24827 * the {disallowed substitutions} and the {type definition}'s 24902 * the {disallowed substitutions} and the {type definition}'s
24828 * {prohibited substitutions}, as defined in 24903 * {prohibited substitutions}, as defined in
24829 » * Type Derivation OK (Complex) (§3.4.6) 24904 » * Type Derivation OK (Complex) (�3.4.6)
24830 * (if it is a complex type definition), 24905 * (if it is a complex type definition),
24831 * or given {disallowed substitutions} as defined in Type 24906 * or given {disallowed substitutions} as defined in Type
24832 » * Derivation OK (Simple) (§3.14.6) (if it is a simple type 24907 » * Derivation OK (Simple) (�3.14.6) (if it is a simple type
24833 * definition)." 24908 * definition)."
24834 * 24909 *
24835 * {disallowed substitutions}: the "block" on the element decl. 24910 * {disallowed substitutions}: the "block" on the element decl.
24836 * {prohibited substitutions}: the "block" on the type def. 24911 * {prohibited substitutions}: the "block" on the type def.
24837 */ 24912 */
24838 /* 24913 /*
24839 * OPTIMIZE TODO: We could map types already evaluated 24914 * OPTIMIZE TODO: We could map types already evaluated
24840 * to be validly derived from other types to avoid checking 24915 * to be validly derived from other types to avoid checking
24841 * this over and over for the same types. 24916 * this over and over for the same types.
24842 */ 24917 */
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
25082 * 3.2.4 Attribute Declaration Validation Rules 25157 * 3.2.4 Attribute Declaration Validation Rules
25083 * Validation Rule: Attribute Locally Valid (cvc-attribute) 25158 * Validation Rule: Attribute Locally Valid (cvc-attribute)
25084 * Attribute Locally Valid (Use) (cvc-au) 25159 * Attribute Locally Valid (Use) (cvc-au)
25085 * 25160 *
25086 * Only "assessed" attribute information items will be visible to 25161 * Only "assessed" attribute information items will be visible to
25087 * IDCs. I.e. not "lax" (without declaration) and "skip" wild attributes. 25162 * IDCs. I.e. not "lax" (without declaration) and "skip" wild attributes.
25088 */ 25163 */
25089 static int 25164 static int
25090 xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) 25165 xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
25091 { 25166 {
25092 xmlSchemaTypePtr type = vctxt->inode->typeDef; 25167 xmlSchemaTypePtr type = vctxt->inode->typeDef;
25093 xmlSchemaItemListPtr attrUseList; 25168 xmlSchemaItemListPtr attrUseList;
25094 xmlSchemaAttributeUsePtr attrUse = NULL; 25169 xmlSchemaAttributeUsePtr attrUse = NULL;
25095 xmlSchemaAttributePtr attrDecl = NULL; 25170 xmlSchemaAttributePtr attrDecl = NULL;
25096 xmlSchemaAttrInfoPtr iattr, tmpiattr; 25171 xmlSchemaAttrInfoPtr iattr, tmpiattr;
25097 int i, j, found, nbAttrs, nbUses; 25172 int i, j, found, nbAttrs, nbUses;
25098 int xpathRes = 0, res, wildIDs = 0, fixed; 25173 int xpathRes = 0, res, wildIDs = 0, fixed;
25099 xmlNodePtr defAttrOwnerElem = NULL; 25174 xmlNodePtr defAttrOwnerElem = NULL;
25100 25175
25101 /* 25176 /*
25102 * SPEC (cvc-attribute) 25177 * SPEC (cvc-attribute)
25103 * (1) "The declaration must not be ·absent· (see Missing 25178 * (1) "The declaration must not be �absent� (see Missing
25104 * Sub-components (§5.3) for how this can fail to be 25179 * Sub-components (�5.3) for how this can fail to be
25105 * the case)." 25180 * the case)."
25106 * (2) "Its {type definition} must not be absent." 25181 * (2) "Its {type definition} must not be absent."
25107 * 25182 *
25108 * NOTE (1) + (2): This is not handled here, since we currently do not 25183 * NOTE (1) + (2): This is not handled here, since we currently do not
25109 * allow validation against schemas which have missing sub-components. 25184 * allow validation against schemas which have missing sub-components.
25110 * 25185 *
25111 * SPEC (cvc-complex-type) 25186 * SPEC (cvc-complex-type)
25112 * (3) "For each attribute information item in the element information 25187 * (3) "For each attribute information item in the element information
25113 * item's [attributes] excepting those whose [namespace name] is 25188 * item's [attributes] excepting those whose [namespace name] is
25114 * identical to http://www.w3.org/2001/XMLSchema-instance and whose 25189 * identical to http://www.w3.org/2001/XMLSchema-instance and whose
(...skipping 29 matching lines...) Expand all
25144 continue; 25219 continue;
25145 if (!xmlStrEqual(iattr->nsName, attrDecl->targetNamespace)) 25220 if (!xmlStrEqual(iattr->nsName, attrDecl->targetNamespace))
25146 continue; 25221 continue;
25147 found = 1; 25222 found = 1;
25148 /* 25223 /*
25149 * SPEC (cvc-complex-type) 25224 * SPEC (cvc-complex-type)
25150 * (3.1) "If there is among the {attribute uses} an attribute 25225 * (3.1) "If there is among the {attribute uses} an attribute
25151 * use with an {attribute declaration} whose {name} matches 25226 * use with an {attribute declaration} whose {name} matches
25152 * the attribute information item's [local name] and whose 25227 * the attribute information item's [local name] and whose
25153 * {target namespace} is identical to the attribute information 25228 * {target namespace} is identical to the attribute information
25154 » * item's [namespace name] (where an ·absent· {target namespace} 25229 » * item's [namespace name] (where an �absent� {target namespace}
25155 * is taken to be identical to a [namespace name] with no value), 25230 * is taken to be identical to a [namespace name] with no value),
25156 » * then the attribute information must be ·valid· with respect 25231 » * then the attribute information must be �valid� with respect
25157 * to that attribute use as per Attribute Locally Valid (Use) 25232 * to that attribute use as per Attribute Locally Valid (Use)
25158 » * (§3.5.4). In this case the {attribute declaration} of that 25233 » * (�3.5.4). In this case the {attribute declaration} of that
25159 » * attribute use is the ·context-determined declaration· for the 25234 » * attribute use is the �context-determined declaration� for the
25160 * attribute information item with respect to Schema-Validity 25235 * attribute information item with respect to Schema-Validity
25161 » * Assessment (Attribute) (§3.2.4) and 25236 » * Assessment (Attribute) (�3.2.4) and
25162 » * Assessment Outcome (Attribute) (§3.2.5). 25237 » * Assessment Outcome (Attribute) (�3.2.5).
25163 */ 25238 */
25164 iattr->state = XML_SCHEMAS_ATTR_ASSESSED; 25239 iattr->state = XML_SCHEMAS_ATTR_ASSESSED;
25165 iattr->use = attrUse; 25240 iattr->use = attrUse;
25166 /* 25241 /*
25167 * Context-determined declaration. 25242 * Context-determined declaration.
25168 */ 25243 */
25169 iattr->decl = attrDecl; 25244 iattr->decl = attrDecl;
25170 iattr->typeDef = attrDecl->subtypes; 25245 iattr->typeDef = attrDecl->subtypes;
25171 break; 25246 break;
25172 } 25247 }
(...skipping 13 matching lines...) Expand all
25186 */ 25261 */
25187 tmpiattr = xmlSchemaGetFreshAttrInfo(vctxt); 25262 tmpiattr = xmlSchemaGetFreshAttrInfo(vctxt);
25188 if (tmpiattr == NULL) { 25263 if (tmpiattr == NULL) {
25189 VERROR_INT( 25264 VERROR_INT(
25190 "xmlSchemaVAttributesComplex", 25265 "xmlSchemaVAttributesComplex",
25191 "calling xmlSchemaGetFreshAttrInfo()"); 25266 "calling xmlSchemaGetFreshAttrInfo()");
25192 return (-1); 25267 return (-1);
25193 } 25268 }
25194 tmpiattr->state = XML_SCHEMAS_ATTR_ERR_MISSING; 25269 tmpiattr->state = XML_SCHEMAS_ATTR_ERR_MISSING;
25195 tmpiattr->use = attrUse; 25270 tmpiattr->use = attrUse;
25196 » tmpiattr->decl = attrDecl;» 25271 » tmpiattr->decl = attrDecl;
25197 } else if ((attrUse->occurs == XML_SCHEMAS_ATTR_USE_OPTIONAL) && 25272 } else if ((attrUse->occurs == XML_SCHEMAS_ATTR_USE_OPTIONAL) &&
25198 ((attrUse->defValue != NULL) || 25273 ((attrUse->defValue != NULL) ||
25199 (attrDecl->defValue != NULL))) { 25274 (attrDecl->defValue != NULL))) {
25200 /* 25275 /*
25201 * Handle non-existent, optional, default/fixed attributes. 25276 * Handle non-existent, optional, default/fixed attributes.
25202 */ 25277 */
25203 tmpiattr = xmlSchemaGetFreshAttrInfo(vctxt); 25278 tmpiattr = xmlSchemaGetFreshAttrInfo(vctxt);
25204 if (tmpiattr == NULL) { 25279 if (tmpiattr == NULL) {
25205 VERROR_INT( 25280 VERROR_INT(
25206 "xmlSchemaVAttributesComplex", 25281 "xmlSchemaVAttributesComplex",
25207 "calling xmlSchemaGetFreshAttrInfo()"); 25282 "calling xmlSchemaGetFreshAttrInfo()");
25208 return (-1); 25283 return (-1);
25209 } 25284 }
25210 tmpiattr->state = XML_SCHEMAS_ATTR_DEFAULT; 25285 tmpiattr->state = XML_SCHEMAS_ATTR_DEFAULT;
25211 tmpiattr->use = attrUse; 25286 tmpiattr->use = attrUse;
25212 tmpiattr->decl = attrDecl; 25287 tmpiattr->decl = attrDecl;
25213 tmpiattr->typeDef = attrDecl->subtypes; 25288 tmpiattr->typeDef = attrDecl->subtypes;
25214 tmpiattr->localName = attrDecl->name; 25289 tmpiattr->localName = attrDecl->name;
25215 tmpiattr->nsName = attrDecl->targetNamespace; 25290 tmpiattr->nsName = attrDecl->targetNamespace;
25216 } 25291 }
25217 } 25292 }
25218 25293
25219 if (vctxt->nbAttrInfos == 0) 25294 if (vctxt->nbAttrInfos == 0)
25220 return (0); 25295 return (0);
25221 nbUses = vctxt->nbAttrInfos;
25222 /* 25296 /*
25223 * Validate against the wildcard. 25297 * Validate against the wildcard.
25224 */ 25298 */
25225 if (type->attributeWildcard != NULL) { 25299 if (type->attributeWildcard != NULL) {
25226 /* 25300 /*
25227 * SPEC (cvc-complex-type) 25301 * SPEC (cvc-complex-type)
25228 * (3.2.1) "There must be an {attribute wildcard}." 25302 * (3.2.1) "There must be an {attribute wildcard}."
25229 */ 25303 */
25230 for (i = 0; i < nbAttrs; i++) { 25304 for (i = 0; i < nbAttrs; i++) {
25231 iattr = vctxt->attrInfos[i]; 25305 iattr = vctxt->attrInfos[i];
25232 /* 25306 /*
25233 * SPEC (cvc-complex-type) (3) 25307 * SPEC (cvc-complex-type) (3)
25234 * Skip meta attributes. 25308 * Skip meta attributes.
25235 */ 25309 */
25236 if (iattr->state != XML_SCHEMAS_ATTR_UNKNOWN) 25310 if (iattr->state != XML_SCHEMAS_ATTR_UNKNOWN)
25237 continue; 25311 continue;
25238 /* 25312 /*
25239 * SPEC (cvc-complex-type) 25313 * SPEC (cvc-complex-type)
25240 » * (3.2.2) "The attribute information item must be ·valid· with 25314 » * (3.2.2) "The attribute information item must be �valid� with
25241 » * respect to it as defined in Item Valid (Wildcard) (§3.10.4)." 25315 » * respect to it as defined in Item Valid (Wildcard) (�3.10.4)."
25242 * 25316 *
25243 * SPEC Item Valid (Wildcard) (cvc-wildcard) 25317 * SPEC Item Valid (Wildcard) (cvc-wildcard)
25244 » * "... its [namespace name] must be ·valid· with respect to 25318 » * "... its [namespace name] must be �valid� with respect to
25245 * the wildcard constraint, as defined in Wildcard allows 25319 * the wildcard constraint, as defined in Wildcard allows
25246 » * Namespace Name (§3.10.4)." 25320 » * Namespace Name (�3.10.4)."
25247 */ 25321 */
25248 if (xmlSchemaCheckCVCWildcardNamespace(type->attributeWildcard, 25322 if (xmlSchemaCheckCVCWildcardNamespace(type->attributeWildcard,
25249 iattr->nsName) == 0) { 25323 iattr->nsName) == 0) {
25250 /* 25324 /*
25251 * Handle processContents. 25325 * Handle processContents.
25252 * 25326 *
25253 * SPEC (cvc-wildcard): 25327 * SPEC (cvc-wildcard):
25254 * processContents | context-determined declaration: 25328 * processContents | context-determined declaration:
25255 * "strict" "mustFind" 25329 * "strict" "mustFind"
25256 * "lax" "none" 25330 * "lax" "none"
(...skipping 15 matching lines...) Expand all
25272 * Find an attribute declaration. 25346 * Find an attribute declaration.
25273 */ 25347 */
25274 iattr->decl = xmlSchemaGetAttributeDecl(vctxt->schema, 25348 iattr->decl = xmlSchemaGetAttributeDecl(vctxt->schema,
25275 iattr->localName, iattr->nsName); 25349 iattr->localName, iattr->nsName);
25276 if (iattr->decl != NULL) { 25350 if (iattr->decl != NULL) {
25277 iattr->state = XML_SCHEMAS_ATTR_ASSESSED; 25351 iattr->state = XML_SCHEMAS_ATTR_ASSESSED;
25278 /* 25352 /*
25279 * SPEC (cvc-complex-type) 25353 * SPEC (cvc-complex-type)
25280 * (5) "Let [Definition:] the wild IDs be the set of 25354 * (5) "Let [Definition:] the wild IDs be the set of
25281 * all attribute information item to which clause 3.2 25355 * all attribute information item to which clause 3.2
25282 » » * applied and whose ·validation· resulted in a 25356 » » * applied and whose �validation� resulted in a
25283 » » * ·context-determined declaration· of mustFind or no 25357 » » * �context-determined declaration� of mustFind or no
25284 » » * ·context-determined declaration· at all, and whose 25358 » » * �context-determined declaration� at all, and whose
25285 * [local name] and [namespace name] resolve (as 25359 * [local name] and [namespace name] resolve (as
25286 » » * defined by QName resolution (Instance) (§3.15.4)) to 25360 » » * defined by QName resolution (Instance) (�3.15.4)) to
25287 * an attribute declaration whose {type definition} is 25361 * an attribute declaration whose {type definition} is
25288 * or is derived from ID. Then all of the following 25362 * or is derived from ID. Then all of the following
25289 * must be true:" 25363 * must be true:"
25290 */ 25364 */
25291 iattr->typeDef = WXS_ATTR_TYPEDEF(iattr->decl); 25365 iattr->typeDef = WXS_ATTR_TYPEDEF(iattr->decl);
25292 if (xmlSchemaIsDerivedFromBuiltInType( 25366 if (xmlSchemaIsDerivedFromBuiltInType(
25293 iattr->typeDef, XML_SCHEMAS_ID)) { 25367 iattr->typeDef, XML_SCHEMAS_ID)) {
25294 /* 25368 /*
25295 * SPEC (5.1) "There must be no more than one 25369 * SPEC (5.1) "There must be no more than one
25296 » » » * item in ·wild IDs·." 25370 » » » * item in �wild IDs�."
25297 */ 25371 */
25298 if (wildIDs != 0) { 25372 if (wildIDs != 0) {
25299 /* VAL TODO */ 25373 /* VAL TODO */
25300 iattr->state = XML_SCHEMAS_ATTR_ERR_WILD_DUPLICATE_I D; 25374 iattr->state = XML_SCHEMAS_ATTR_ERR_WILD_DUPLICATE_I D;
25301 TODO 25375 TODO
25302 continue; 25376 continue;
25303 } 25377 }
25304 wildIDs++; 25378 wildIDs++;
25305 /* 25379 /*
25306 * SPEC (cvc-complex-type) 25380 * SPEC (cvc-complex-type)
25307 » » » * (5.2) "If ·wild IDs· is non-empty, there must not 25381 » » » * (5.2) "If �wild IDs� is non-empty, there must not
25308 * be any attribute uses among the {attribute uses} 25382 * be any attribute uses among the {attribute uses}
25309 * whose {attribute declaration}'s {type definition} 25383 * whose {attribute declaration}'s {type definition}
25310 * is or is derived from ID." 25384 * is or is derived from ID."
25311 */ 25385 */
25312 » » » for (j = 0; j < attrUseList->nbItems; j++) { 25386 if (attrUseList != NULL) {
25313 » » » if (xmlSchemaIsDerivedFromBuiltInType( 25387 for (j = 0; j < attrUseList->nbItems; j++) {
25314 » » » » WXS_ATTRUSE_TYPEDEF(attrUseList->items[j]), 25388 if (xmlSchemaIsDerivedFromBuiltInType(
25315 » » » » XML_SCHEMAS_ID)) { 25389 WXS_ATTRUSE_TYPEDEF(attrUseList->items[j]),
25316 » » » » /* URGENT VAL TODO: implement */ 25390 XML_SCHEMAS_ID)) {
25317 » » » » iattr->state = XML_SCHEMAS_ATTR_ERR_WILD_AND_USE _ID; 25391 /* URGENT VAL TODO: implement */
25318 » » » » TODO 25392 iattr->state = XML_SCHEMAS_ATTR_ERR_WILD_AND_USE_ID;
25319 » » » » break; 25393 TODO
25320 » » » } 25394 break;
25321 » » » } 25395 }
25396 }
25397 }
25322 } 25398 }
25323 } else if (type->attributeWildcard->processContents == 25399 } else if (type->attributeWildcard->processContents ==
25324 XML_SCHEMAS_ANY_LAX) { 25400 XML_SCHEMAS_ANY_LAX) {
25325 iattr->state = XML_SCHEMAS_ATTR_WILD_LAX_NO_DECL; 25401 iattr->state = XML_SCHEMAS_ATTR_WILD_LAX_NO_DECL;
25326 /* 25402 /*
25327 * SPEC PSVI Assessment Outcome (Attribute) 25403 * SPEC PSVI Assessment Outcome (Attribute)
25328 * [validity] = "notKnown" 25404 * [validity] = "notKnown"
25329 * [validation attempted] = "none" 25405 * [validation attempted] = "none"
25330 */ 25406 */
25331 } else { 25407 } else {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
25414 VERROR_INT("xmlSchemaVAttributesComplex", 25490 VERROR_INT("xmlSchemaVAttributesComplex",
25415 "calling xmlSchemaCopyValue()"); 25491 "calling xmlSchemaCopyValue()");
25416 goto internal_error; 25492 goto internal_error;
25417 } 25493 }
25418 } 25494 }
25419 /* 25495 /*
25420 * PSVI: Add the default attribute to the current element. 25496 * PSVI: Add the default attribute to the current element.
25421 * VAL TODO: Should we use the *normalized* value? This currently 25497 * VAL TODO: Should we use the *normalized* value? This currently
25422 * uses the *initial* value. 25498 * uses the *initial* value.
25423 */ 25499 */
25424 » 25500
25425 if (defAttrOwnerElem) { 25501 if (defAttrOwnerElem) {
25426 xmlChar *normValue; 25502 xmlChar *normValue;
25427 const xmlChar *value; 25503 const xmlChar *value;
25428 25504
25429 value = iattr->value; 25505 value = iattr->value;
25430 /* 25506 /*
25431 * Normalize the value. 25507 * Normalize the value.
25432 */ 25508 */
25433 normValue = xmlSchemaNormalizeValue(iattr->typeDef, 25509 normValue = xmlSchemaNormalizeValue(iattr->typeDef,
25434 iattr->value); 25510 iattr->value);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
25505 * the attribute was a wild attribute. 25581 * the attribute was a wild attribute.
25506 */ 25582 */
25507 if ((iattr->decl->flags & XML_SCHEMAS_ATTR_FIXED) || 25583 if ((iattr->decl->flags & XML_SCHEMAS_ATTR_FIXED) ||
25508 ((iattr->use != NULL) && 25584 ((iattr->use != NULL) &&
25509 (iattr->use->flags & XML_SCHEMAS_ATTR_FIXED))) 25585 (iattr->use->flags & XML_SCHEMAS_ATTR_FIXED)))
25510 fixed = 1; 25586 fixed = 1;
25511 else 25587 else
25512 fixed = 0; 25588 fixed = 0;
25513 /* 25589 /*
25514 * SPEC (cvc-attribute) 25590 * SPEC (cvc-attribute)
25515 » * (3) "The item's ·normalized value· must be locally ·valid· 25591 » * (3) "The item's �normalized value� must be locally �valid�
25516 » * with respect to that {type definition} as per 25592 » * with respect to that {type definition} as per
25517 » * String Valid (§3.14.4)." 25593 » * String Valid (�3.14.4)."
25518 * 25594 *
25519 * VAL TODO: Do we already have the 25595 * VAL TODO: Do we already have the
25520 * "normalized attribute value" here? 25596 * "normalized attribute value" here?
25521 */ 25597 */
25522 if (xpathRes || fixed) { 25598 if (xpathRes || fixed) {
25523 iattr->flags |= XML_SCHEMA_NODE_INFO_VALUE_NEEDED; 25599 iattr->flags |= XML_SCHEMA_NODE_INFO_VALUE_NEEDED;
25524 /* 25600 /*
25525 * Request a computed value. 25601 * Request a computed value.
25526 */ 25602 */
25527 res = xmlSchemaVCheckCVCSimpleType( 25603 res = xmlSchemaVCheckCVCSimpleType(
25528 ACTXT_CAST vctxt, 25604 ACTXT_CAST vctxt,
25529 iattr->node, iattr->typeDef, iattr->value, &(iattr->val), 25605 iattr->node, iattr->typeDef, iattr->value, &(iattr->val),
25530 1, 1, 0); 25606 1, 1, 0);
25531 } else { 25607 } else {
25532 res = xmlSchemaVCheckCVCSimpleType( 25608 res = xmlSchemaVCheckCVCSimpleType(
25533 ACTXT_CAST vctxt, 25609 ACTXT_CAST vctxt,
25534 iattr->node, iattr->typeDef, iattr->value, NULL, 25610 iattr->node, iattr->typeDef, iattr->value, NULL,
25535 1, 0, 0); 25611 1, 0, 0);
25536 } 25612 }
25537 » 25613
25538 if (res != 0) { 25614 if (res != 0) {
25539 if (res == -1) { 25615 if (res == -1) {
25540 VERROR_INT("xmlSchemaVAttributesComplex", 25616 VERROR_INT("xmlSchemaVAttributesComplex",
25541 "calling xmlSchemaStreamValidateSimpleTypeValue()"); 25617 "calling xmlSchemaStreamValidateSimpleTypeValue()");
25542 goto internal_error; 25618 goto internal_error;
25543 } 25619 }
25544 iattr->state = XML_SCHEMAS_ATTR_INVALID_VALUE; 25620 iattr->state = XML_SCHEMAS_ATTR_INVALID_VALUE;
25545 /* 25621 /*
25546 * SPEC PSVI Assessment Outcome (Attribute) 25622 * SPEC PSVI Assessment Outcome (Attribute)
25547 * [validity] = "invalid" 25623 * [validity] = "invalid"
25548 */ 25624 */
25549 goto eval_idcs; 25625 goto eval_idcs;
25550 } 25626 }
25551 25627
25552 » if (fixed) {» 25628 » if (fixed) {
25553 /* 25629 /*
25554 * SPEC Attribute Locally Valid (Use) (cvc-au) 25630 * SPEC Attribute Locally Valid (Use) (cvc-au)
25555 » * "For an attribute information item to be·valid· 25631 » * "For an attribute information item to be�valid�
25556 * with respect to an attribute use its *normalized* 25632 * with respect to an attribute use its *normalized*
25557 » * value· must match the *canonical* lexical 25633 » * value� must match the *canonical* lexical
25558 * representation of the attribute use's {value 25634 * representation of the attribute use's {value
25559 * constraint}value, if it is present and fixed." 25635 * constraint}value, if it is present and fixed."
25560 * 25636 *
25561 * VAL TODO: The requirement for the *canonical* value 25637 * VAL TODO: The requirement for the *canonical* value
25562 * will be removed in XML Schema 1.1. 25638 * will be removed in XML Schema 1.1.
25563 */ 25639 */
25564 /* 25640 /*
25565 * SPEC Attribute Locally Valid (cvc-attribute) 25641 * SPEC Attribute Locally Valid (cvc-attribute)
25566 » * (4) "The item's *actual* value· must match the *value* of 25642 » * (4) "The item's *actual* value� must match the *value* of
25567 * the {value constraint}, if it is present and fixed." 25643 * the {value constraint}, if it is present and fixed."
25568 */ 25644 */
25569 if (iattr->val == NULL) { 25645 if (iattr->val == NULL) {
25570 /* VAL TODO: A value was not precomputed. */ 25646 /* VAL TODO: A value was not precomputed. */
25571 TODO 25647 TODO
25572 goto eval_idcs; 25648 goto eval_idcs;
25573 } 25649 }
25574 if ((iattr->use != NULL) && 25650 if ((iattr->use != NULL) &&
25575 (iattr->use->defValue != NULL)) { 25651 (iattr->use->defValue != NULL)) {
25576 if (iattr->use->defVal == NULL) { 25652 if (iattr->use->defVal == NULL) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
25648 break; 25724 break;
25649 } 25725 }
25650 case XML_SCHEMAS_ATTR_ERR_NO_TYPE: 25726 case XML_SCHEMAS_ATTR_ERR_NO_TYPE:
25651 VERROR(XML_SCHEMAV_CVC_ATTRIBUTE_2, NULL, 25727 VERROR(XML_SCHEMAV_CVC_ATTRIBUTE_2, NULL,
25652 "The type definition is absent"); 25728 "The type definition is absent");
25653 break; 25729 break;
25654 case XML_SCHEMAS_ATTR_ERR_FIXED_VALUE: 25730 case XML_SCHEMAS_ATTR_ERR_FIXED_VALUE:
25655 xmlSchemaCustomErr(ACTXT_CAST vctxt, 25731 xmlSchemaCustomErr(ACTXT_CAST vctxt,
25656 XML_SCHEMAV_CVC_AU, NULL, NULL, 25732 XML_SCHEMAV_CVC_AU, NULL, NULL,
25657 "The value '%s' does not match the fixed " 25733 "The value '%s' does not match the fixed "
25658 » » "value constraint '%s'", 25734 » » "value constraint '%s'",
25659 » » iattr->value, iattr->vcValue);» » 25735 » » iattr->value, iattr->vcValue);
25660 break; 25736 break;
25661 case XML_SCHEMAS_ATTR_ERR_WILD_STRICT_NO_DECL: 25737 case XML_SCHEMAS_ATTR_ERR_WILD_STRICT_NO_DECL:
25662 VERROR(XML_SCHEMAV_CVC_WILDCARD, NULL, 25738 VERROR(XML_SCHEMAV_CVC_WILDCARD, NULL,
25663 "No matching global attribute declaration available, but " 25739 "No matching global attribute declaration available, but "
25664 "demanded by the strict wildcard"); 25740 "demanded by the strict wildcard");
25665 break; 25741 break;
25666 case XML_SCHEMAS_ATTR_UNKNOWN: 25742 case XML_SCHEMAS_ATTR_UNKNOWN:
25667 if (iattr->metaType) 25743 if (iattr->metaType)
25668 break; 25744 break;
25669 /* 25745 /*
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
25711 * URGENT VAL TODO: Either we need to position the stream to the 25787 * URGENT VAL TODO: Either we need to position the stream to the
25712 * next sibling, or walk the whole subtree. 25788 * next sibling, or walk the whole subtree.
25713 */ 25789 */
25714 *skip = 1; 25790 *skip = 1;
25715 return (0); 25791 return (0);
25716 } 25792 }
25717 { 25793 {
25718 xmlSchemaElementPtr decl = NULL; 25794 xmlSchemaElementPtr decl = NULL;
25719 25795
25720 decl = xmlSchemaGetElem(vctxt->schema, 25796 decl = xmlSchemaGetElem(vctxt->schema,
25721 » vctxt->inode->localName, vctxt->inode->nsName);» 25797 » vctxt->inode->localName, vctxt->inode->nsName);
25722 if (decl != NULL) { 25798 if (decl != NULL) {
25723 vctxt->inode->decl = decl; 25799 vctxt->inode->decl = decl;
25724 return (0); 25800 return (0);
25725 } 25801 }
25726 } 25802 }
25727 if (wild->processContents == XML_SCHEMAS_ANY_STRICT) { 25803 if (wild->processContents == XML_SCHEMAS_ANY_STRICT) {
25728 /* VAL TODO: Change to proper error code. */ 25804 /* VAL TODO: Change to proper error code. */
25729 VERROR(XML_SCHEMAV_CVC_ELT_1, NULL, /* WXS_BASIC_CAST wild */ 25805 VERROR(XML_SCHEMAV_CVC_ELT_1, NULL, /* WXS_BASIC_CAST wild */
25730 "No matching global element declaration available, but " 25806 "No matching global element declaration available, but "
25731 "demanded by the strict wildcard"); 25807 "demanded by the strict wildcard");
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
25769 * xmlSchemaCheckCOSValidDefault: 25845 * xmlSchemaCheckCOSValidDefault:
25770 * 25846 *
25771 * This will be called if: not nilled, no content and a default/fixed 25847 * This will be called if: not nilled, no content and a default/fixed
25772 * value is provided. 25848 * value is provided.
25773 */ 25849 */
25774 25850
25775 static int 25851 static int
25776 xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt, 25852 xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt,
25777 const xmlChar *value, 25853 const xmlChar *value,
25778 xmlSchemaValPtr *val) 25854 xmlSchemaValPtr *val)
25779 { 25855 {
25780 int ret = 0; 25856 int ret = 0;
25781 xmlSchemaNodeInfoPtr inode = vctxt->inode; 25857 xmlSchemaNodeInfoPtr inode = vctxt->inode;
25782 25858
25783 /* 25859 /*
25784 * cos-valid-default: 25860 * cos-valid-default:
25785 * Schema Component Constraint: Element Default Valid (Immediate) 25861 * Schema Component Constraint: Element Default Valid (Immediate)
25786 * For a string to be a valid default with respect to a type 25862 * For a string to be a valid default with respect to a type
25787 * definition the appropriate case among the following must be true: 25863 * definition the appropriate case among the following must be true:
25788 */ 25864 */
25789 if WXS_IS_COMPLEX(inode->typeDef) { 25865 if WXS_IS_COMPLEX(inode->typeDef) {
25790 /* 25866 /*
25791 * Complex type. 25867 * Complex type.
25792 * 25868 *
25793 * SPEC (2.1) "its {content type} must be a simple type definition 25869 * SPEC (2.1) "its {content type} must be a simple type definition
25794 * or mixed." 25870 * or mixed."
25795 * SPEC (2.2.2) "If the {content type} is mixed, then the {content 25871 * SPEC (2.2.2) "If the {content type} is mixed, then the {content
25796 » * type}'s particle must be ·emptiable· as defined by 25872 » * type}'s particle must be �emptiable� as defined by
25797 » * Particle Emptiable (§3.9.6)." 25873 » * Particle Emptiable (�3.9.6)."
25798 */ 25874 */
25799 if ((! WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) && 25875 if ((! WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) &&
25800 ((! WXS_HAS_MIXED_CONTENT(inode->typeDef)) || 25876 ((! WXS_HAS_MIXED_CONTENT(inode->typeDef)) ||
25801 (! WXS_EMPTIABLE(inode->typeDef)))) { 25877 (! WXS_EMPTIABLE(inode->typeDef)))) {
25802 ret = XML_SCHEMAP_COS_VALID_DEFAULT_2_1; 25878 ret = XML_SCHEMAP_COS_VALID_DEFAULT_2_1;
25803 /* NOTE that this covers (2.2.2) as well. */ 25879 /* NOTE that this covers (2.2.2) as well. */
25804 VERROR(ret, NULL, 25880 VERROR(ret, NULL,
25805 "For a string to be a valid default, the type definition " 25881 "For a string to be a valid default, the type definition "
25806 "must be a simple type or a complex type with simple content " 25882 "must be a simple type or a complex type with simple content "
25807 "or mixed content and a particle emptiable"); 25883 "or mixed content and a particle emptiable");
25808 return(ret); 25884 return(ret);
25809 } 25885 }
25810 }» 25886 }
25811 /* 25887 /*
25812 * 1 If the type definition is a simple type definition, then the string 25888 * 1 If the type definition is a simple type definition, then the string
25813 * must be ·valid· with respect to that definition as defined by String 25889 * must be �valid� with respect to that definition as defined by String
25814 * Valid (§3.14.4). 25890 * Valid (�3.14.4).
25815 * 25891 *
25816 * AND 25892 * AND
25817 * 25893 *
25818 * 2.2.1 If the {content type} is a simple type definition, then the 25894 * 2.2.1 If the {content type} is a simple type definition, then the
25819 * string must be ·valid· with respect to that simple type definition 25895 * string must be �valid� with respect to that simple type definition
25820 * as defined by String Valid (§3.14.4). 25896 * as defined by String Valid (�3.14.4).
25821 */ 25897 */
25822 if (WXS_IS_SIMPLE(inode->typeDef)) { 25898 if (WXS_IS_SIMPLE(inode->typeDef)) {
25823 25899
25824 ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST vctxt, 25900 ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST vctxt,
25825 NULL, inode->typeDef, value, val, 1, 1, 0); 25901 NULL, inode->typeDef, value, val, 1, 1, 0);
25826 25902
25827 } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) { 25903 } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
25828 25904
25829 ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST vctxt, 25905 ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST vctxt,
25830 NULL, inode->typeDef->contentTypeDef, value, val, 1, 1, 0); 25906 NULL, inode->typeDef->contentTypeDef, value, val, 1, 1, 0);
25831 } 25907 }
25832 if (ret < 0) { 25908 if (ret < 0) {
25833 VERROR_INT("xmlSchemaCheckCOSValidDefault", 25909 VERROR_INT("xmlSchemaCheckCOSValidDefault",
25834 "calling xmlSchemaVCheckCVCSimpleType()"); 25910 "calling xmlSchemaVCheckCVCSimpleType()");
25835 } 25911 }
25836 return (ret); 25912 return (ret);
25837 } 25913 }
25838 25914
25839 static void 25915 static void
25840 xmlSchemaVContentModelCallback(xmlSchemaValidCtxtPtr vctxt ATTRIBUTE_UNUSED, 25916 xmlSchemaVContentModelCallback(xmlSchemaValidCtxtPtr vctxt ATTRIBUTE_UNUSED,
25841 const xmlChar * name ATTRIBUTE_UNUSED, 25917 const xmlChar * name ATTRIBUTE_UNUSED,
25842 xmlSchemaElementPtr item, 25918 xmlSchemaElementPtr item,
25843 xmlSchemaNodeInfoPtr inode) 25919 xmlSchemaNodeInfoPtr inode)
25844 { 25920 {
25845 inode->decl = item; 25921 inode->decl = item;
(...skipping 13 matching lines...) Expand all
25859 inode->localName, inode->nsName)); 25935 inode->localName, inode->nsName));
25860 25936
25861 } 25937 }
25862 FREE_AND_NULL(str) 25938 FREE_AND_NULL(str)
25863 } 25939 }
25864 #endif 25940 #endif
25865 } 25941 }
25866 25942
25867 static int 25943 static int
25868 xmlSchemaValidatorPushElem(xmlSchemaValidCtxtPtr vctxt) 25944 xmlSchemaValidatorPushElem(xmlSchemaValidCtxtPtr vctxt)
25869 { 25945 {
25870 vctxt->inode = xmlSchemaGetFreshElemInfo(vctxt); 25946 vctxt->inode = xmlSchemaGetFreshElemInfo(vctxt);
25871 if (vctxt->inode == NULL) { 25947 if (vctxt->inode == NULL) {
25872 VERROR_INT("xmlSchemaValidatorPushElem", 25948 VERROR_INT("xmlSchemaValidatorPushElem",
25873 "calling xmlSchemaGetFreshElemInfo()"); 25949 "calling xmlSchemaGetFreshElemInfo()");
25874 return (-1); 25950 return (-1);
25875 } 25951 }
25876 vctxt->nbAttrInfos = 0; 25952 vctxt->nbAttrInfos = 0;
25877 return (0); 25953 return (0);
25878 } 25954 }
25879 25955
25880 static int 25956 static int
25881 xmlSchemaVCheckINodeDataType(xmlSchemaValidCtxtPtr vctxt, 25957 xmlSchemaVCheckINodeDataType(xmlSchemaValidCtxtPtr vctxt,
25882 xmlSchemaNodeInfoPtr inode, 25958 xmlSchemaNodeInfoPtr inode,
25883 xmlSchemaTypePtr type, 25959 xmlSchemaTypePtr type,
25884 const xmlChar *value) 25960 const xmlChar *value)
25885 { 25961 {
25886 if (inode->flags & XML_SCHEMA_NODE_INFO_VALUE_NEEDED) 25962 if (inode->flags & XML_SCHEMA_NODE_INFO_VALUE_NEEDED)
25887 return (xmlSchemaVCheckCVCSimpleType( 25963 return (xmlSchemaVCheckCVCSimpleType(
25888 ACTXT_CAST vctxt, NULL, 25964 ACTXT_CAST vctxt, NULL,
25889 type, value, &(inode->val), 1, 1, 0)); 25965 type, value, &(inode->val), 1, 1, 0));
25890 else 25966 else
25891 return (xmlSchemaVCheckCVCSimpleType( 25967 return (xmlSchemaVCheckCVCSimpleType(
25892 ACTXT_CAST vctxt, NULL, 25968 ACTXT_CAST vctxt, NULL,
25893 type, value, NULL, 1, 0, 0)); 25969 type, value, NULL, 1, 0, 0));
25894 } 25970 }
25895 25971
25896 25972
25897 25973
25898 /* 25974 /*
25899 * Process END of element. 25975 * Process END of element.
25900 */ 25976 */
25901 static int 25977 static int
25902 xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt) 25978 xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
25903 { 25979 {
25904 int ret = 0; 25980 int ret = 0;
25905 xmlSchemaNodeInfoPtr inode = vctxt->inode; 25981 xmlSchemaNodeInfoPtr inode = vctxt->inode;
25906 25982
25907 if (vctxt->nbAttrInfos != 0) 25983 if (vctxt->nbAttrInfos != 0)
25908 xmlSchemaClearAttrInfos(vctxt); 25984 xmlSchemaClearAttrInfos(vctxt);
25909 if (inode->flags & XML_SCHEMA_NODE_INFO_ERR_NOT_EXPECTED) { 25985 if (inode->flags & XML_SCHEMA_NODE_INFO_ERR_NOT_EXPECTED) {
25910 /* 25986 /*
25911 * This element was not expected; 25987 * This element was not expected;
25912 * we will not validate child elements of broken parents. 25988 * we will not validate child elements of broken parents.
25913 * Skip validation of all content of the parent. 25989 * Skip validation of all content of the parent.
25914 */ 25990 */
25915 vctxt->skipDepth = vctxt->depth -1; 25991 vctxt->skipDepth = vctxt->depth -1;
25916 goto end_elem; 25992 goto end_elem;
25917 } 25993 }
25918 if ((inode->typeDef == NULL) || 25994 if ((inode->typeDef == NULL) ||
25919 (inode->flags & XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE)) { 25995 (inode->flags & XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE)) {
25920 /* 25996 /*
25921 * 1. the type definition might be missing if the element was 25997 * 1. the type definition might be missing if the element was
25922 * error prone 25998 * error prone
25923 * 2. it might be abstract. 25999 * 2. it might be abstract.
25924 */ 26000 */
25925 goto end_elem; 26001 goto end_elem;
25926 } 26002 }
25927 /* 26003 /*
25928 * Check the content model. 26004 * Check the content model.
25929 */ 26005 */
25930 if ((inode->typeDef->contentType == XML_SCHEMA_CONTENT_MIXED) || 26006 if ((inode->typeDef->contentType == XML_SCHEMA_CONTENT_MIXED) ||
25931 (inode->typeDef->contentType == XML_SCHEMA_CONTENT_ELEMENTS)) { 26007 (inode->typeDef->contentType == XML_SCHEMA_CONTENT_ELEMENTS)) {
25932 26008
25933 /* 26009 /*
25934 * Workaround for "anyType". 26010 * Workaround for "anyType".
25935 */ 26011 */
25936 if (inode->typeDef->builtInType == XML_SCHEMAS_ANYTYPE) 26012 if (inode->typeDef->builtInType == XML_SCHEMAS_ANYTYPE)
25937 » goto character_content;» » » 26013 » goto character_content;
25938 » 26014
25939 if ((inode->flags & XML_SCHEMA_ELEM_INFO_ERR_BAD_CONTENT) == 0) { 26015 if ((inode->flags & XML_SCHEMA_ELEM_INFO_ERR_BAD_CONTENT) == 0) {
25940 xmlChar *values[10]; 26016 xmlChar *values[10];
25941 int terminal, nbval = 10, nbneg; 26017 int terminal, nbval = 10, nbneg;
25942 26018
25943 if (inode->regexCtxt == NULL) { 26019 if (inode->regexCtxt == NULL) {
25944 /* 26020 /*
25945 * Create the regex context. 26021 * Create the regex context.
25946 */ 26022 */
25947 inode->regexCtxt = 26023 inode->regexCtxt =
25948 xmlRegNewExecCtxt(inode->typeDef->contModel, 26024 xmlRegNewExecCtxt(inode->typeDef->contModel,
25949 (xmlRegExecCallbacks) xmlSchemaVContentModelCallback, 26025 (xmlRegExecCallbacks) xmlSchemaVContentModelCallback,
25950 vctxt); 26026 vctxt);
25951 if (inode->regexCtxt == NULL) { 26027 if (inode->regexCtxt == NULL) {
25952 VERROR_INT("xmlSchemaValidatorPopElem", 26028 VERROR_INT("xmlSchemaValidatorPopElem",
25953 "failed to create a regex context"); 26029 "failed to create a regex context");
25954 goto internal_error; 26030 goto internal_error;
25955 } 26031 }
25956 #ifdef DEBUG_AUTOMATA 26032 #ifdef DEBUG_AUTOMATA
25957 xmlGenericError(xmlGenericErrorContext, 26033 xmlGenericError(xmlGenericErrorContext,
25958 "AUTOMATON create on '%s'\n", inode->localName); 26034 "AUTOMATON create on '%s'\n", inode->localName);
25959 #endif» 26035 #endif
25960 } 26036 }
25961 /* 26037 /*
25962 * Get hold of the still expected content, since a further 26038 * Get hold of the still expected content, since a further
25963 * call to xmlRegExecPushString() will loose this information. 26039 * call to xmlRegExecPushString() will loose this information.
25964 » */ 26040 » */
25965 xmlRegExecNextValues(inode->regexCtxt, 26041 xmlRegExecNextValues(inode->regexCtxt,
25966 &nbval, &nbneg, &values[0], &terminal); 26042 &nbval, &nbneg, &values[0], &terminal);
25967 ret = xmlRegExecPushString(inode->regexCtxt, NULL, NULL); 26043 ret = xmlRegExecPushString(inode->regexCtxt, NULL, NULL);
25968 if ((ret<0) || ((ret==0) && (!INODE_NILLED(inode)))) { 26044 if ((ret<0) || ((ret==0) && (!INODE_NILLED(inode)))) {
25969 /* 26045 /*
25970 * Still missing something. 26046 * Still missing something.
25971 */ 26047 */
25972 ret = 1; 26048 ret = 1;
25973 inode->flags |= 26049 inode->flags |=
25974 XML_SCHEMA_ELEM_INFO_ERR_BAD_CONTENT; 26050 XML_SCHEMA_ELEM_INFO_ERR_BAD_CONTENT;
(...skipping 29 matching lines...) Expand all
26004 xmlSchemaFreeValue(vctxt->value); 26080 xmlSchemaFreeValue(vctxt->value);
26005 vctxt->value = NULL; 26081 vctxt->value = NULL;
26006 } 26082 }
26007 /* 26083 /*
26008 * Check character content. 26084 * Check character content.
26009 */ 26085 */
26010 if (inode->decl == NULL) { 26086 if (inode->decl == NULL) {
26011 /* 26087 /*
26012 * Speedup if no declaration exists. 26088 * Speedup if no declaration exists.
26013 */ 26089 */
26014 » if (WXS_IS_SIMPLE(inode->typeDef)) {» 26090 » if (WXS_IS_SIMPLE(inode->typeDef)) {
26015 ret = xmlSchemaVCheckINodeDataType(vctxt, 26091 ret = xmlSchemaVCheckINodeDataType(vctxt,
26016 inode, inode->typeDef, inode->value); 26092 inode, inode->typeDef, inode->value);
26017 } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) { 26093 } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
26018 ret = xmlSchemaVCheckINodeDataType(vctxt, 26094 ret = xmlSchemaVCheckINodeDataType(vctxt,
26019 inode, inode->typeDef->contentTypeDef, 26095 inode, inode->typeDef->contentTypeDef,
26020 inode->value); 26096 inode->value);
26021 » }» » 26097 » }
26022 if (ret < 0) { 26098 if (ret < 0) {
26023 VERROR_INT("xmlSchemaValidatorPopElem", 26099 VERROR_INT("xmlSchemaValidatorPopElem",
26024 "calling xmlSchemaVCheckCVCSimpleType()"); 26100 "calling xmlSchemaVCheckCVCSimpleType()");
26025 goto internal_error; 26101 goto internal_error;
26026 } 26102 }
26027 goto end_elem; 26103 goto end_elem;
26028 } 26104 }
26029 /* 26105 /*
26030 * cvc-elt (3.3.4) : 5 26106 * cvc-elt (3.3.4) : 5
26031 * The appropriate case among the following must be true: 26107 * The appropriate case among the following must be true:
26032 */ 26108 */
26033 /* 26109 /*
26034 * cvc-elt (3.3.4) : 5.1 26110 * cvc-elt (3.3.4) : 5.1
26035 * If the declaration has a {value constraint}, 26111 * If the declaration has a {value constraint},
26036 * the item has neither element nor character [children] and 26112 * the item has neither element nor character [children] and
26037 * clause 3.2 has not applied, then all of the following must be true: 26113 * clause 3.2 has not applied, then all of the following must be true:
26038 */ 26114 */
26039 if ((inode->decl->value != NULL) && 26115 if ((inode->decl->value != NULL) &&
26040 » (inode->flags & XML_SCHEMA_ELEM_INFO_EMPTY) && 26116 » (inode->flags & XML_SCHEMA_ELEM_INFO_EMPTY) &&
26041 (! INODE_NILLED(inode))) { 26117 (! INODE_NILLED(inode))) {
26042 /* 26118 /*
26043 » * cvc-elt (3.3.4) : 5.1.1 26119 » * cvc-elt (3.3.4) : 5.1.1
26044 » * If the ·actual type definition· is a ·local type definition· 26120 » * If the �actual type definition� is a �local type definition�
26045 * then the canonical lexical representation of the {value constraint} 26121 * then the canonical lexical representation of the {value constraint}
26046 » * value must be a valid default for the ·actual type definition· as 26122 » * value must be a valid default for the �actual type definition� as
26047 » * defined in Element Default Valid (Immediate) (§3.3.6). 26123 » * defined in Element Default Valid (Immediate) (�3.3.6).
26048 */ 26124 */
26049 » /* 26125 » /*
26050 * NOTE: 'local' above means types acquired by xsi:type. 26126 * NOTE: 'local' above means types acquired by xsi:type.
26051 * NOTE: Although the *canonical* value is stated, it is not 26127 * NOTE: Although the *canonical* value is stated, it is not
26052 * relevant if canonical or not. Additionally XML Schema 1.1 26128 * relevant if canonical or not. Additionally XML Schema 1.1
26053 * will removed this requirement as well. 26129 * will removed this requirement as well.
26054 */ 26130 */
26055 if (inode->flags & XML_SCHEMA_ELEM_INFO_LOCAL_TYPE) { 26131 if (inode->flags & XML_SCHEMA_ELEM_INFO_LOCAL_TYPE) {
26056 26132
26057 ret = xmlSchemaCheckCOSValidDefault(vctxt, 26133 ret = xmlSchemaCheckCOSValidDefault(vctxt,
26058 inode->decl->value, &(inode->val)); 26134 inode->decl->value, &(inode->val));
26059 if (ret != 0) { 26135 if (ret != 0) {
26060 if (ret < 0) { 26136 if (ret < 0) {
26061 VERROR_INT("xmlSchemaValidatorPopElem", 26137 VERROR_INT("xmlSchemaValidatorPopElem",
26062 "calling xmlSchemaCheckCOSValidDefault()"); 26138 "calling xmlSchemaCheckCOSValidDefault()");
26063 goto internal_error; 26139 goto internal_error;
26064 } 26140 }
26065 goto end_elem; 26141 goto end_elem;
26066 } 26142 }
26067 /* 26143 /*
26068 * Stop here, to avoid redundant validation of the value 26144 * Stop here, to avoid redundant validation of the value
26069 * (see following). 26145 * (see following).
26070 */ 26146 */
26071 goto default_psvi; 26147 goto default_psvi;
26072 » }» 26148 » }
26073 /* 26149 /*
26074 » * cvc-elt (3.3.4) : 5.1.2 26150 » * cvc-elt (3.3.4) : 5.1.2
26075 » * The element information item with the canonical lexical 26151 » * The element information item with the canonical lexical
26076 » * representation of the {value constraint} value used as its 26152 » * representation of the {value constraint} value used as its
26077 » * ·normalized value· must be ·valid· with respect to the 26153 » * �normalized value� must be �valid� with respect to the
26078 » * ·actual type definition· as defined by Element Locally Valid (Type) 26154 » * �actual type definition� as defined by Element Locally Valid (Type )
26079 » * (§3.3.4). 26155 » * (�3.3.4).
26080 » */» 26156 » */
26081 if (WXS_IS_SIMPLE(inode->typeDef)) { 26157 if (WXS_IS_SIMPLE(inode->typeDef)) {
26082 ret = xmlSchemaVCheckINodeDataType(vctxt, 26158 ret = xmlSchemaVCheckINodeDataType(vctxt,
26083 inode, inode->typeDef, inode->decl->value); 26159 inode, inode->typeDef, inode->decl->value);
26084 } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) { 26160 } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
26085 ret = xmlSchemaVCheckINodeDataType(vctxt, 26161 ret = xmlSchemaVCheckINodeDataType(vctxt,
26086 inode, inode->typeDef->contentTypeDef, 26162 inode, inode->typeDef->contentTypeDef,
26087 » » inode->decl->value);» 26163 » » inode->decl->value);
26088 } 26164 }
26089 if (ret != 0) { 26165 if (ret != 0) {
26090 if (ret < 0) { 26166 if (ret < 0) {
26091 VERROR_INT("xmlSchemaValidatorPopElem", 26167 VERROR_INT("xmlSchemaValidatorPopElem",
26092 "calling xmlSchemaVCheckCVCSimpleType()"); 26168 "calling xmlSchemaVCheckCVCSimpleType()");
26093 goto internal_error; 26169 goto internal_error;
26094 } 26170 }
26095 goto end_elem; 26171 goto end_elem;
26096 } 26172 }
26097 26173
26098 default_psvi: 26174 default_psvi:
26099 /* 26175 /*
26100 * PSVI: Create a text node on the instance element. 26176 * PSVI: Create a text node on the instance element.
26101 */ 26177 */
26102 if ((vctxt->options & XML_SCHEMA_VAL_VC_I_CREATE) && 26178 if ((vctxt->options & XML_SCHEMA_VAL_VC_I_CREATE) &&
26103 (inode->node != NULL)) { 26179 (inode->node != NULL)) {
26104 xmlNodePtr textChild; 26180 xmlNodePtr textChild;
26105 xmlChar *normValue; 26181 xmlChar *normValue;
26106 /* 26182 /*
26107 * VAL TODO: Normalize the value. 26183 * VAL TODO: Normalize the value.
26108 » */» 26184 » */
26109 normValue = xmlSchemaNormalizeValue(inode->typeDef, 26185 normValue = xmlSchemaNormalizeValue(inode->typeDef,
26110 inode->decl->value); 26186 inode->decl->value);
26111 if (normValue != NULL) { 26187 if (normValue != NULL) {
26112 textChild = xmlNewText(BAD_CAST normValue); 26188 textChild = xmlNewText(BAD_CAST normValue);
26113 xmlFree(normValue); 26189 xmlFree(normValue);
26114 } else 26190 } else
26115 textChild = xmlNewText(inode->decl->value); 26191 textChild = xmlNewText(inode->decl->value);
26116 if (textChild == NULL) { 26192 if (textChild == NULL) {
26117 VERROR_INT("xmlSchemaValidatorPopElem", 26193 VERROR_INT("xmlSchemaValidatorPopElem",
26118 "calling xmlNewText()"); 26194 "calling xmlNewText()");
26119 goto internal_error; 26195 goto internal_error;
26120 } else 26196 } else
26121 » » xmlAddChild(inode->node, textChild);» 26197 » » xmlAddChild(inode->node, textChild);
26122 } 26198 }
26123 » 26199
26124 } else if (! INODE_NILLED(inode)) {» 26200 } else if (! INODE_NILLED(inode)) {
26125 /* 26201 /*
26126 » * 5.2.1 The element information item must be ·valid· with respect 26202 » * 5.2.1 The element information item must be �valid� with respect
26127 » * to the ·actual type definition· as defined by Element Locally 26203 » * to the �actual type definition� as defined by Element Locally
26128 » * Valid (Type) (§3.3.4). 26204 » * Valid (Type) (�3.3.4).
26129 » */» 26205 » */
26130 if (WXS_IS_SIMPLE(inode->typeDef)) { 26206 if (WXS_IS_SIMPLE(inode->typeDef)) {
26131 /* 26207 /*
26132 * SPEC (cvc-type) (3.1) 26208 * SPEC (cvc-type) (3.1)
26133 * "If the type definition is a simple type definition, ..." 26209 * "If the type definition is a simple type definition, ..."
26134 * (3.1.3) "If clause 3.2 of Element Locally Valid 26210 * (3.1.3) "If clause 3.2 of Element Locally Valid
26135 » * (Element) (§3.3.4) did not apply, then the ·normalized value· 26211 » * (Element) (�3.3.4) did not apply, then the �normalized valueï¿ ½
26136 » * must be ·valid· with respect to the type definition as defined 26212 » * must be �valid� with respect to the type definition as defined
26137 » * by String Valid (§3.14.4). 26213 » * by String Valid (�3.14.4).
26138 » */» 26214 » */
26139 ret = xmlSchemaVCheckINodeDataType(vctxt, 26215 ret = xmlSchemaVCheckINodeDataType(vctxt,
26140 inode, inode->typeDef, inode->value); 26216 inode, inode->typeDef, inode->value);
26141 } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) { 26217 } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
26142 /* 26218 /*
26143 * SPEC (cvc-type) (3.2) "If the type definition is a complex type 26219 * SPEC (cvc-type) (3.2) "If the type definition is a complex type
26144 * definition, then the element information item must be 26220 * definition, then the element information item must be
26145 » * ·valid· with respect to the type definition as per 26221 » * �valid� with respect to the type definition as per
26146 » * Element Locally Valid (Complex Type) (§3.4.4);" 26222 » * Element Locally Valid (Complex Type) (�3.4.4);"
26147 * 26223 *
26148 * SPEC (cvc-complex-type) (2.2) 26224 * SPEC (cvc-complex-type) (2.2)
26149 » * "If the {content type} is a simple type definition, ... 26225 » * "If the {content type} is a simple type definition, ...
26150 » * the ·normalized value· of the element information item is 26226 » * the �normalized value� of the element information item is
26151 » * ·valid· with respect to that simple type definition as 26227 » * �valid� with respect to that simple type definition as
26152 » * defined by String Valid (§3.14.4)." 26228 » * defined by String Valid (�3.14.4)."
26153 */ 26229 */
26154 ret = xmlSchemaVCheckINodeDataType(vctxt, 26230 ret = xmlSchemaVCheckINodeDataType(vctxt,
26155 inode, inode->typeDef->contentTypeDef, inode->value); 26231 inode, inode->typeDef->contentTypeDef, inode->value);
26156 » }» 26232 » }
26157 if (ret != 0) { 26233 if (ret != 0) {
26158 if (ret < 0) { 26234 if (ret < 0) {
26159 VERROR_INT("xmlSchemaValidatorPopElem", 26235 VERROR_INT("xmlSchemaValidatorPopElem",
26160 "calling xmlSchemaVCheckCVCSimpleType()"); 26236 "calling xmlSchemaVCheckCVCSimpleType()");
26161 goto internal_error; 26237 goto internal_error;
26162 } 26238 }
26163 goto end_elem; 26239 goto end_elem;
26164 } 26240 }
26165 /* 26241 /*
26166 » * 5.2.2 If there is a fixed {value constraint} and clause 3.2 has 26242 » * 5.2.2 If there is a fixed {value constraint} and clause 3.2 has
26167 * not applied, all of the following must be true: 26243 * not applied, all of the following must be true:
26168 */ 26244 */
26169 if ((inode->decl->value != NULL) && 26245 if ((inode->decl->value != NULL) &&
26170 (inode->decl->flags & XML_SCHEMAS_ELEM_FIXED)) { 26246 (inode->decl->flags & XML_SCHEMAS_ELEM_FIXED)) {
26171 26247
26172 /* 26248 /*
26173 * TODO: We will need a computed value, when comparison is 26249 * TODO: We will need a computed value, when comparison is
26174 * done on computed values. 26250 * done on computed values.
26175 */ 26251 */
26176 /* 26252 /*
26177 » * 5.2.2.1 The element information item must have no element 26253 » * 5.2.2.1 The element information item must have no element
26178 * information item [children]. 26254 * information item [children].
26179 */ 26255 */
26180 if (inode->flags & 26256 if (inode->flags &
26181 XML_SCHEMA_ELEM_INFO_HAS_ELEM_CONTENT) { 26257 XML_SCHEMA_ELEM_INFO_HAS_ELEM_CONTENT) {
26182 ret = XML_SCHEMAV_CVC_ELT_5_2_2_1; 26258 ret = XML_SCHEMAV_CVC_ELT_5_2_2_1;
26183 VERROR(ret, NULL, 26259 VERROR(ret, NULL,
26184 "The content must not containt element nodes since " 26260 "The content must not containt element nodes since "
26185 "there is a fixed value constraint"); 26261 "there is a fixed value constraint");
26186 goto end_elem; 26262 goto end_elem;
26187 } else { 26263 } else {
26188 /* 26264 /*
26189 » » * 5.2.2.2 The appropriate case among the following must 26265 » » * 5.2.2.2 The appropriate case among the following must
26190 * be true: 26266 * be true:
26191 » » */» » 26267 » » */
26192 if (WXS_HAS_MIXED_CONTENT(inode->typeDef)) { 26268 if (WXS_HAS_MIXED_CONTENT(inode->typeDef)) {
26193 /* 26269 /*
26194 » » * 5.2.2.2.1 If the {content type} of the ·actual type 26270 » » * 5.2.2.2.1 If the {content type} of the �actual type
26195 » » * definition· is mixed, then the *initial value* of the 26271 » » * definition� is mixed, then the *initial value* of the
26196 » » * item must match the canonical lexical representation 26272 » » * item must match the canonical lexical representation
26197 * of the {value constraint} value. 26273 * of the {value constraint} value.
26198 * 26274 *
26199 » » * ... the *initial value* of an element information 26275 » » * ... the *initial value* of an element information
26200 » » * item is the string composed of, in order, the 26276 » » * item is the string composed of, in order, the
26201 » » * [character code] of each character information item in 26277 » » * [character code] of each character information item in
26202 * the [children] of that element information item. 26278 * the [children] of that element information item.
26203 » » */» » 26279 » » */
26204 if (! xmlStrEqual(inode->value, inode->decl->value)){ 26280 if (! xmlStrEqual(inode->value, inode->decl->value)){
26205 » » » /* 26281 » » » /*
26206 * VAL TODO: Report invalid & expected values as well. 26282 * VAL TODO: Report invalid & expected values as well.
26207 * VAL TODO: Implement the canonical stuff. 26283 * VAL TODO: Implement the canonical stuff.
26208 */ 26284 */
26209 ret = XML_SCHEMAV_CVC_ELT_5_2_2_2_1; 26285 ret = XML_SCHEMAV_CVC_ELT_5_2_2_2_1;
26210 » » » xmlSchemaCustomErr(ACTXT_CAST vctxt, 26286 » » » xmlSchemaCustomErr(ACTXT_CAST vctxt,
26211 ret, NULL, NULL, 26287 ret, NULL, NULL,
26212 "The initial value '%s' does not match the fixed " 26288 "The initial value '%s' does not match the fixed "
26213 "value constraint '%s'", 26289 "value constraint '%s'",
26214 inode->value, inode->decl->value); 26290 inode->value, inode->decl->value);
26215 goto end_elem; 26291 goto end_elem;
26216 } 26292 }
26217 } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) { 26293 } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
26218 /* 26294 /*
26219 » » * 5.2.2.2.2 If the {content type} of the ·actual type 26295 » » * 5.2.2.2.2 If the {content type} of the �actual type
26220 » » * definition· is a simple type definition, then the 26296 » » * definition� is a simple type definition, then the
26221 » » * *actual value* of the item must match the canonical 26297 » » * *actual value* of the item must match the canonical
26222 * lexical representation of the {value constraint} value. 26298 * lexical representation of the {value constraint} value.
26223 */ 26299 */
26224 /* 26300 /*
26225 * VAL TODO: *actual value* is the normalized value, impl. 26301 * VAL TODO: *actual value* is the normalized value, impl.
26226 * this. 26302 * this.
26227 * VAL TODO: Report invalid & expected values as well. 26303 * VAL TODO: Report invalid & expected values as well.
26228 * VAL TODO: Implement a comparison with the computed values. 26304 * VAL TODO: Implement a comparison with the computed values.
26229 */ 26305 */
26230 if (! xmlStrEqual(inode->value, 26306 if (! xmlStrEqual(inode->value,
26231 inode->decl->value)) { 26307 inode->decl->value)) {
26232 ret = XML_SCHEMAV_CVC_ELT_5_2_2_2_2; 26308 ret = XML_SCHEMAV_CVC_ELT_5_2_2_2_2;
26233 xmlSchemaCustomErr(ACTXT_CAST vctxt, 26309 xmlSchemaCustomErr(ACTXT_CAST vctxt,
26234 ret, NULL, NULL, 26310 ret, NULL, NULL,
26235 "The actual value '%s' does not match the fixed " 26311 "The actual value '%s' does not match the fixed "
26236 » » » "value constraint '%s'", 26312 » » » "value constraint '%s'",
26237 inode->value, 26313 inode->value,
26238 inode->decl->value); 26314 inode->decl->value);
26239 goto end_elem; 26315 goto end_elem;
26240 » » }» » 26316 » » }
26241 } 26317 }
26242 » }» 26318 » }
26243 } 26319 }
26244 } 26320 }
26245 26321
26246 end_elem: 26322 end_elem:
26247 if (vctxt->depth < 0) { 26323 if (vctxt->depth < 0) {
26248 /* TODO: raise error? */ 26324 /* TODO: raise error? */
26249 return (0); 26325 return (0);
26250 } 26326 }
26251 if (vctxt->depth == vctxt->skipDepth) 26327 if (vctxt->depth == vctxt->skipDepth)
26252 vctxt->skipDepth = -1; 26328 vctxt->skipDepth = -1;
26253 /* 26329 /*
26254 * Evaluate the history of XPath state objects. 26330 * Evaluate the history of XPath state objects.
26255 */ 26331 */
26256 if (inode->appliedXPath && 26332 if (inode->appliedXPath &&
26257 (xmlSchemaXPathProcessHistory(vctxt, vctxt->depth) == -1)) 26333 (xmlSchemaXPathProcessHistory(vctxt, vctxt->depth) == -1))
26258 goto internal_error; 26334 goto internal_error;
26259 /* 26335 /*
26260 * MAYBE TODO: 26336 * MAYBE TODO:
26261 * SPEC (6) "The element information item must be ·valid· with 26337 * SPEC (6) "The element information item must be �valid� with
26262 * respect to each of the {identity-constraint definitions} as per 26338 * respect to each of the {identity-constraint definitions} as per
26263 * Identity-constraint Satisfied (§3.11.4)." 26339 * Identity-constraint Satisfied (�3.11.4)."
26264 */ 26340 */
26265 /* 26341 /*
26266 * PSVI TODO: If we expose IDC node-tables via PSVI then the tables 26342 * PSVI TODO: If we expose IDC node-tables via PSVI then the tables
26267 * need to be built in any case. 26343 * need to be built in any case.
26268 * We will currently build IDC node-tables and bubble them only if 26344 * We will currently build IDC node-tables and bubble them only if
26269 * keyrefs do exist. 26345 * keyrefs do exist.
26270 */ 26346 */
26271 26347
26272 /* 26348 /*
26273 * Add the current IDC target-nodes to the IDC node-tables. 26349 * Add the current IDC target-nodes to the IDC node-tables.
26274 */ 26350 */
26275 if ((inode->idcMatchers != NULL) && 26351 if ((inode->idcMatchers != NULL) &&
26276 (vctxt->hasKeyrefs || vctxt->createIDCNodeTables)) 26352 (vctxt->hasKeyrefs || vctxt->createIDCNodeTables))
26277 { 26353 {
26278 if (xmlSchemaIDCFillNodeTables(vctxt, inode) == -1) 26354 if (xmlSchemaIDCFillNodeTables(vctxt, inode) == -1)
26279 goto internal_error; 26355 goto internal_error;
26280 } 26356 }
26281 /* 26357 /*
(...skipping 13 matching lines...) Expand all
26295 inode->idcTable); 26371 inode->idcTable);
26296 #endif 26372 #endif
26297 if ((vctxt->depth > 0) && 26373 if ((vctxt->depth > 0) &&
26298 (vctxt->hasKeyrefs || vctxt->createIDCNodeTables)) 26374 (vctxt->hasKeyrefs || vctxt->createIDCNodeTables))
26299 { 26375 {
26300 /* 26376 /*
26301 * Merge the IDC node table with the table of the parent node. 26377 * Merge the IDC node table with the table of the parent node.
26302 */ 26378 */
26303 if (xmlSchemaBubbleIDCNodeTables(vctxt) == -1) 26379 if (xmlSchemaBubbleIDCNodeTables(vctxt) == -1)
26304 goto internal_error; 26380 goto internal_error;
26305 » }» 26381 » }
26306 } 26382 }
26307 /* 26383 /*
26308 * Clear the current ielem. 26384 * Clear the current ielem.
26309 * VAL TODO: Don't free the PSVI IDC tables if they are 26385 * VAL TODO: Don't free the PSVI IDC tables if they are
26310 * requested for the PSVI. 26386 * requested for the PSVI.
26311 */ 26387 */
26312 xmlSchemaClearElemInfo(vctxt, inode); 26388 xmlSchemaClearElemInfo(vctxt, inode);
26313 /* 26389 /*
26314 * Skip further processing if we are on the validation root. 26390 * Skip further processing if we are on the validation root.
26315 */ 26391 */
(...skipping 12 matching lines...) Expand all
26328 /* 26404 /*
26329 * A 'keyrefDepth' of a key/unique IDC matches the current 26405 * A 'keyrefDepth' of a key/unique IDC matches the current
26330 * depth, this means that we are leaving the scope of the 26406 * depth, this means that we are leaving the scope of the
26331 * top-most keyref IDC which refers to this IDC. 26407 * top-most keyref IDC which refers to this IDC.
26332 */ 26408 */
26333 aidc->keyrefDepth = -1; 26409 aidc->keyrefDepth = -1;
26334 } 26410 }
26335 aidc = aidc->next; 26411 aidc = aidc->next;
26336 } while (aidc != NULL); 26412 } while (aidc != NULL);
26337 } 26413 }
26338 vctxt->depth--; 26414 vctxt->depth--;
26339 vctxt->inode = vctxt->elemInfos[vctxt->depth]; 26415 vctxt->inode = vctxt->elemInfos[vctxt->depth];
26340 /* 26416 /*
26341 * VAL TODO: 7 If the element information item is the ·validation root·, it m ust be 26417 * VAL TODO: 7 If the element information item is the �validation root�, it must be
26342 * ·valid· per Validation Root Valid (ID/IDREF) (§3.3.4). 26418 * �valid� per Validation Root Valid (ID/IDREF) (�3.3.4).
26343 */ 26419 */
26344 return (ret); 26420 return (ret);
26345 26421
26346 internal_error: 26422 internal_error:
26347 vctxt->err = -1; 26423 vctxt->err = -1;
26348 return (-1); 26424 return (-1);
26349 } 26425 }
26350 26426
26351 /* 26427 /*
26352 * 3.4.4 Complex Type Definition Validation Rules 26428 * 3.4.4 Complex Type Definition Validation Rules
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
26413 "process the attribute 'xsi:nil'"); 26489 "process the attribute 'xsi:nil'");
26414 return (-1); 26490 return (-1);
26415 } 26491 }
26416 return (ret); 26492 return (ret);
26417 } 26493 }
26418 } else { 26494 } else {
26419 /* 26495 /*
26420 * Fallback to "anyType". 26496 * Fallback to "anyType".
26421 * 26497 *
26422 * SPEC (cvc-assess-elt) 26498 * SPEC (cvc-assess-elt)
26423 » » * "If the item cannot be ·strictly assessed·, [...] 26499 » » * "If the item cannot be �strictly assessed�, [...]
26424 * an element information item's schema validity may be laxly 26500 * an element information item's schema validity may be laxly
26425 » » * assessed if its ·context-determined declaration· is not 26501 » » * assessed if its �context-determined declaration� is not
26426 » » * skip by ·validating· with respect to the ·ur-type 26502 » » * skip by �validating� with respect to the �ur-type
26427 » » * definition· as per Element Locally Valid (Type) (§3.3.4)." 26503 » » * definition� as per Element Locally Valid (Type) (�3.3.4). "
26428 */ 26504 */
26429 vctxt->inode->typeDef = 26505 vctxt->inode->typeDef =
26430 xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYTYPE); 26506 xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYTYPE);
26431 } 26507 }
26432 } 26508 }
26433 return (0); 26509 return (0);
26434 } 26510 }
26435 26511
26436 switch (ptype->contentType) { 26512 switch (ptype->contentType) {
26437 case XML_SCHEMA_CONTENT_EMPTY: 26513 case XML_SCHEMA_CONTENT_EMPTY:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
26489 #ifdef DEBUG_AUTOMATA 26565 #ifdef DEBUG_AUTOMATA
26490 xmlGenericError(xmlGenericErrorContext, "AUTOMATA create on '%s' \n", 26566 xmlGenericError(xmlGenericErrorContext, "AUTOMATA create on '%s' \n",
26491 pielem->localName); 26567 pielem->localName);
26492 #endif 26568 #endif
26493 } 26569 }
26494 26570
26495 /* 26571 /*
26496 * SPEC (2.4) "If the {content type} is element-only or mixed, 26572 * SPEC (2.4) "If the {content type} is element-only or mixed,
26497 * then the sequence of the element information item's 26573 * then the sequence of the element information item's
26498 * element information item [children], if any, taken in 26574 * element information item [children], if any, taken in
26499 » * order, is ·valid· with respect to the {content type}'s 26575 » * order, is �valid� with respect to the {content type}'s
26500 * particle, as defined in Element Sequence Locally Valid 26576 * particle, as defined in Element Sequence Locally Valid
26501 » * (Particle) (§3.9.4)." 26577 » * (Particle) (�3.9.4)."
26502 */ 26578 */
26503 ret = xmlRegExecPushString2(regexCtxt, 26579 ret = xmlRegExecPushString2(regexCtxt,
26504 vctxt->inode->localName, 26580 vctxt->inode->localName,
26505 vctxt->inode->nsName, 26581 vctxt->inode->nsName,
26506 vctxt->inode); 26582 vctxt->inode);
26507 #ifdef DEBUG_AUTOMATA 26583 #ifdef DEBUG_AUTOMATA
26508 if (ret < 0) 26584 if (ret < 0)
26509 xmlGenericError(xmlGenericErrorContext, 26585 xmlGenericError(xmlGenericErrorContext,
26510 "AUTOMATON push ERROR for '%s' on '%s'\n", 26586 "AUTOMATON push ERROR for '%s' on '%s'\n",
26511 vctxt->inode->localName, pielem->localName); 26587 vctxt->inode->localName, pielem->localName);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
26588 * OPTIMIZE: Maybe we could skip it, if: 26664 * OPTIMIZE: Maybe we could skip it, if:
26589 * 1. content type is simple 26665 * 1. content type is simple
26590 * 2. whitespace is "collapse" 26666 * 2. whitespace is "collapse"
26591 * 3. it consists of whitespace only 26667 * 3. it consists of whitespace only
26592 * 26668 *
26593 * Process character content. 26669 * Process character content.
26594 */ 26670 */
26595 if (consumed != NULL) 26671 if (consumed != NULL)
26596 *consumed = 0; 26672 *consumed = 0;
26597 if (INODE_NILLED(vctxt->inode)) { 26673 if (INODE_NILLED(vctxt->inode)) {
26598 » /* 26674 » /*
26599 * SPEC cvc-elt (3.3.4 - 3.2.1) 26675 * SPEC cvc-elt (3.3.4 - 3.2.1)
26600 * "The element information item must have no character or 26676 * "The element information item must have no character or
26601 * element information item [children]." 26677 * element information item [children]."
26602 */ 26678 */
26603 VERROR(XML_SCHEMAV_CVC_ELT_3_2_1, NULL, 26679 VERROR(XML_SCHEMAV_CVC_ELT_3_2_1, NULL,
26604 "Neither character nor element content is allowed " 26680 "Neither character nor element content is allowed "
26605 "because the element is 'nilled'"); 26681 "because the element is 'nilled'");
26606 return (vctxt->err); 26682 return (vctxt->err);
26607 } 26683 }
26608 /* 26684 /*
26609 * SPEC (2.1) "If the {content type} is empty, then the 26685 * SPEC (2.1) "If the {content type} is empty, then the
26610 * element information item has no character or element 26686 * element information item has no character or element
26611 * information item [children]." 26687 * information item [children]."
26612 */ 26688 */
26613 if (vctxt->inode->typeDef->contentType == 26689 if (vctxt->inode->typeDef->contentType ==
26614 » XML_SCHEMA_CONTENT_EMPTY) { 26690 » XML_SCHEMA_CONTENT_EMPTY) {
26615 VERROR(XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, NULL, 26691 VERROR(XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, NULL,
26616 "Character content is not allowed, " 26692 "Character content is not allowed, "
26617 "because the content type is empty"); 26693 "because the content type is empty");
26618 return (vctxt->err); 26694 return (vctxt->err);
26619 } 26695 }
26620 26696
26621 if (vctxt->inode->typeDef->contentType == 26697 if (vctxt->inode->typeDef->contentType ==
26622 XML_SCHEMA_CONTENT_ELEMENTS) { 26698 XML_SCHEMA_CONTENT_ELEMENTS) {
26623 if ((nodeType != XML_TEXT_NODE) || 26699 if ((nodeType != XML_TEXT_NODE) ||
26624 (! xmlSchemaIsBlank((xmlChar *) value, len))) { 26700 (! xmlSchemaIsBlank((xmlChar *) value, len))) {
26625 » /* 26701 » /*
26626 » * SPEC cvc-complex-type (2.3) 26702 » * SPEC cvc-complex-type (2.3)
26627 » * "If the {content type} is element-only, then the 26703 » * "If the {content type} is element-only, then the
26628 » * element information item has no character information 26704 » * element information item has no character information
26629 » * item [children] other than those whose [character 26705 » * item [children] other than those whose [character
26630 » * code] is defined as a white space in [XML 1.0 (Second 26706 » * code] is defined as a white space in [XML 1.0 (Second
26631 * Edition)]." 26707 * Edition)]."
26632 */ 26708 */
26633 VERROR(XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, NULL, 26709 VERROR(XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, NULL,
26634 "Character content other than whitespace is not allowed " 26710 "Character content other than whitespace is not allowed "
26635 "because the content type is 'element-only'"); 26711 "because the content type is 'element-only'");
26636 return (vctxt->err); 26712 return (vctxt->err);
26637 } 26713 }
26638 return (0); 26714 return (0);
26639 } 26715 }
26640 26716
26641 if ((value == NULL) || (value[0] == 0)) 26717 if ((value == NULL) || (value[0] == 0))
26642 return (0); 26718 return (0);
26643 /* 26719 /*
26644 * Save the value. 26720 * Save the value.
26645 * NOTE that even if the content type is *mixed*, we need the 26721 * NOTE that even if the content type is *mixed*, we need the
26646 * *initial value* for default/fixed value constraints. 26722 * *initial value* for default/fixed value constraints.
26647 */ 26723 */
26648 if ((vctxt->inode->typeDef->contentType == XML_SCHEMA_CONTENT_MIXED) && 26724 if ((vctxt->inode->typeDef->contentType == XML_SCHEMA_CONTENT_MIXED) &&
26649 ((vctxt->inode->decl == NULL) || 26725 ((vctxt->inode->decl == NULL) ||
26650 (vctxt->inode->decl->value == NULL))) 26726 (vctxt->inode->decl->value == NULL)))
26651 return (0); 26727 return (0);
26652 26728
26653 if (vctxt->inode->value == NULL) { 26729 if (vctxt->inode->value == NULL) {
26654 /* 26730 /*
26655 * Set the value. 26731 * Set the value.
26656 */ 26732 */
26657 switch (mode) { 26733 switch (mode) {
26658 case XML_SCHEMA_PUSH_TEXT_PERSIST: 26734 case XML_SCHEMA_PUSH_TEXT_PERSIST:
26659 /* 26735 /*
26660 * When working on a tree. 26736 * When working on a tree.
26661 */ 26737 */
26662 vctxt->inode->value = value; 26738 vctxt->inode->value = value;
(...skipping 22 matching lines...) Expand all
26685 XML_SCHEMA_NODE_INFO_FLAG_OWNED_VALUES; 26761 XML_SCHEMA_NODE_INFO_FLAG_OWNED_VALUES;
26686 break; 26762 break;
26687 default: 26763 default:
26688 break; 26764 break;
26689 } 26765 }
26690 } else { 26766 } else {
26691 if (len < 0) 26767 if (len < 0)
26692 len = xmlStrlen(value); 26768 len = xmlStrlen(value);
26693 /* 26769 /*
26694 * Concat the value. 26770 * Concat the value.
26695 » */» 26771 » */
26696 if (vctxt->inode->flags & XML_SCHEMA_NODE_INFO_FLAG_OWNED_VALUES) { 26772 if (vctxt->inode->flags & XML_SCHEMA_NODE_INFO_FLAG_OWNED_VALUES) {
26697 vctxt->inode->value = BAD_CAST xmlStrncat( 26773 vctxt->inode->value = BAD_CAST xmlStrncat(
26698 (xmlChar *) vctxt->inode->value, value, len); 26774 (xmlChar *) vctxt->inode->value, value, len);
26699 } else { 26775 } else {
26700 vctxt->inode->value = 26776 vctxt->inode->value =
26701 BAD_CAST xmlStrncatNew(vctxt->inode->value, value, len); 26777 BAD_CAST xmlStrncatNew(vctxt->inode->value, value, len);
26702 vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_FLAG_OWNED_VALUES; 26778 vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_FLAG_OWNED_VALUES;
26703 } 26779 }
26704 }» 26780 }
26705 26781
26706 return (0); 26782 return (0);
26707 } 26783 }
26708 26784
26709 static int 26785 static int
26710 xmlSchemaValidateElem(xmlSchemaValidCtxtPtr vctxt) 26786 xmlSchemaValidateElem(xmlSchemaValidCtxtPtr vctxt)
26711 { 26787 {
26712 int ret = 0; 26788 int ret = 0;
26713 26789
26714 if ((vctxt->skipDepth != -1) && 26790 if ((vctxt->skipDepth != -1) &&
26715 (vctxt->depth >= vctxt->skipDepth)) { 26791 (vctxt->depth >= vctxt->skipDepth)) {
26716 VERROR_INT("xmlSchemaValidateElem", 26792 VERROR_INT("xmlSchemaValidateElem",
26717 "in skip-state"); 26793 "in skip-state");
26718 goto internal_error; 26794 goto internal_error;
26719 } 26795 }
26720 if (vctxt->xsiAssemble) { 26796 if (vctxt->xsiAssemble) {
26721 » /* 26797 » /*
26722 * We will stop validation if there was an error during 26798 * We will stop validation if there was an error during
26723 * dynamic schema construction. 26799 * dynamic schema construction.
26724 * Note that we simply set @skipDepth to 0, this could 26800 * Note that we simply set @skipDepth to 0, this could
26725 * mean that a streaming document via SAX would be 26801 * mean that a streaming document via SAX would be
26726 * still read to the end but it won't be validated any more. 26802 * still read to the end but it won't be validated any more.
26727 * TODO: If we are sure how to stop the validation at once 26803 * TODO: If we are sure how to stop the validation at once
26728 * for all input scenarios, then this should be changed to 26804 * for all input scenarios, then this should be changed to
26729 * instantly stop the validation. 26805 * instantly stop the validation.
26730 */ 26806 */
26731 ret = xmlSchemaAssembleByXSI(vctxt); 26807 ret = xmlSchemaAssembleByXSI(vctxt);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
26824 * Validate against the type definition. 26900 * Validate against the type definition.
26825 */ 26901 */
26826 type_validation: 26902 type_validation:
26827 26903
26828 if (vctxt->inode->typeDef == NULL) { 26904 if (vctxt->inode->typeDef == NULL) {
26829 vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE; 26905 vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE;
26830 ret = XML_SCHEMAV_CVC_TYPE_1; 26906 ret = XML_SCHEMAV_CVC_TYPE_1;
26831 VERROR(ret, NULL, 26907 VERROR(ret, NULL,
26832 "The type definition is absent"); 26908 "The type definition is absent");
26833 goto exit; 26909 goto exit;
26834 } 26910 }
26835 if (vctxt->inode->typeDef->flags & XML_SCHEMAS_TYPE_ABSTRACT) { 26911 if (vctxt->inode->typeDef->flags & XML_SCHEMAS_TYPE_ABSTRACT) {
26836 vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE; 26912 vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE;
26837 ret = XML_SCHEMAV_CVC_TYPE_2; 26913 ret = XML_SCHEMAV_CVC_TYPE_2;
26838 VERROR(ret, NULL, 26914 VERROR(ret, NULL,
26839 » "The type definition is abstract");» 26915 » "The type definition is abstract");
26840 goto exit; 26916 goto exit;
26841 } 26917 }
26842 /* 26918 /*
26843 * Evaluate IDCs. Do it here, since new IDC matchers are registered 26919 * Evaluate IDCs. Do it here, since new IDC matchers are registered
26844 * during validation against the declaration. This must be done 26920 * during validation against the declaration. This must be done
26845 * _before_ attribute validation. 26921 * _before_ attribute validation.
26846 */ 26922 */
26847 if (vctxt->xpathStates != NULL) { 26923 if (vctxt->xpathStates != NULL) {
26848 ret = xmlSchemaXPathEvaluate(vctxt, XML_ELEMENT_NODE); 26924 ret = xmlSchemaXPathEvaluate(vctxt, XML_ELEMENT_NODE);
26849 vctxt->inode->appliedXPath = 1; 26925 vctxt->inode->appliedXPath = 1;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
26910 } 26986 }
26911 goto exit; 26987 goto exit;
26912 26988
26913 root_found: 26989 root_found:
26914 26990
26915 do { 26991 do {
26916 depth = xmlTextReaderDepth(vctxt->reader); 26992 depth = xmlTextReaderDepth(vctxt->reader);
26917 nodeType = xmlTextReaderNodeType(vctxt->reader); 26993 nodeType = xmlTextReaderNodeType(vctxt->reader);
26918 26994
26919 if (nodeType == XML_ELEMENT_NODE) { 26995 if (nodeType == XML_ELEMENT_NODE) {
26920 » 26996
26921 vctxt->depth++; 26997 vctxt->depth++;
26922 if (xmlSchemaValidatorPushElem(vctxt) == -1) { 26998 if (xmlSchemaValidatorPushElem(vctxt) == -1) {
26923 VERROR_INT("xmlSchemaVReaderWalk", 26999 VERROR_INT("xmlSchemaVReaderWalk",
26924 "calling xmlSchemaValidatorPushElem()"); 27000 "calling xmlSchemaValidatorPushElem()");
26925 goto internal_error; 27001 goto internal_error;
26926 } 27002 }
26927 ielem = vctxt->inode; 27003 ielem = vctxt->inode;
26928 ielem->localName = xmlTextReaderLocalName(vctxt->reader); 27004 ielem->localName = xmlTextReaderLocalName(vctxt->reader);
26929 ielem->nsName = xmlTextReaderNamespaceUri(vctxt->reader); 27005 ielem->nsName = xmlTextReaderNamespaceUri(vctxt->reader);
26930 ielem->flags |= XML_SCHEMA_NODE_INFO_FLAG_OWNED_NAMES; 27006 ielem->flags |= XML_SCHEMA_NODE_INFO_FLAG_OWNED_NAMES;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
27085 /************************************************************************ 27161 /************************************************************************
27086 * * 27162 * *
27087 * SAX validation handlers * 27163 * SAX validation handlers *
27088 * * 27164 * *
27089 ************************************************************************/ 27165 ************************************************************************/
27090 27166
27091 /* 27167 /*
27092 * Process text content. 27168 * Process text content.
27093 */ 27169 */
27094 static void 27170 static void
27095 xmlSchemaSAXHandleText(void *ctx, 27171 xmlSchemaSAXHandleText(void *ctx,
27096 » » const xmlChar * ch, 27172 » » const xmlChar * ch,
27097 int len) 27173 int len)
27098 { 27174 {
27099 xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx; 27175 xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx;
27100 27176
27101 if (vctxt->depth < 0) 27177 if (vctxt->depth < 0)
27102 return; 27178 return;
27103 if ((vctxt->skipDepth != -1) && (vctxt->depth >= vctxt->skipDepth)) 27179 if ((vctxt->skipDepth != -1) && (vctxt->depth >= vctxt->skipDepth))
27104 return; 27180 return;
27105 if (vctxt->inode->flags & XML_SCHEMA_ELEM_INFO_EMPTY) 27181 if (vctxt->inode->flags & XML_SCHEMA_ELEM_INFO_EMPTY)
27106 vctxt->inode->flags ^= XML_SCHEMA_ELEM_INFO_EMPTY; 27182 vctxt->inode->flags ^= XML_SCHEMA_ELEM_INFO_EMPTY;
27107 if (xmlSchemaVPushText(vctxt, XML_TEXT_NODE, ch, len, 27183 if (xmlSchemaVPushText(vctxt, XML_TEXT_NODE, ch, len,
27108 XML_SCHEMA_PUSH_TEXT_VOLATILE, NULL) == -1) { 27184 XML_SCHEMA_PUSH_TEXT_VOLATILE, NULL) == -1) {
27109 VERROR_INT("xmlSchemaSAXHandleCDataSection", 27185 VERROR_INT("xmlSchemaSAXHandleCDataSection",
27110 "calling xmlSchemaVPushText()"); 27186 "calling xmlSchemaVPushText()");
27111 vctxt->err = -1; 27187 vctxt->err = -1;
27112 xmlStopParser(vctxt->parserCtxt); 27188 xmlStopParser(vctxt->parserCtxt);
27113 } 27189 }
27114 } 27190 }
27115 27191
27116 /* 27192 /*
27117 * Process CDATA content. 27193 * Process CDATA content.
27118 */ 27194 */
27119 static void 27195 static void
27120 xmlSchemaSAXHandleCDataSection(void *ctx, 27196 xmlSchemaSAXHandleCDataSection(void *ctx,
27121 » » » const xmlChar * ch, 27197 » » » const xmlChar * ch,
27122 int len) 27198 int len)
27123 { 27199 {
27124 xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx; 27200 xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx;
27125 27201
27126 if (vctxt->depth < 0) 27202 if (vctxt->depth < 0)
27127 return; 27203 return;
27128 if ((vctxt->skipDepth != -1) && (vctxt->depth >= vctxt->skipDepth)) 27204 if ((vctxt->skipDepth != -1) && (vctxt->depth >= vctxt->skipDepth))
27129 return; 27205 return;
27130 if (vctxt->inode->flags & XML_SCHEMA_ELEM_INFO_EMPTY) 27206 if (vctxt->inode->flags & XML_SCHEMA_ELEM_INFO_EMPTY)
27131 vctxt->inode->flags ^= XML_SCHEMA_ELEM_INFO_EMPTY; 27207 vctxt->inode->flags ^= XML_SCHEMA_ELEM_INFO_EMPTY;
27132 if (xmlSchemaVPushText(vctxt, XML_CDATA_SECTION_NODE, ch, len, 27208 if (xmlSchemaVPushText(vctxt, XML_CDATA_SECTION_NODE, ch, len,
27133 XML_SCHEMA_PUSH_TEXT_VOLATILE, NULL) == -1) { 27209 XML_SCHEMA_PUSH_TEXT_VOLATILE, NULL) == -1) {
(...skipping 13 matching lines...) Expand all
27147 if (vctxt->depth < 0) 27223 if (vctxt->depth < 0)
27148 return; 27224 return;
27149 if ((vctxt->skipDepth != -1) && (vctxt->depth >= vctxt->skipDepth)) 27225 if ((vctxt->skipDepth != -1) && (vctxt->depth >= vctxt->skipDepth))
27150 return; 27226 return;
27151 /* SAX VAL TODO: What to do here? */ 27227 /* SAX VAL TODO: What to do here? */
27152 TODO 27228 TODO
27153 } 27229 }
27154 27230
27155 static void 27231 static void
27156 xmlSchemaSAXHandleStartElementNs(void *ctx, 27232 xmlSchemaSAXHandleStartElementNs(void *ctx,
27157 » » » » const xmlChar * localname, 27233 » » » » const xmlChar * localname,
27158 » » » » const xmlChar * prefix ATTRIBUTE_UNUSED, 27234 » » » » const xmlChar * prefix ATTRIBUTE_UNUSED,
27159 » » » » const xmlChar * URI, 27235 » » » » const xmlChar * URI,
27160 » » » » int nb_namespaces, 27236 » » » » int nb_namespaces,
27161 » » » » const xmlChar ** namespaces, 27237 » » » » const xmlChar ** namespaces,
27162 » » » » int nb_attributes, 27238 » » » » int nb_attributes,
27163 » » » » int nb_defaulted ATTRIBUTE_UNUSED, 27239 » » » » int nb_defaulted ATTRIBUTE_UNUSED,
27164 const xmlChar ** attributes) 27240 const xmlChar ** attributes)
27165 { 27241 {
27166 xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx; 27242 xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx;
27167 int ret; 27243 int ret;
27168 xmlSchemaNodeInfoPtr ielem; 27244 xmlSchemaNodeInfoPtr ielem;
27169 int i, j; 27245 int i, j;
27170 27246
27171 /* 27247 /*
27172 * SAX VAL TODO: What to do with nb_defaulted? 27248 * SAX VAL TODO: What to do with nb_defaulted?
27173 */ 27249 */
27174 /* 27250 /*
27175 * Skip elements if inside a "skip" wildcard or invalid. 27251 * Skip elements if inside a "skip" wildcard or invalid.
27176 */ 27252 */
27177 vctxt->depth++; 27253 vctxt->depth++;
27178 if ((vctxt->skipDepth != -1) && (vctxt->depth >= vctxt->skipDepth)) 27254 if ((vctxt->skipDepth != -1) && (vctxt->depth >= vctxt->skipDepth))
27179 return; 27255 return;
27180 /* 27256 /*
27181 * Push the element. 27257 * Push the element.
27182 */ 27258 */
27183 if (xmlSchemaValidatorPushElem(vctxt) == -1) { 27259 if (xmlSchemaValidatorPushElem(vctxt) == -1) {
27184 VERROR_INT("xmlSchemaSAXHandleStartElementNs", 27260 VERROR_INT("xmlSchemaSAXHandleStartElementNs",
27185 "calling xmlSchemaValidatorPushElem()"); 27261 "calling xmlSchemaValidatorPushElem()");
27186 goto internal_error; 27262 goto internal_error;
27187 } 27263 }
27188 ielem = vctxt->inode; 27264 ielem = vctxt->inode;
27189 /* 27265 /*
27190 * TODO: Is this OK? 27266 * TODO: Is this OK?
27191 */ 27267 */
27192 ielem->nodeLine = xmlSAX2GetLineNumber(vctxt->parserCtxt); 27268 ielem->nodeLine = xmlSAX2GetLineNumber(vctxt->parserCtxt);
27193 ielem->localName = localname; 27269 ielem->localName = localname;
27194 ielem->nsName = URI; 27270 ielem->nsName = URI;
27195 ielem->flags |= XML_SCHEMA_ELEM_INFO_EMPTY; 27271 ielem->flags |= XML_SCHEMA_ELEM_INFO_EMPTY;
27196 /* 27272 /*
27197 * Register namespaces on the elem info. 27273 * Register namespaces on the elem info.
27198 */ 27274 */
27199 if (nb_namespaces != 0) { 27275 if (nb_namespaces != 0) {
27200 /* 27276 /*
27201 * Although the parser builds its own namespace list, 27277 * Although the parser builds its own namespace list,
27202 * we have no access to it, so we'll use an own one. 27278 * we have no access to it, so we'll use an own one.
27203 */ 27279 */
27204 for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) {» 27280 for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) {
27205 /* 27281 /*
27206 * Store prefix and namespace name. 27282 * Store prefix and namespace name.
27207 » */» 27283 » */
27208 if (ielem->nsBindings == NULL) { 27284 if (ielem->nsBindings == NULL) {
27209 ielem->nsBindings = 27285 ielem->nsBindings =
27210 (const xmlChar **) xmlMalloc(10 * 27286 (const xmlChar **) xmlMalloc(10 *
27211 sizeof(const xmlChar *)); 27287 sizeof(const xmlChar *));
27212 if (ielem->nsBindings == NULL) { 27288 if (ielem->nsBindings == NULL) {
27213 xmlSchemaVErrMemory(vctxt, 27289 xmlSchemaVErrMemory(vctxt,
27214 "allocating namespace bindings for SAX validation", 27290 "allocating namespace bindings for SAX validation",
27215 NULL); 27291 NULL);
27216 goto internal_error; 27292 goto internal_error;
27217 } 27293 }
(...skipping 15 matching lines...) Expand all
27233 27309
27234 ielem->nsBindings[ielem->nbNsBindings * 2] = namespaces[j]; 27310 ielem->nsBindings[ielem->nbNsBindings * 2] = namespaces[j];
27235 if (namespaces[j+1][0] == 0) { 27311 if (namespaces[j+1][0] == 0) {
27236 /* 27312 /*
27237 * Handle xmlns="". 27313 * Handle xmlns="".
27238 */ 27314 */
27239 ielem->nsBindings[ielem->nbNsBindings * 2 + 1] = NULL; 27315 ielem->nsBindings[ielem->nbNsBindings * 2 + 1] = NULL;
27240 } else 27316 } else
27241 ielem->nsBindings[ielem->nbNsBindings * 2 + 1] = 27317 ielem->nsBindings[ielem->nbNsBindings * 2 + 1] =
27242 namespaces[j+1]; 27318 namespaces[j+1];
27243 » ielem->nbNsBindings++;» » 27319 » ielem->nbNsBindings++;
27244 } 27320 }
27245 } 27321 }
27246 /* 27322 /*
27247 * Register attributes. 27323 * Register attributes.
27248 * SAX VAL TODO: We are not adding namespace declaration 27324 * SAX VAL TODO: We are not adding namespace declaration
27249 * attributes yet. 27325 * attributes yet.
27250 */ 27326 */
27251 if (nb_attributes != 0) { 27327 if (nb_attributes != 0) {
27252 xmlChar *value; 27328 xmlChar *value;
27253 27329
27254 for (j = 0, i = 0; i < nb_attributes; i++, j += 5) { 27330 for (j = 0, i = 0; i < nb_attributes; i++, j += 5) {
27255 /* 27331 /*
27256 * Duplicate the value. 27332 * Duplicate the value.
27257 » */» 27333 » */
27258 value = xmlStrndup(attributes[j+3], 27334 value = xmlStrndup(attributes[j+3],
27259 attributes[j+4] - attributes[j+3]); 27335 attributes[j+4] - attributes[j+3]);
27260 /* 27336 /*
27261 * TODO: Set the node line. 27337 * TODO: Set the node line.
27262 */ 27338 */
27263 ret = xmlSchemaValidatorPushAttribute(vctxt, 27339 ret = xmlSchemaValidatorPushAttribute(vctxt,
27264 NULL, ielem->nodeLine, attributes[j], attributes[j+2], 0, 27340 NULL, ielem->nodeLine, attributes[j], attributes[j+2], 0,
27265 value, 1); 27341 value, 1);
27266 if (ret == -1) { 27342 if (ret == -1) {
27267 VERROR_INT("xmlSchemaSAXHandleStartElementNs", 27343 VERROR_INT("xmlSchemaSAXHandleStartElementNs",
27268 "calling xmlSchemaValidatorPushAttribute()"); 27344 "calling xmlSchemaValidatorPushAttribute()");
27269 goto internal_error; 27345 goto internal_error;
27270 } 27346 }
27271 } 27347 }
27272 } 27348 }
27273 /* 27349 /*
27274 * Validate the element. 27350 * Validate the element.
27275 */ 27351 */
27276 ret = xmlSchemaValidateElem(vctxt); 27352 ret = xmlSchemaValidateElem(vctxt);
27277 if (ret != 0) { 27353 if (ret != 0) {
27278 if (ret == -1) { 27354 if (ret == -1) {
27279 VERROR_INT("xmlSchemaSAXHandleStartElementNs", 27355 VERROR_INT("xmlSchemaSAXHandleStartElementNs",
27280 "calling xmlSchemaValidateElem()"); 27356 "calling xmlSchemaValidateElem()");
27281 goto internal_error; 27357 goto internal_error;
27282 } 27358 }
27283 goto exit; 27359 goto exit;
27284 } 27360 }
27285 27361
27286 exit: 27362 exit:
27287 return; 27363 return;
27288 internal_error: 27364 internal_error:
27289 vctxt->err = -1; 27365 vctxt->err = -1;
27290 xmlStopParser(vctxt->parserCtxt); 27366 xmlStopParser(vctxt->parserCtxt);
27291 return; 27367 return;
27292 } 27368 }
27293 27369
27294 static void 27370 static void
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
27384 * TODO: Should we clear the flags? 27460 * TODO: Should we clear the flags?
27385 * Might be problematic if one reuses the context 27461 * Might be problematic if one reuses the context
27386 * and assumes that the options remain the same. 27462 * and assumes that the options remain the same.
27387 */ 27463 */
27388 vctxt->flags = 0; 27464 vctxt->flags = 0;
27389 vctxt->validationRoot = NULL; 27465 vctxt->validationRoot = NULL;
27390 vctxt->doc = NULL; 27466 vctxt->doc = NULL;
27391 #ifdef LIBXML_READER_ENABLED 27467 #ifdef LIBXML_READER_ENABLED
27392 vctxt->reader = NULL; 27468 vctxt->reader = NULL;
27393 #endif 27469 #endif
27394 vctxt->hasKeyrefs = 0; 27470 vctxt->hasKeyrefs = 0;
27395 27471
27396 if (vctxt->value != NULL) { 27472 if (vctxt->value != NULL) {
27397 xmlSchemaFreeValue(vctxt->value); 27473 xmlSchemaFreeValue(vctxt->value);
27398 vctxt->value = NULL; 27474 vctxt->value = NULL;
27399 } 27475 }
27400 /* 27476 /*
27401 * Augmented IDC information. 27477 * Augmented IDC information.
27402 */ 27478 */
27403 if (vctxt->aidcs != NULL) { 27479 if (vctxt->aidcs != NULL) {
27404 xmlSchemaIDCAugPtr cur = vctxt->aidcs, next; 27480 xmlSchemaIDCAugPtr cur = vctxt->aidcs, next;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
27454 if (vctxt->elemInfos != NULL) { 27530 if (vctxt->elemInfos != NULL) {
27455 int i; 27531 int i;
27456 xmlSchemaNodeInfoPtr ei; 27532 xmlSchemaNodeInfoPtr ei;
27457 27533
27458 for (i = 0; i < vctxt->sizeElemInfos; i++) { 27534 for (i = 0; i < vctxt->sizeElemInfos; i++) {
27459 ei = vctxt->elemInfos[i]; 27535 ei = vctxt->elemInfos[i];
27460 if (ei == NULL) 27536 if (ei == NULL)
27461 break; 27537 break;
27462 xmlSchemaClearElemInfo(vctxt, ei); 27538 xmlSchemaClearElemInfo(vctxt, ei);
27463 } 27539 }
27464 } 27540 }
27465 xmlSchemaItemListClear(vctxt->nodeQNames); 27541 xmlSchemaItemListClear(vctxt->nodeQNames);
27466 /* Recreate the dict. */ 27542 /* Recreate the dict. */
27467 xmlDictFree(vctxt->dict); 27543 xmlDictFree(vctxt->dict);
27468 /* 27544 /*
27469 * TODO: Is is save to recreate it? Do we have a scenario 27545 * TODO: Is is save to recreate it? Do we have a scenario
27470 * where the user provides the dict? 27546 * where the user provides the dict?
27471 */ 27547 */
27472 vctxt->dict = xmlDictCreate(); 27548 vctxt->dict = xmlDictCreate();
27473 } 27549 }
27474 27550
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
27556 if (ctxt->dict != NULL) 27632 if (ctxt->dict != NULL)
27557 xmlDictFree(ctxt->dict); 27633 xmlDictFree(ctxt->dict);
27558 xmlFree(ctxt); 27634 xmlFree(ctxt);
27559 } 27635 }
27560 27636
27561 /** 27637 /**
27562 * xmlSchemaIsValid: 27638 * xmlSchemaIsValid:
27563 * @ctxt: the schema validation context 27639 * @ctxt: the schema validation context
27564 * 27640 *
27565 * Check if any error was detected during validation. 27641 * Check if any error was detected during validation.
27566 * 27642 *
27567 * Returns 1 if valid so far, 0 if errors were detected, and -1 in case 27643 * Returns 1 if valid so far, 0 if errors were detected, and -1 in case
27568 * of internal error. 27644 * of internal error.
27569 */ 27645 */
27570 int 27646 int
27571 xmlSchemaIsValid(xmlSchemaValidCtxtPtr ctxt) 27647 xmlSchemaIsValid(xmlSchemaValidCtxtPtr ctxt)
27572 { 27648 {
27573 if (ctxt == NULL) 27649 if (ctxt == NULL)
27574 return(-1); 27650 return(-1);
27575 return(ctxt->err == 0); 27651 return(ctxt->err == 0);
27576 } 27652 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
27615 ctxt->serror = serror; 27691 ctxt->serror = serror;
27616 ctxt->error = NULL; 27692 ctxt->error = NULL;
27617 ctxt->warning = NULL; 27693 ctxt->warning = NULL;
27618 ctxt->errCtxt = ctx; 27694 ctxt->errCtxt = ctx;
27619 if (ctxt->pctxt != NULL) 27695 if (ctxt->pctxt != NULL)
27620 xmlSchemaSetParserStructuredErrors(ctxt->pctxt, serror, ctx); 27696 xmlSchemaSetParserStructuredErrors(ctxt->pctxt, serror, ctx);
27621 } 27697 }
27622 27698
27623 /** 27699 /**
27624 * xmlSchemaGetValidErrors: 27700 * xmlSchemaGetValidErrors:
27625 * @ctxt:» a XML-Schema validation context 27701 * @ctxt: a XML-Schema validation context
27626 * @err: the error function result 27702 * @err: the error function result
27627 * @warn: the warning function result 27703 * @warn: the warning function result
27628 * @ctx: the functions context result 27704 * @ctx: the functions context result
27629 * 27705 *
27630 * Get the error and warning callback informations 27706 * Get the error and warning callback informations
27631 * 27707 *
27632 * Returns -1 in case of error and 0 otherwise 27708 * Returns -1 in case of error and 0 otherwise
27633 */ 27709 */
27634 int 27710 int
27635 xmlSchemaGetValidErrors(xmlSchemaValidCtxtPtr ctxt, 27711 xmlSchemaGetValidErrors(xmlSchemaValidCtxtPtr ctxt,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
27676 for (i = 1; i < (int) sizeof(int) * 8; i++) { 27752 for (i = 1; i < (int) sizeof(int) * 8; i++) {
27677 if (options & 1<<i) 27753 if (options & 1<<i)
27678 return (-1); 27754 return (-1);
27679 } 27755 }
27680 ctxt->options = options; 27756 ctxt->options = options;
27681 return (0); 27757 return (0);
27682 } 27758 }
27683 27759
27684 /** 27760 /**
27685 * xmlSchemaValidCtxtGetOptions: 27761 * xmlSchemaValidCtxtGetOptions:
27686 * @ctxt:» a schema validation context 27762 * @ctxt: a schema validation context
27687 * 27763 *
27688 * Get the validation context options. 27764 * Get the validation context options.
27689 * 27765 *
27690 * Returns the option combination or -1 on error. 27766 * Returns the option combination or -1 on error.
27691 */ 27767 */
27692 int 27768 int
27693 xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt) 27769 xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt)
27694 27770
27695 { 27771 {
27696 if (ctxt == NULL) 27772 if (ctxt == NULL)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
27744 vctxt->nbAttrInfos = 0; 27820 vctxt->nbAttrInfos = 0;
27745 if (node->properties != NULL) { 27821 if (node->properties != NULL) {
27746 attr = node->properties; 27822 attr = node->properties;
27747 do { 27823 do {
27748 if (attr->ns != NULL) 27824 if (attr->ns != NULL)
27749 nsName = attr->ns->href; 27825 nsName = attr->ns->href;
27750 else 27826 else
27751 nsName = NULL; 27827 nsName = NULL;
27752 ret = xmlSchemaValidatorPushAttribute(vctxt, 27828 ret = xmlSchemaValidatorPushAttribute(vctxt,
27753 (xmlNodePtr) attr, 27829 (xmlNodePtr) attr,
27754 » » » /* 27830 » » » /*
27755 * Note that we give it the line number of the 27831 * Note that we give it the line number of the
27756 * parent element. 27832 * parent element.
27757 */ 27833 */
27758 ielem->nodeLine, 27834 ielem->nodeLine,
27759 attr->name, nsName, 0, 27835 attr->name, nsName, 0,
27760 xmlNodeListGetString(attr->doc, attr->children, 1), 1); 27836 xmlNodeListGetString(attr->doc, attr->children, 1), 1);
27761 if (ret == -1) { 27837 if (ret == -1) {
27762 VERROR_INT("xmlSchemaDocWalk", 27838 VERROR_INT("xmlSchemaDocWalk",
27763 "calling xmlSchemaValidatorPushAttribute()"); 27839 "calling xmlSchemaValidatorPushAttribute()");
27764 goto internal_error; 27840 goto internal_error;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
27800 goto internal_error; 27876 goto internal_error;
27801 } 27877 }
27802 /* 27878 /*
27803 * DOC VAL TODO: Should we skip further validation of the 27879 * DOC VAL TODO: Should we skip further validation of the
27804 * element content here? 27880 * element content here?
27805 */ 27881 */
27806 } else if ((node->type == XML_ENTITY_NODE) || 27882 } else if ((node->type == XML_ENTITY_NODE) ||
27807 (node->type == XML_ENTITY_REF_NODE)) { 27883 (node->type == XML_ENTITY_REF_NODE)) {
27808 /* 27884 /*
27809 * DOC VAL TODO: What to do with entities? 27885 * DOC VAL TODO: What to do with entities?
27810 » */» 27886 » */
27811 VERROR_INT("xmlSchemaVDocWalk", 27887 VERROR_INT("xmlSchemaVDocWalk",
27812 "there is at least one entity reference in the node-tree " 27888 "there is at least one entity reference in the node-tree "
27813 "currently being validated. Processing of entities with " 27889 "currently being validated. Processing of entities with "
27814 "this XML Schema processor is not supported (yet). Please " 27890 "this XML Schema processor is not supported (yet). Please "
27815 "substitute entities before validation."); 27891 "substitute entities before validation.");
27816 goto internal_error; 27892 goto internal_error;
27817 } else { 27893 } else {
27818 goto leave_node; 27894 goto leave_node;
27819 /* 27895 /*
27820 * DOC VAL TODO: XInclude nodes, etc. 27896 * DOC VAL TODO: XInclude nodes, etc.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
27860 exit: 27936 exit:
27861 return (ret); 27937 return (ret);
27862 internal_error: 27938 internal_error:
27863 return (-1); 27939 return (-1);
27864 } 27940 }
27865 27941
27866 static int 27942 static int
27867 xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) { 27943 xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) {
27868 /* 27944 /*
27869 * Some initialization. 27945 * Some initialization.
27870 */ 27946 */
27871 vctxt->err = 0; 27947 vctxt->err = 0;
27872 vctxt->nberrors = 0; 27948 vctxt->nberrors = 0;
27873 vctxt->depth = -1; 27949 vctxt->depth = -1;
27874 vctxt->skipDepth = -1; 27950 vctxt->skipDepth = -1;
27875 vctxt->xsiAssemble = 0; 27951 vctxt->xsiAssemble = 0;
27876 vctxt->hasKeyrefs = 0; 27952 vctxt->hasKeyrefs = 0;
27877 #ifdef ENABLE_IDC_NODE_TABLES_TEST 27953 #ifdef ENABLE_IDC_NODE_TABLES_TEST
27878 vctxt->createIDCNodeTables = 1; 27954 vctxt->createIDCNodeTables = 1;
27879 #else 27955 #else
27880 vctxt->createIDCNodeTables = 0; 27956 vctxt->createIDCNodeTables = 0;
27881 #endif 27957 #endif
27882 /* 27958 /*
27883 * Create a schema + parser if necessary. 27959 * Create a schema + parser if necessary.
27884 */ 27960 */
27885 if (vctxt->schema == NULL) { 27961 if (vctxt->schema == NULL) {
27886 xmlSchemaParserCtxtPtr pctxt; 27962 xmlSchemaParserCtxtPtr pctxt;
27887 » 27963
27888 vctxt->xsiAssemble = 1; 27964 vctxt->xsiAssemble = 1;
27889 » /* 27965 » /*
27890 * If not schema was given then we will create a schema 27966 * If not schema was given then we will create a schema
27891 * dynamically using XSI schema locations. 27967 * dynamically using XSI schema locations.
27892 * 27968 *
27893 * Create the schema parser context. 27969 * Create the schema parser context.
27894 */ 27970 */
27895 if ((vctxt->pctxt == NULL) && 27971 if ((vctxt->pctxt == NULL) &&
27896 (xmlSchemaCreatePCtxtOnVCtxt(vctxt) == -1)) 27972 (xmlSchemaCreatePCtxtOnVCtxt(vctxt) == -1))
27897 return (-1); 27973 return (-1);
27898 pctxt = vctxt->pctxt; 27974 pctxt = vctxt->pctxt;
27899 pctxt->xsiAssemble = 1; 27975 pctxt->xsiAssemble = 1;
27900 /* 27976 /*
27901 * Create the schema. 27977 * Create the schema.
27902 */ 27978 */
27903 vctxt->schema = xmlSchemaNewSchema(pctxt); 27979 vctxt->schema = xmlSchemaNewSchema(pctxt);
27904 if (vctxt->schema == NULL) 27980 if (vctxt->schema == NULL)
27905 » return (-1);» » 27981 » return (-1);
27906 » /* 27982 » /*
27907 * Create the schema construction context. 27983 * Create the schema construction context.
27908 */ 27984 */
27909 pctxt->constructor = xmlSchemaConstructionCtxtCreate(pctxt->dict); 27985 pctxt->constructor = xmlSchemaConstructionCtxtCreate(pctxt->dict);
27910 if (pctxt->constructor == NULL) 27986 if (pctxt->constructor == NULL)
27911 return(-1); 27987 return(-1);
27912 pctxt->constructor->mainSchema = vctxt->schema; 27988 pctxt->constructor->mainSchema = vctxt->schema;
27913 /* 27989 /*
27914 * Take ownership of the constructor to be able to free it. 27990 * Take ownership of the constructor to be able to free it.
27915 */ 27991 */
27916 pctxt->ownsConstructor = 1; 27992 pctxt->ownsConstructor = 1;
27917 }» 27993 }
27918 /* 27994 /*
27919 * Augment the IDC definitions for the main schema and all imported ones 27995 * Augment the IDC definitions for the main schema and all imported ones
27920 * NOTE: main schema if the first in the imported list 27996 * NOTE: main schema if the first in the imported list
27921 */ 27997 */
27922 xmlHashScan(vctxt->schema->schemasImports,(xmlHashScanner)xmlSchemaAugmentIm portedIDC, vctxt); 27998 xmlHashScan(vctxt->schema->schemasImports,(xmlHashScanner)xmlSchemaAugmentIm portedIDC, vctxt);
27923 27999
27924 return(0); 28000 return(0);
27925 } 28001 }
27926 28002
27927 static void 28003 static void
27928 xmlSchemaPostRun(xmlSchemaValidCtxtPtr vctxt) { 28004 xmlSchemaPostRun(xmlSchemaValidCtxtPtr vctxt) {
27929 if (vctxt->xsiAssemble) { 28005 if (vctxt->xsiAssemble) {
27930 if (vctxt->schema != NULL) { 28006 if (vctxt->schema != NULL) {
27931 xmlSchemaFree(vctxt->schema); 28007 xmlSchemaFree(vctxt->schema);
27932 vctxt->schema = NULL; 28008 vctxt->schema = NULL;
27933 } 28009 }
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
28328 if (ctxt == NULL) 28404 if (ctxt == NULL)
28329 return; 28405 return;
28330 if ((ctxt != NULL) && (ctxt->user_sax != NULL) && 28406 if ((ctxt != NULL) && (ctxt->user_sax != NULL) &&
28331 (ctxt->user_sax->reference != NULL)) 28407 (ctxt->user_sax->reference != NULL))
28332 ctxt->user_sax->reference(ctxt->user_data, name); 28408 ctxt->user_sax->reference(ctxt->user_data, name);
28333 if (ctxt->ctxt != NULL) 28409 if (ctxt->ctxt != NULL)
28334 xmlSchemaSAXHandleReference(ctxt->user_data, name); 28410 xmlSchemaSAXHandleReference(ctxt->user_data, name);
28335 } 28411 }
28336 28412
28337 static void 28413 static void
28338 startElementNsSplit(void *ctx, const xmlChar * localname, 28414 startElementNsSplit(void *ctx, const xmlChar * localname,
28339 » » const xmlChar * prefix, const xmlChar * URI, 28415 » » const xmlChar * prefix, const xmlChar * URI,
28340 » » int nb_namespaces, const xmlChar ** namespaces, 28416 » » int nb_namespaces, const xmlChar ** namespaces,
28341 » » int nb_attributes, int nb_defaulted, 28417 » » int nb_attributes, int nb_defaulted,
28342 const xmlChar ** attributes) { 28418 const xmlChar ** attributes) {
28343 xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx; 28419 xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx;
28344 if (ctxt == NULL) 28420 if (ctxt == NULL)
28345 return; 28421 return;
28346 if ((ctxt->user_sax != NULL) && 28422 if ((ctxt->user_sax != NULL) &&
28347 (ctxt->user_sax->startElementNs != NULL)) 28423 (ctxt->user_sax->startElementNs != NULL))
28348 ctxt->user_sax->startElementNs(ctxt->user_data, localname, prefix, 28424 ctxt->user_sax->startElementNs(ctxt->user_data, localname, prefix,
28349 URI, nb_namespaces, namespaces, 28425 URI, nb_namespaces, namespaces,
28350 nb_attributes, nb_defaulted, 28426 nb_attributes, nb_defaulted,
28351 attributes); 28427 attributes);
28352 if (ctxt->ctxt != NULL) 28428 if (ctxt->ctxt != NULL)
28353 xmlSchemaSAXHandleStartElementNs(ctxt->ctxt, localname, prefix, 28429 xmlSchemaSAXHandleStartElementNs(ctxt->ctxt, localname, prefix,
28354 URI, nb_namespaces, namespaces, 28430 URI, nb_namespaces, namespaces,
28355 nb_attributes, nb_defaulted, 28431 nb_attributes, nb_defaulted,
28356 attributes); 28432 attributes);
28357 } 28433 }
28358 28434
28359 static void 28435 static void
28360 endElementNsSplit(void *ctx, const xmlChar * localname, 28436 endElementNsSplit(void *ctx, const xmlChar * localname,
28361 const xmlChar * prefix, const xmlChar * URI) { 28437 const xmlChar * prefix, const xmlChar * URI) {
28362 xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx; 28438 xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx;
28363 if (ctxt == NULL) 28439 if (ctxt == NULL)
28364 return; 28440 return;
28365 if ((ctxt->user_sax != NULL) && 28441 if ((ctxt->user_sax != NULL) &&
28366 (ctxt->user_sax->endElementNs != NULL)) 28442 (ctxt->user_sax->endElementNs != NULL))
28367 ctxt->user_sax->endElementNs(ctxt->user_data, localname, prefix, URI); 28443 ctxt->user_sax->endElementNs(ctxt->user_data, localname, prefix, URI);
28368 if (ctxt->ctxt != NULL) 28444 if (ctxt->ctxt != NULL)
28369 xmlSchemaSAXHandleEndElementNs(ctxt->ctxt, localname, prefix, URI); 28445 xmlSchemaSAXHandleEndElementNs(ctxt->ctxt, localname, prefix, URI);
28370 } 28446 }
(...skipping 20 matching lines...) Expand all
28391 28467
28392 if ((ctxt == NULL) || (sax == NULL) || (user_data == NULL)) 28468 if ((ctxt == NULL) || (sax == NULL) || (user_data == NULL))
28393 return(NULL); 28469 return(NULL);
28394 28470
28395 /* 28471 /*
28396 * We only allow to plug into SAX2 event streams 28472 * We only allow to plug into SAX2 event streams
28397 */ 28473 */
28398 old_sax = *sax; 28474 old_sax = *sax;
28399 if ((old_sax != NULL) && (old_sax->initialized != XML_SAX2_MAGIC)) 28475 if ((old_sax != NULL) && (old_sax->initialized != XML_SAX2_MAGIC))
28400 return(NULL); 28476 return(NULL);
28401 if ((old_sax != NULL) && 28477 if ((old_sax != NULL) &&
28402 (old_sax->startElementNs == NULL) && (old_sax->endElementNs == NULL) && 28478 (old_sax->startElementNs == NULL) && (old_sax->endElementNs == NULL) &&
28403 ((old_sax->startElement != NULL) || (old_sax->endElement != NULL))) 28479 ((old_sax->startElement != NULL) || (old_sax->endElement != NULL)))
28404 return(NULL); 28480 return(NULL);
28405 28481
28406 /* 28482 /*
28407 * everything seems right allocate the local data needed for that layer 28483 * everything seems right allocate the local data needed for that layer
28408 */ 28484 */
28409 ret = (xmlSchemaSAXPlugPtr) xmlMalloc(sizeof(xmlSchemaSAXPlugStruct)); 28485 ret = (xmlSchemaSAXPlugPtr) xmlMalloc(sizeof(xmlSchemaSAXPlugStruct));
28410 if (ret == NULL) { 28486 if (ret == NULL) {
28411 return(NULL); 28487 return(NULL);
28412 } 28488 }
28413 memset(ret, 0, sizeof(xmlSchemaSAXPlugStruct)); 28489 memset(ret, 0, sizeof(xmlSchemaSAXPlugStruct));
28414 ret->magic = XML_SAX_PLUG_MAGIC; 28490 ret->magic = XML_SAX_PLUG_MAGIC;
28415 ret->schemas_sax.initialized = XML_SAX2_MAGIC; 28491 ret->schemas_sax.initialized = XML_SAX2_MAGIC;
28416 ret->ctxt = ctxt; 28492 ret->ctxt = ctxt;
28417 ret->user_sax_ptr = sax; 28493 ret->user_sax_ptr = sax;
28418 ret->user_sax = old_sax; 28494 ret->user_sax = old_sax;
28419 if (old_sax == NULL) {» 28495 if (old_sax == NULL) {
28420 /* 28496 /*
28421 * go direct, no need for the split block and functions. 28497 * go direct, no need for the split block and functions.
28422 */ 28498 */
28423 ret->schemas_sax.startElementNs = xmlSchemaSAXHandleStartElementNs; 28499 ret->schemas_sax.startElementNs = xmlSchemaSAXHandleStartElementNs;
28424 ret->schemas_sax.endElementNs = xmlSchemaSAXHandleEndElementNs; 28500 ret->schemas_sax.endElementNs = xmlSchemaSAXHandleEndElementNs;
28425 /* 28501 /*
28426 * Note that we use the same text-function for both, to prevent 28502 * Note that we use the same text-function for both, to prevent
28427 * the parser from testing for ignorable whitespace. 28503 * the parser from testing for ignorable whitespace.
28428 */ 28504 */
28429 ret->schemas_sax.ignorableWhitespace = xmlSchemaSAXHandleText; 28505 ret->schemas_sax.ignorableWhitespace = xmlSchemaSAXHandleText;
28430 ret->schemas_sax.characters = xmlSchemaSAXHandleText; 28506 ret->schemas_sax.characters = xmlSchemaSAXHandleText;
28431 28507
28432 ret->schemas_sax.cdataBlock = xmlSchemaSAXHandleCDataSection; 28508 ret->schemas_sax.cdataBlock = xmlSchemaSAXHandleCDataSection;
28433 ret->schemas_sax.reference = xmlSchemaSAXHandleReference; 28509 ret->schemas_sax.reference = xmlSchemaSAXHandleReference;
28434 28510
28435 ret->user_data = ctxt; 28511 ret->user_data = ctxt;
28436 *user_data = ctxt; 28512 *user_data = ctxt;
28437 } else { 28513 } else {
28438 /* 28514 /*
28439 * for each callback unused by Schemas initialize it to the Split 28515 * for each callback unused by Schemas initialize it to the Split
28440 » * routine only if non NULL in the user block, this can speed up 28516 » * routine only if non NULL in the user block, this can speed up
28441 * things at the SAX level. 28517 * things at the SAX level.
28442 */ 28518 */
28443 if (old_sax->internalSubset != NULL) 28519 if (old_sax->internalSubset != NULL)
28444 ret->schemas_sax.internalSubset = internalSubsetSplit; 28520 ret->schemas_sax.internalSubset = internalSubsetSplit;
28445 if (old_sax->isStandalone != NULL) 28521 if (old_sax->isStandalone != NULL)
28446 ret->schemas_sax.isStandalone = isStandaloneSplit; 28522 ret->schemas_sax.isStandalone = isStandaloneSplit;
28447 if (old_sax->hasInternalSubset != NULL) 28523 if (old_sax->hasInternalSubset != NULL)
28448 ret->schemas_sax.hasInternalSubset = hasInternalSubsetSplit; 28524 ret->schemas_sax.hasInternalSubset = hasInternalSubsetSplit;
28449 if (old_sax->hasExternalSubset != NULL) 28525 if (old_sax->hasExternalSubset != NULL)
28450 ret->schemas_sax.hasExternalSubset = hasExternalSubsetSplit; 28526 ret->schemas_sax.hasExternalSubset = hasExternalSubsetSplit;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
28583 pctxt = xmlNewParserCtxt(); 28659 pctxt = xmlNewParserCtxt();
28584 if (pctxt == NULL) 28660 if (pctxt == NULL)
28585 return (-1); 28661 return (-1);
28586 old_sax = pctxt->sax; 28662 old_sax = pctxt->sax;
28587 pctxt->sax = sax; 28663 pctxt->sax = sax;
28588 pctxt->userData = user_data; 28664 pctxt->userData = user_data;
28589 #if 0 28665 #if 0
28590 if (options) 28666 if (options)
28591 xmlCtxtUseOptions(pctxt, options); 28667 xmlCtxtUseOptions(pctxt, options);
28592 #endif 28668 #endif
28593 pctxt->linenumbers = 1; 28669 pctxt->linenumbers = 1;
28594 28670
28595 inputStream = xmlNewIOInputStream(pctxt, input, enc);; 28671 inputStream = xmlNewIOInputStream(pctxt, input, enc);;
28596 if (inputStream == NULL) { 28672 if (inputStream == NULL) {
28597 ret = -1; 28673 ret = -1;
28598 goto done; 28674 goto done;
28599 } 28675 }
28600 inputPush(pctxt, inputStream); 28676 inputPush(pctxt, inputStream);
28601 ctxt->parserCtxt = pctxt; 28677 ctxt->parserCtxt = pctxt;
28602 ctxt->input = input; 28678 ctxt->input = input;
28603 28679
28604 /* 28680 /*
28605 * Plug the validation and launch the parsing 28681 * Plug the validation and launch the parsing
28606 */ 28682 */
28607 plug = xmlSchemaSAXPlug(ctxt, &(pctxt->sax), &(pctxt->userData)); 28683 plug = xmlSchemaSAXPlug(ctxt, &(pctxt->sax), &(pctxt->userData));
28608 if (plug == NULL) { 28684 if (plug == NULL) {
28609 ret = -1; 28685 ret = -1;
28610 goto done; 28686 goto done;
28611 } 28687 }
28612 ctxt->input = input; 28688 ctxt->input = input;
28613 ctxt->enc = enc; 28689 ctxt->enc = enc;
28614 ctxt->sax = pctxt->sax; 28690 ctxt->sax = pctxt->sax;
28615 ctxt->flags |= XML_SCHEMA_VALID_CTXT_FLAG_STREAM; 28691 ctxt->flags |= XML_SCHEMA_VALID_CTXT_FLAG_STREAM;
28616 ret = xmlSchemaVStart(ctxt); 28692 ret = xmlSchemaVStart(ctxt);
28617 28693
28618 if ((ret == 0) && (! ctxt->parserCtxt->wellFormed)) { 28694 if ((ret == 0) && (! ctxt->parserCtxt->wellFormed)) {
28619 ret = ctxt->parserCtxt->errNo; 28695 ret = ctxt->parserCtxt->errNo;
28620 if (ret == 0) 28696 if (ret == 0)
28621 ret = 1; 28697 ret = 1;
28622 } 28698 }
28623 28699
28624 done: 28700 done:
28625 ctxt->parserCtxt = NULL; 28701 ctxt->parserCtxt = NULL;
28626 ctxt->sax = NULL; 28702 ctxt->sax = NULL;
28627 ctxt->input = NULL; 28703 ctxt->input = NULL;
28628 if (plug != NULL) { 28704 if (plug != NULL) {
28629 xmlSchemaSAXUnplug(plug); 28705 xmlSchemaSAXUnplug(plug);
28630 } 28706 }
28631 /* cleanup */ 28707 /* cleanup */
28632 if (pctxt != NULL) { 28708 if (pctxt != NULL) {
(...skipping 18 matching lines...) Expand all
28651 int 28727 int
28652 xmlSchemaValidateFile(xmlSchemaValidCtxtPtr ctxt, 28728 xmlSchemaValidateFile(xmlSchemaValidCtxtPtr ctxt,
28653 const char * filename, 28729 const char * filename,
28654 int options ATTRIBUTE_UNUSED) 28730 int options ATTRIBUTE_UNUSED)
28655 { 28731 {
28656 int ret; 28732 int ret;
28657 xmlParserInputBufferPtr input; 28733 xmlParserInputBufferPtr input;
28658 28734
28659 if ((ctxt == NULL) || (filename == NULL)) 28735 if ((ctxt == NULL) || (filename == NULL))
28660 return (-1); 28736 return (-1);
28661 28737
28662 input = xmlParserInputBufferCreateFilename(filename, 28738 input = xmlParserInputBufferCreateFilename(filename,
28663 XML_CHAR_ENCODING_NONE); 28739 XML_CHAR_ENCODING_NONE);
28664 if (input == NULL) 28740 if (input == NULL)
28665 return (-1); 28741 return (-1);
28666 ret = xmlSchemaValidateStream(ctxt, input, XML_CHAR_ENCODING_NONE, 28742 ret = xmlSchemaValidateStream(ctxt, input, XML_CHAR_ENCODING_NONE,
28667 » NULL, NULL); 28743 » NULL, NULL);
28668 return (ret); 28744 return (ret);
28669 } 28745 }
28670 28746
28747 /**
28748 * xmlSchemaValidCtxtGetParserCtxt:
28749 * @ctxt: a schema validation context
28750 *
28751 * allow access to the parser context of the schema validation context
28752 *
28753 * Returns the parser context of the schema validation context or NULL
28754 * in case of error.
28755 */
28756 xmlParserCtxtPtr
28757 xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt)
28758 {
28759 if (ctxt == NULL)
28760 return(NULL);
28761 return (ctxt->parserCtxt);
28762 }
28763
28671 #define bottom_xmlschemas 28764 #define bottom_xmlschemas
28672 #include "elfgcchack.h" 28765 #include "elfgcchack.h"
28673 #endif /* LIBXML_SCHEMAS_ENABLED */ 28766 #endif /* LIBXML_SCHEMAS_ENABLED */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698