schemasInternals.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  1. /*
  2. * Summary: internal interfaces for XML Schemas
  3. * Description: internal interfaces for the XML Schemas handling
  4. * and schema validity checking
  5. * The Schemas development is a Work In Progress.
  6. * Some of those interfaces are not garanteed to be API or ABI stable !
  7. *
  8. * Copy: See Copyright for the status of this software.
  9. *
  10. * Author: Daniel Veillard
  11. */
  12. #ifndef __XML_SCHEMA_INTERNALS_H__
  13. #define __XML_SCHEMA_INTERNALS_H__
  14. #include <libxml/xmlversion.h>
  15. #ifdef LIBXML_SCHEMAS_ENABLED
  16. #include <libxml/xmlregexp.h>
  17. #include <libxml/hash.h>
  18. #include <libxml/dict.h>
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. typedef enum {
  23. XML_SCHEMAS_UNKNOWN = 0,
  24. XML_SCHEMAS_STRING,
  25. XML_SCHEMAS_NORMSTRING,
  26. XML_SCHEMAS_DECIMAL,
  27. XML_SCHEMAS_TIME,
  28. XML_SCHEMAS_GDAY,
  29. XML_SCHEMAS_GMONTH,
  30. XML_SCHEMAS_GMONTHDAY,
  31. XML_SCHEMAS_GYEAR,
  32. XML_SCHEMAS_GYEARMONTH,
  33. XML_SCHEMAS_DATE,
  34. XML_SCHEMAS_DATETIME,
  35. XML_SCHEMAS_DURATION,
  36. XML_SCHEMAS_FLOAT,
  37. XML_SCHEMAS_DOUBLE,
  38. XML_SCHEMAS_BOOLEAN,
  39. XML_SCHEMAS_TOKEN,
  40. XML_SCHEMAS_LANGUAGE,
  41. XML_SCHEMAS_NMTOKEN,
  42. XML_SCHEMAS_NMTOKENS,
  43. XML_SCHEMAS_NAME,
  44. XML_SCHEMAS_QNAME,
  45. XML_SCHEMAS_NCNAME,
  46. XML_SCHEMAS_ID,
  47. XML_SCHEMAS_IDREF,
  48. XML_SCHEMAS_IDREFS,
  49. XML_SCHEMAS_ENTITY,
  50. XML_SCHEMAS_ENTITIES,
  51. XML_SCHEMAS_NOTATION,
  52. XML_SCHEMAS_ANYURI,
  53. XML_SCHEMAS_INTEGER,
  54. XML_SCHEMAS_NPINTEGER,
  55. XML_SCHEMAS_NINTEGER,
  56. XML_SCHEMAS_NNINTEGER,
  57. XML_SCHEMAS_PINTEGER,
  58. XML_SCHEMAS_INT,
  59. XML_SCHEMAS_UINT,
  60. XML_SCHEMAS_LONG,
  61. XML_SCHEMAS_ULONG,
  62. XML_SCHEMAS_SHORT,
  63. XML_SCHEMAS_USHORT,
  64. XML_SCHEMAS_BYTE,
  65. XML_SCHEMAS_UBYTE,
  66. XML_SCHEMAS_HEXBINARY,
  67. XML_SCHEMAS_BASE64BINARY,
  68. XML_SCHEMAS_ANYTYPE,
  69. XML_SCHEMAS_ANYSIMPLETYPE
  70. }
  71. xmlSchemaValType;
  72. /*
  73. * XML Schemas defines multiple type of types.
  74. */
  75. typedef enum {
  76. XML_SCHEMA_TYPE_BASIC = 1, /* A built-in datatype */
  77. XML_SCHEMA_TYPE_ANY,
  78. XML_SCHEMA_TYPE_FACET,
  79. XML_SCHEMA_TYPE_SIMPLE,
  80. XML_SCHEMA_TYPE_COMPLEX,
  81. XML_SCHEMA_TYPE_SEQUENCE = 6,
  82. XML_SCHEMA_TYPE_CHOICE,
  83. XML_SCHEMA_TYPE_ALL,
  84. XML_SCHEMA_TYPE_SIMPLE_CONTENT,
  85. XML_SCHEMA_TYPE_COMPLEX_CONTENT,
  86. XML_SCHEMA_TYPE_UR,
  87. XML_SCHEMA_TYPE_RESTRICTION,
  88. XML_SCHEMA_TYPE_EXTENSION,
  89. XML_SCHEMA_TYPE_ELEMENT,
  90. XML_SCHEMA_TYPE_ATTRIBUTE,
  91. XML_SCHEMA_TYPE_ATTRIBUTEGROUP,
  92. XML_SCHEMA_TYPE_GROUP,
  93. XML_SCHEMA_TYPE_NOTATION,
  94. XML_SCHEMA_TYPE_LIST,
  95. XML_SCHEMA_TYPE_UNION,
  96. XML_SCHEMA_TYPE_ANY_ATTRIBUTE,
  97. XML_SCHEMA_TYPE_IDC_UNIQUE,
  98. XML_SCHEMA_TYPE_IDC_KEY,
  99. XML_SCHEMA_TYPE_IDC_KEYREF,
  100. XML_SCHEMA_TYPE_PARTICLE = 25,
  101. XML_SCHEMA_TYPE_ATTRIBUTE_USE,
  102. XML_SCHEMA_FACET_MININCLUSIVE = 1000,
  103. XML_SCHEMA_FACET_MINEXCLUSIVE,
  104. XML_SCHEMA_FACET_MAXINCLUSIVE,
  105. XML_SCHEMA_FACET_MAXEXCLUSIVE,
  106. XML_SCHEMA_FACET_TOTALDIGITS,
  107. XML_SCHEMA_FACET_FRACTIONDIGITS,
  108. XML_SCHEMA_FACET_PATTERN,
  109. XML_SCHEMA_FACET_ENUMERATION,
  110. XML_SCHEMA_FACET_WHITESPACE,
  111. XML_SCHEMA_FACET_LENGTH,
  112. XML_SCHEMA_FACET_MAXLENGTH,
  113. XML_SCHEMA_FACET_MINLENGTH,
  114. XML_SCHEMA_EXTRA_QNAMEREF = 2000,
  115. XML_SCHEMA_EXTRA_ATTR_USE_PROHIB
  116. } xmlSchemaTypeType;
  117. typedef enum {
  118. XML_SCHEMA_CONTENT_UNKNOWN = 0,
  119. XML_SCHEMA_CONTENT_EMPTY = 1,
  120. XML_SCHEMA_CONTENT_ELEMENTS,
  121. XML_SCHEMA_CONTENT_MIXED,
  122. XML_SCHEMA_CONTENT_SIMPLE,
  123. XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS, /* Obsolete */
  124. XML_SCHEMA_CONTENT_BASIC,
  125. XML_SCHEMA_CONTENT_ANY
  126. } xmlSchemaContentType;
  127. typedef struct _xmlSchemaVal xmlSchemaVal;
  128. typedef xmlSchemaVal *xmlSchemaValPtr;
  129. typedef struct _xmlSchemaType xmlSchemaType;
  130. typedef xmlSchemaType *xmlSchemaTypePtr;
  131. typedef struct _xmlSchemaFacet xmlSchemaFacet;
  132. typedef xmlSchemaFacet *xmlSchemaFacetPtr;
  133. /**
  134. * Annotation
  135. */
  136. typedef struct _xmlSchemaAnnot xmlSchemaAnnot;
  137. typedef xmlSchemaAnnot *xmlSchemaAnnotPtr;
  138. struct _xmlSchemaAnnot {
  139. struct _xmlSchemaAnnot *next;
  140. xmlNodePtr content; /* the annotation */
  141. };
  142. /**
  143. * XML_SCHEMAS_ANYATTR_SKIP:
  144. *
  145. * Skip unknown attribute from validation
  146. * Obsolete, not used anymore.
  147. */
  148. #define XML_SCHEMAS_ANYATTR_SKIP 1
  149. /**
  150. * XML_SCHEMAS_ANYATTR_LAX:
  151. *
  152. * Ignore validation non definition on attributes
  153. * Obsolete, not used anymore.
  154. */
  155. #define XML_SCHEMAS_ANYATTR_LAX 2
  156. /**
  157. * XML_SCHEMAS_ANYATTR_STRICT:
  158. *
  159. * Apply strict validation rules on attributes
  160. * Obsolete, not used anymore.
  161. */
  162. #define XML_SCHEMAS_ANYATTR_STRICT 3
  163. /**
  164. * XML_SCHEMAS_ANY_SKIP:
  165. *
  166. * Skip unknown attribute from validation
  167. */
  168. #define XML_SCHEMAS_ANY_SKIP 1
  169. /**
  170. * XML_SCHEMAS_ANY_LAX:
  171. *
  172. * Used by wildcards.
  173. * Validate if type found, don't worry if not found
  174. */
  175. #define XML_SCHEMAS_ANY_LAX 2
  176. /**
  177. * XML_SCHEMAS_ANY_STRICT:
  178. *
  179. * Used by wildcards.
  180. * Apply strict validation rules
  181. */
  182. #define XML_SCHEMAS_ANY_STRICT 3
  183. /**
  184. * XML_SCHEMAS_ATTR_USE_PROHIBITED:
  185. *
  186. * Used by wildcards.
  187. * The attribute is prohibited.
  188. */
  189. #define XML_SCHEMAS_ATTR_USE_PROHIBITED 0
  190. /**
  191. * XML_SCHEMAS_ATTR_USE_REQUIRED:
  192. *
  193. * The attribute is required.
  194. */
  195. #define XML_SCHEMAS_ATTR_USE_REQUIRED 1
  196. /**
  197. * XML_SCHEMAS_ATTR_USE_OPTIONAL:
  198. *
  199. * The attribute is optional.
  200. */
  201. #define XML_SCHEMAS_ATTR_USE_OPTIONAL 2
  202. /**
  203. * XML_SCHEMAS_ATTR_GLOBAL:
  204. *
  205. * allow elements in no namespace
  206. */
  207. #define XML_SCHEMAS_ATTR_GLOBAL 1 << 0
  208. /**
  209. * XML_SCHEMAS_ATTR_NSDEFAULT:
  210. *
  211. * allow elements in no namespace
  212. */
  213. #define XML_SCHEMAS_ATTR_NSDEFAULT 1 << 7
  214. /**
  215. * XML_SCHEMAS_ATTR_INTERNAL_RESOLVED:
  216. *
  217. * this is set when the "type" and "ref" references
  218. * have been resolved.
  219. */
  220. #define XML_SCHEMAS_ATTR_INTERNAL_RESOLVED 1 << 8
  221. /**
  222. * XML_SCHEMAS_ATTR_FIXED:
  223. *
  224. * the attribute has a fixed value
  225. */
  226. #define XML_SCHEMAS_ATTR_FIXED 1 << 9
  227. /**
  228. * xmlSchemaAttribute:
  229. * An attribute definition.
  230. */
  231. typedef struct _xmlSchemaAttribute xmlSchemaAttribute;
  232. typedef xmlSchemaAttribute *xmlSchemaAttributePtr;
  233. struct _xmlSchemaAttribute {
  234. xmlSchemaTypeType type;
  235. struct _xmlSchemaAttribute *next; /* the next attribute (not used?) */
  236. const xmlChar *name; /* the name of the declaration */
  237. const xmlChar *id; /* Deprecated; not used */
  238. const xmlChar *ref; /* Deprecated; not used */
  239. const xmlChar *refNs; /* Deprecated; not used */
  240. const xmlChar *typeName; /* the local name of the type definition */
  241. const xmlChar *typeNs; /* the ns URI of the type definition */
  242. xmlSchemaAnnotPtr annot;
  243. xmlSchemaTypePtr base; /* Deprecated; not used */
  244. int occurs; /* Deprecated; not used */
  245. const xmlChar *defValue; /* The initial value of the value constraint */
  246. xmlSchemaTypePtr subtypes; /* the type definition */
  247. xmlNodePtr node;
  248. const xmlChar *targetNamespace;
  249. int flags;
  250. const xmlChar *refPrefix; /* Deprecated; not used */
  251. xmlSchemaValPtr defVal; /* The compiled value constraint */
  252. xmlSchemaAttributePtr refDecl; /* Deprecated; not used */
  253. };
  254. /**
  255. * xmlSchemaAttributeLink:
  256. * Used to build a list of attribute uses on complexType definitions.
  257. * WARNING: Deprecated; not used.
  258. */
  259. typedef struct _xmlSchemaAttributeLink xmlSchemaAttributeLink;
  260. typedef xmlSchemaAttributeLink *xmlSchemaAttributeLinkPtr;
  261. struct _xmlSchemaAttributeLink {
  262. struct _xmlSchemaAttributeLink *next;/* the next attribute link ... */
  263. struct _xmlSchemaAttribute *attr;/* the linked attribute */
  264. };
  265. /**
  266. * XML_SCHEMAS_WILDCARD_COMPLETE:
  267. *
  268. * If the wildcard is complete.
  269. */
  270. #define XML_SCHEMAS_WILDCARD_COMPLETE 1 << 0
  271. /**
  272. * xmlSchemaCharValueLink:
  273. * Used to build a list of namespaces on wildcards.
  274. */
  275. typedef struct _xmlSchemaWildcardNs xmlSchemaWildcardNs;
  276. typedef xmlSchemaWildcardNs *xmlSchemaWildcardNsPtr;
  277. struct _xmlSchemaWildcardNs {
  278. struct _xmlSchemaWildcardNs *next;/* the next constraint link ... */
  279. const xmlChar *value;/* the value */
  280. };
  281. /**
  282. * xmlSchemaWildcard.
  283. * A wildcard.
  284. */
  285. typedef struct _xmlSchemaWildcard xmlSchemaWildcard;
  286. typedef xmlSchemaWildcard *xmlSchemaWildcardPtr;
  287. struct _xmlSchemaWildcard {
  288. xmlSchemaTypeType type; /* The kind of type */
  289. const xmlChar *id; /* Deprecated; not used */
  290. xmlSchemaAnnotPtr annot;
  291. xmlNodePtr node;
  292. int minOccurs; /* Deprecated; not used */
  293. int maxOccurs; /* Deprecated; not used */
  294. int processContents;
  295. int any; /* Indicates if the ns constraint is of ##any */
  296. xmlSchemaWildcardNsPtr nsSet; /* The list of allowed namespaces */
  297. xmlSchemaWildcardNsPtr negNsSet; /* The negated namespace */
  298. int flags;
  299. };
  300. /**
  301. * XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED:
  302. *
  303. * The attribute wildcard has been already builded.
  304. */
  305. #define XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED 1 << 0
  306. /**
  307. * XML_SCHEMAS_ATTRGROUP_GLOBAL:
  308. *
  309. * The attribute wildcard has been already builded.
  310. */
  311. #define XML_SCHEMAS_ATTRGROUP_GLOBAL 1 << 1
  312. /**
  313. * XML_SCHEMAS_ATTRGROUP_MARKED:
  314. *
  315. * Marks the attr group as marked; used for circular checks.
  316. */
  317. #define XML_SCHEMAS_ATTRGROUP_MARKED 1 << 2
  318. /**
  319. * XML_SCHEMAS_ATTRGROUP_REDEFINED:
  320. *
  321. * The attr group was redefined.
  322. */
  323. #define XML_SCHEMAS_ATTRGROUP_REDEFINED 1 << 3
  324. /**
  325. * XML_SCHEMAS_ATTRGROUP_HAS_REFS:
  326. *
  327. * Whether this attr. group contains attr. group references.
  328. */
  329. #define XML_SCHEMAS_ATTRGROUP_HAS_REFS 1 << 4
  330. /**
  331. * An attribute group definition.
  332. *
  333. * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures
  334. * must be kept similar
  335. */
  336. typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup;
  337. typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr;
  338. struct _xmlSchemaAttributeGroup {
  339. xmlSchemaTypeType type; /* The kind of type */
  340. struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
  341. const xmlChar *name;
  342. const xmlChar *id;
  343. const xmlChar *ref; /* Deprecated; not used */
  344. const xmlChar *refNs; /* Deprecated; not used */
  345. xmlSchemaAnnotPtr annot;
  346. xmlSchemaAttributePtr attributes; /* Deprecated; not used */
  347. xmlNodePtr node;
  348. int flags;
  349. xmlSchemaWildcardPtr attributeWildcard;
  350. const xmlChar *refPrefix; /* Deprecated; not used */
  351. xmlSchemaAttributeGroupPtr refItem; /* Deprecated; not used */
  352. const xmlChar *targetNamespace;
  353. void *attrUses;
  354. };
  355. /**
  356. * xmlSchemaTypeLink:
  357. * Used to build a list of types (e.g. member types of
  358. * simpleType with variety "union").
  359. */
  360. typedef struct _xmlSchemaTypeLink xmlSchemaTypeLink;
  361. typedef xmlSchemaTypeLink *xmlSchemaTypeLinkPtr;
  362. struct _xmlSchemaTypeLink {
  363. struct _xmlSchemaTypeLink *next;/* the next type link ... */
  364. xmlSchemaTypePtr type;/* the linked type */
  365. };
  366. /**
  367. * xmlSchemaFacetLink:
  368. * Used to build a list of facets.
  369. */
  370. typedef struct _xmlSchemaFacetLink xmlSchemaFacetLink;
  371. typedef xmlSchemaFacetLink *xmlSchemaFacetLinkPtr;
  372. struct _xmlSchemaFacetLink {
  373. struct _xmlSchemaFacetLink *next;/* the next facet link ... */
  374. xmlSchemaFacetPtr facet;/* the linked facet */
  375. };
  376. /**
  377. * XML_SCHEMAS_TYPE_MIXED:
  378. *
  379. * the element content type is mixed
  380. */
  381. #define XML_SCHEMAS_TYPE_MIXED 1 << 0
  382. /**
  383. * XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION:
  384. *
  385. * the simple or complex type has a derivation method of "extension".
  386. */
  387. #define XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION 1 << 1
  388. /**
  389. * XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION:
  390. *
  391. * the simple or complex type has a derivation method of "restriction".
  392. */
  393. #define XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION 1 << 2
  394. /**
  395. * XML_SCHEMAS_TYPE_GLOBAL:
  396. *
  397. * the type is global
  398. */
  399. #define XML_SCHEMAS_TYPE_GLOBAL 1 << 3
  400. /**
  401. * XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD:
  402. *
  403. * the complexType owns an attribute wildcard, i.e.
  404. * it can be freed by the complexType
  405. */
  406. #define XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD 1 << 4 /* Obsolete. */
  407. /**
  408. * XML_SCHEMAS_TYPE_VARIETY_ABSENT:
  409. *
  410. * the simpleType has a variety of "absent".
  411. * TODO: Actually not necessary :-/, since if
  412. * none of the variety flags occur then it's
  413. * automatically absent.
  414. */
  415. #define XML_SCHEMAS_TYPE_VARIETY_ABSENT 1 << 5
  416. /**
  417. * XML_SCHEMAS_TYPE_VARIETY_LIST:
  418. *
  419. * the simpleType has a variety of "list".
  420. */
  421. #define XML_SCHEMAS_TYPE_VARIETY_LIST 1 << 6
  422. /**
  423. * XML_SCHEMAS_TYPE_VARIETY_UNION:
  424. *
  425. * the simpleType has a variety of "union".
  426. */
  427. #define XML_SCHEMAS_TYPE_VARIETY_UNION 1 << 7
  428. /**
  429. * XML_SCHEMAS_TYPE_VARIETY_ATOMIC:
  430. *
  431. * the simpleType has a variety of "union".
  432. */
  433. #define XML_SCHEMAS_TYPE_VARIETY_ATOMIC 1 << 8
  434. /**
  435. * XML_SCHEMAS_TYPE_FINAL_EXTENSION:
  436. *
  437. * the complexType has a final of "extension".
  438. */
  439. #define XML_SCHEMAS_TYPE_FINAL_EXTENSION 1 << 9
  440. /**
  441. * XML_SCHEMAS_TYPE_FINAL_RESTRICTION:
  442. *
  443. * the simpleType/complexType has a final of "restriction".
  444. */
  445. #define XML_SCHEMAS_TYPE_FINAL_RESTRICTION 1 << 10
  446. /**
  447. * XML_SCHEMAS_TYPE_FINAL_LIST:
  448. *
  449. * the simpleType has a final of "list".
  450. */
  451. #define XML_SCHEMAS_TYPE_FINAL_LIST 1 << 11
  452. /**
  453. * XML_SCHEMAS_TYPE_FINAL_UNION:
  454. *
  455. * the simpleType has a final of "union".
  456. */
  457. #define XML_SCHEMAS_TYPE_FINAL_UNION 1 << 12
  458. /**
  459. * XML_SCHEMAS_TYPE_FINAL_DEFAULT:
  460. *
  461. * the simpleType has a final of "default".
  462. */
  463. #define XML_SCHEMAS_TYPE_FINAL_DEFAULT 1 << 13
  464. /**
  465. * XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE:
  466. *
  467. * Marks the item as a builtin primitive.
  468. */
  469. #define XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE 1 << 14
  470. /**
  471. * XML_SCHEMAS_TYPE_MARKED:
  472. *
  473. * Marks the item as marked; used for circular checks.
  474. */
  475. #define XML_SCHEMAS_TYPE_MARKED 1 << 16
  476. /**
  477. * XML_SCHEMAS_TYPE_BLOCK_DEFAULT:
  478. *
  479. * the complexType did not specify 'block' so use the default of the
  480. * <schema> item.
  481. */
  482. #define XML_SCHEMAS_TYPE_BLOCK_DEFAULT 1 << 17
  483. /**
  484. * XML_SCHEMAS_TYPE_BLOCK_EXTENSION:
  485. *
  486. * the complexType has a 'block' of "extension".
  487. */
  488. #define XML_SCHEMAS_TYPE_BLOCK_EXTENSION 1 << 18
  489. /**
  490. * XML_SCHEMAS_TYPE_BLOCK_RESTRICTION:
  491. *
  492. * the complexType has a 'block' of "restriction".
  493. */
  494. #define XML_SCHEMAS_TYPE_BLOCK_RESTRICTION 1 << 19
  495. /**
  496. * XML_SCHEMAS_TYPE_ABSTRACT:
  497. *
  498. * the simple/complexType is abstract.
  499. */
  500. #define XML_SCHEMAS_TYPE_ABSTRACT 1 << 20
  501. /**
  502. * XML_SCHEMAS_TYPE_FACETSNEEDVALUE:
  503. *
  504. * indicates if the facets need a computed value
  505. */
  506. #define XML_SCHEMAS_TYPE_FACETSNEEDVALUE 1 << 21
  507. /**
  508. * XML_SCHEMAS_TYPE_INTERNAL_RESOLVED:
  509. *
  510. * indicates that the type was typefixed
  511. */
  512. #define XML_SCHEMAS_TYPE_INTERNAL_RESOLVED 1 << 22
  513. /**
  514. * XML_SCHEMAS_TYPE_INTERNAL_INVALID:
  515. *
  516. * indicates that the type is invalid
  517. */
  518. #define XML_SCHEMAS_TYPE_INTERNAL_INVALID 1 << 23
  519. /**
  520. * XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE:
  521. *
  522. * a whitespace-facet value of "preserve"
  523. */
  524. #define XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE 1 << 24
  525. /**
  526. * XML_SCHEMAS_TYPE_WHITESPACE_REPLACE:
  527. *
  528. * a whitespace-facet value of "replace"
  529. */
  530. #define XML_SCHEMAS_TYPE_WHITESPACE_REPLACE 1 << 25
  531. /**
  532. * XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE:
  533. *
  534. * a whitespace-facet value of "collapse"
  535. */
  536. #define XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE 1 << 26
  537. /**
  538. * XML_SCHEMAS_TYPE_HAS_FACETS:
  539. *
  540. * has facets
  541. */
  542. #define XML_SCHEMAS_TYPE_HAS_FACETS 1 << 27
  543. /**
  544. * XML_SCHEMAS_TYPE_NORMVALUENEEDED:
  545. *
  546. * indicates if the facets (pattern) need a normalized value
  547. */
  548. #define XML_SCHEMAS_TYPE_NORMVALUENEEDED 1 << 28
  549. /**
  550. * XML_SCHEMAS_TYPE_FIXUP_1:
  551. *
  552. * First stage of fixup was done.
  553. */
  554. #define XML_SCHEMAS_TYPE_FIXUP_1 1 << 29
  555. /**
  556. * XML_SCHEMAS_TYPE_REDEFINED:
  557. *
  558. * The type was redefined.
  559. */
  560. #define XML_SCHEMAS_TYPE_REDEFINED 1 << 30
  561. /**
  562. * XML_SCHEMAS_TYPE_REDEFINING:
  563. *
  564. * The type redefines an other type.
  565. */
  566. /* #define XML_SCHEMAS_TYPE_REDEFINING 1 << 31 */
  567. /**
  568. * _xmlSchemaType:
  569. *
  570. * Schemas type definition.
  571. */
  572. struct _xmlSchemaType {
  573. xmlSchemaTypeType type; /* The kind of type */
  574. struct _xmlSchemaType *next; /* the next type if in a sequence ... */
  575. const xmlChar *name;
  576. const xmlChar *id ; /* Deprecated; not used */
  577. const xmlChar *ref; /* Deprecated; not used */
  578. const xmlChar *refNs; /* Deprecated; not used */
  579. xmlSchemaAnnotPtr annot;
  580. xmlSchemaTypePtr subtypes;
  581. xmlSchemaAttributePtr attributes; /* Deprecated; not used */
  582. xmlNodePtr node;
  583. int minOccurs; /* Deprecated; not used */
  584. int maxOccurs; /* Deprecated; not used */
  585. int flags;
  586. xmlSchemaContentType contentType;
  587. const xmlChar *base; /* Base type's local name */
  588. const xmlChar *baseNs; /* Base type's target namespace */
  589. xmlSchemaTypePtr baseType; /* The base type component */
  590. xmlSchemaFacetPtr facets; /* Local facets */
  591. struct _xmlSchemaType *redef; /* Deprecated; not used */
  592. int recurse; /* Obsolete */
  593. xmlSchemaAttributeLinkPtr *attributeUses; /* Deprecated; not used */
  594. xmlSchemaWildcardPtr attributeWildcard;
  595. int builtInType; /* Type of built-in types. */
  596. xmlSchemaTypeLinkPtr memberTypes; /* member-types if a union type. */
  597. xmlSchemaFacetLinkPtr facetSet; /* All facets (incl. inherited) */
  598. const xmlChar *refPrefix; /* Deprecated; not used */
  599. xmlSchemaTypePtr contentTypeDef; /* Used for the simple content of complex types.
  600. Could we use @subtypes for this? */
  601. xmlRegexpPtr contModel; /* Holds the automaton of the content model */
  602. const xmlChar *targetNamespace;
  603. void *attrUses;
  604. };
  605. /*
  606. * xmlSchemaElement:
  607. * An element definition.
  608. *
  609. * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of
  610. * structures must be kept similar
  611. */
  612. /**
  613. * XML_SCHEMAS_ELEM_NILLABLE:
  614. *
  615. * the element is nillable
  616. */
  617. #define XML_SCHEMAS_ELEM_NILLABLE 1 << 0
  618. /**
  619. * XML_SCHEMAS_ELEM_GLOBAL:
  620. *
  621. * the element is global
  622. */
  623. #define XML_SCHEMAS_ELEM_GLOBAL 1 << 1
  624. /**
  625. * XML_SCHEMAS_ELEM_DEFAULT:
  626. *
  627. * the element has a default value
  628. */
  629. #define XML_SCHEMAS_ELEM_DEFAULT 1 << 2
  630. /**
  631. * XML_SCHEMAS_ELEM_FIXED:
  632. *
  633. * the element has a fixed value
  634. */
  635. #define XML_SCHEMAS_ELEM_FIXED 1 << 3
  636. /**
  637. * XML_SCHEMAS_ELEM_ABSTRACT:
  638. *
  639. * the element is abstract
  640. */
  641. #define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4
  642. /**
  643. * XML_SCHEMAS_ELEM_TOPLEVEL:
  644. *
  645. * the element is top level
  646. * obsolete: use XML_SCHEMAS_ELEM_GLOBAL instead
  647. */
  648. #define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5
  649. /**
  650. * XML_SCHEMAS_ELEM_REF:
  651. *
  652. * the element is a reference to a type
  653. */
  654. #define XML_SCHEMAS_ELEM_REF 1 << 6
  655. /**
  656. * XML_SCHEMAS_ELEM_NSDEFAULT:
  657. *
  658. * allow elements in no namespace
  659. * Obsolete, not used anymore.
  660. */
  661. #define XML_SCHEMAS_ELEM_NSDEFAULT 1 << 7
  662. /**
  663. * XML_SCHEMAS_ELEM_INTERNAL_RESOLVED:
  664. *
  665. * this is set when "type", "ref", "substitutionGroup"
  666. * references have been resolved.
  667. */
  668. #define XML_SCHEMAS_ELEM_INTERNAL_RESOLVED 1 << 8
  669. /**
  670. * XML_SCHEMAS_ELEM_CIRCULAR:
  671. *
  672. * a helper flag for the search of circular references.
  673. */
  674. #define XML_SCHEMAS_ELEM_CIRCULAR 1 << 9
  675. /**
  676. * XML_SCHEMAS_ELEM_BLOCK_ABSENT:
  677. *
  678. * the "block" attribute is absent
  679. */
  680. #define XML_SCHEMAS_ELEM_BLOCK_ABSENT 1 << 10
  681. /**
  682. * XML_SCHEMAS_ELEM_BLOCK_EXTENSION:
  683. *
  684. * disallowed substitutions are absent
  685. */
  686. #define XML_SCHEMAS_ELEM_BLOCK_EXTENSION 1 << 11
  687. /**
  688. * XML_SCHEMAS_ELEM_BLOCK_RESTRICTION:
  689. *
  690. * disallowed substitutions: "restriction"
  691. */
  692. #define XML_SCHEMAS_ELEM_BLOCK_RESTRICTION 1 << 12
  693. /**
  694. * XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION:
  695. *
  696. * disallowed substitutions: "substituion"
  697. */
  698. #define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION 1 << 13
  699. /**
  700. * XML_SCHEMAS_ELEM_FINAL_ABSENT:
  701. *
  702. * substitution group exclusions are absent
  703. */
  704. #define XML_SCHEMAS_ELEM_FINAL_ABSENT 1 << 14
  705. /**
  706. * XML_SCHEMAS_ELEM_FINAL_EXTENSION:
  707. *
  708. * substitution group exclusions: "extension"
  709. */
  710. #define XML_SCHEMAS_ELEM_FINAL_EXTENSION 1 << 15
  711. /**
  712. * XML_SCHEMAS_ELEM_FINAL_RESTRICTION:
  713. *
  714. * substitution group exclusions: "restriction"
  715. */
  716. #define XML_SCHEMAS_ELEM_FINAL_RESTRICTION 1 << 16
  717. /**
  718. * XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD:
  719. *
  720. * the declaration is a substitution group head
  721. */
  722. #define XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD 1 << 17
  723. /**
  724. * XML_SCHEMAS_ELEM_INTERNAL_CHECKED:
  725. *
  726. * this is set when the elem decl has been checked against
  727. * all constraints
  728. */
  729. #define XML_SCHEMAS_ELEM_INTERNAL_CHECKED 1 << 18
  730. typedef struct _xmlSchemaElement xmlSchemaElement;
  731. typedef xmlSchemaElement *xmlSchemaElementPtr;
  732. struct _xmlSchemaElement {
  733. xmlSchemaTypeType type; /* The kind of type */
  734. struct _xmlSchemaType *next; /* Not used? */
  735. const xmlChar *name;
  736. const xmlChar *id; /* Deprecated; not used */
  737. const xmlChar *ref; /* Deprecated; not used */
  738. const xmlChar *refNs; /* Deprecated; not used */
  739. xmlSchemaAnnotPtr annot;
  740. xmlSchemaTypePtr subtypes; /* the type definition */
  741. xmlSchemaAttributePtr attributes;
  742. xmlNodePtr node;
  743. int minOccurs; /* Deprecated; not used */
  744. int maxOccurs; /* Deprecated; not used */
  745. int flags;
  746. const xmlChar *targetNamespace;
  747. const xmlChar *namedType;
  748. const xmlChar *namedTypeNs;
  749. const xmlChar *substGroup;
  750. const xmlChar *substGroupNs;
  751. const xmlChar *scope;
  752. const xmlChar *value; /* The original value of the value constraint. */
  753. struct _xmlSchemaElement *refDecl; /* This will now be used for the
  754. substitution group affiliation */
  755. xmlRegexpPtr contModel; /* Obsolete for WXS, maybe used for RelaxNG */
  756. xmlSchemaContentType contentType;
  757. const xmlChar *refPrefix; /* Deprecated; not used */
  758. xmlSchemaValPtr defVal; /* The compiled value contraint. */
  759. void *idcs; /* The identity-constraint defs */
  760. };
  761. /*
  762. * XML_SCHEMAS_FACET_UNKNOWN:
  763. *
  764. * unknown facet handling
  765. */
  766. #define XML_SCHEMAS_FACET_UNKNOWN 0
  767. /*
  768. * XML_SCHEMAS_FACET_PRESERVE:
  769. *
  770. * preserve the type of the facet
  771. */
  772. #define XML_SCHEMAS_FACET_PRESERVE 1
  773. /*
  774. * XML_SCHEMAS_FACET_REPLACE:
  775. *
  776. * replace the type of the facet
  777. */
  778. #define XML_SCHEMAS_FACET_REPLACE 2
  779. /*
  780. * XML_SCHEMAS_FACET_COLLAPSE:
  781. *
  782. * collapse the types of the facet
  783. */
  784. #define XML_SCHEMAS_FACET_COLLAPSE 3
  785. /**
  786. * A facet definition.
  787. */
  788. struct _xmlSchemaFacet {
  789. xmlSchemaTypeType type; /* The kind of type */
  790. struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */
  791. const xmlChar *value; /* The original value */
  792. const xmlChar *id; /* Obsolete */
  793. xmlSchemaAnnotPtr annot;
  794. xmlNodePtr node;
  795. int fixed; /* XML_SCHEMAS_FACET_PRESERVE, etc. */
  796. int whitespace;
  797. xmlSchemaValPtr val; /* The compiled value */
  798. xmlRegexpPtr regexp; /* The regex for patterns */
  799. };
  800. /**
  801. * A notation definition.
  802. */
  803. typedef struct _xmlSchemaNotation xmlSchemaNotation;
  804. typedef xmlSchemaNotation *xmlSchemaNotationPtr;
  805. struct _xmlSchemaNotation {
  806. xmlSchemaTypeType type; /* The kind of type */
  807. const xmlChar *name;
  808. xmlSchemaAnnotPtr annot;
  809. const xmlChar *identifier;
  810. const xmlChar *targetNamespace;
  811. };
  812. /*
  813. * TODO: Actually all those flags used for the schema should sit
  814. * on the schema parser context, since they are used only
  815. * during parsing an XML schema document, and not available
  816. * on the component level as per spec.
  817. */
  818. /**
  819. * XML_SCHEMAS_QUALIF_ELEM:
  820. *
  821. * Reflects elementFormDefault == qualified in
  822. * an XML schema document.
  823. */
  824. #define XML_SCHEMAS_QUALIF_ELEM 1 << 0
  825. /**
  826. * XML_SCHEMAS_QUALIF_ATTR:
  827. *
  828. * Reflects attributeFormDefault == qualified in
  829. * an XML schema document.
  830. */
  831. #define XML_SCHEMAS_QUALIF_ATTR 1 << 1
  832. /**
  833. * XML_SCHEMAS_FINAL_DEFAULT_EXTENSION:
  834. *
  835. * the schema has "extension" in the set of finalDefault.
  836. */
  837. #define XML_SCHEMAS_FINAL_DEFAULT_EXTENSION 1 << 2
  838. /**
  839. * XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION:
  840. *
  841. * the schema has "restriction" in the set of finalDefault.
  842. */
  843. #define XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION 1 << 3
  844. /**
  845. * XML_SCHEMAS_FINAL_DEFAULT_LIST:
  846. *
  847. * the cshema has "list" in the set of finalDefault.
  848. */
  849. #define XML_SCHEMAS_FINAL_DEFAULT_LIST 1 << 4
  850. /**
  851. * XML_SCHEMAS_FINAL_DEFAULT_UNION:
  852. *
  853. * the schema has "union" in the set of finalDefault.
  854. */
  855. #define XML_SCHEMAS_FINAL_DEFAULT_UNION 1 << 5
  856. /**
  857. * XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION:
  858. *
  859. * the schema has "extension" in the set of blockDefault.
  860. */
  861. #define XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION 1 << 6
  862. /**
  863. * XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION:
  864. *
  865. * the schema has "restriction" in the set of blockDefault.
  866. */
  867. #define XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION 1 << 7
  868. /**
  869. * XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION:
  870. *
  871. * the schema has "substitution" in the set of blockDefault.
  872. */
  873. #define XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION 1 << 8
  874. /**
  875. * XML_SCHEMAS_INCLUDING_CONVERT_NS:
  876. *
  877. * the schema is currently including an other schema with
  878. * no target namespace.
  879. */
  880. #define XML_SCHEMAS_INCLUDING_CONVERT_NS 1 << 9
  881. /**
  882. * _xmlSchema:
  883. *
  884. * A Schemas definition
  885. */
  886. struct _xmlSchema {
  887. const xmlChar *name; /* schema name */
  888. const xmlChar *targetNamespace; /* the target namespace */
  889. const xmlChar *version;
  890. const xmlChar *id; /* Obsolete */
  891. xmlDocPtr doc;
  892. xmlSchemaAnnotPtr annot;
  893. int flags;
  894. xmlHashTablePtr typeDecl;
  895. xmlHashTablePtr attrDecl;
  896. xmlHashTablePtr attrgrpDecl;
  897. xmlHashTablePtr elemDecl;
  898. xmlHashTablePtr notaDecl;
  899. xmlHashTablePtr schemasImports;
  900. void *_private; /* unused by the library for users or bindings */
  901. xmlHashTablePtr groupDecl;
  902. xmlDictPtr dict;
  903. void *includes; /* the includes, this is opaque for now */
  904. int preserve; /* whether to free the document */
  905. int counter; /* used to give ononymous components unique names */
  906. xmlHashTablePtr idcDef; /* All identity-constraint defs. */
  907. void *volatiles; /* Obsolete */
  908. };
  909. XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type);
  910. XMLPUBFUN void XMLCALL xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard);
  911. #ifdef __cplusplus
  912. }
  913. #endif
  914. #endif /* LIBXML_SCHEMAS_ENABLED */
  915. #endif /* __XML_SCHEMA_INTERNALS_H__ */