XmlSchemaElement.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. // Author: Dwivedi, Ajay kumar
  2. // [email protected]
  3. using System;
  4. using System.Xml;
  5. using System.Xml.Serialization;
  6. using System.ComponentModel;
  7. namespace System.Xml.Schema
  8. {
  9. /// <summary>
  10. /// Summary description for XmlSchemaElement.
  11. /// </summary>
  12. public class XmlSchemaElement : XmlSchemaParticle
  13. {
  14. private XmlSchemaDerivationMethod block;
  15. private XmlSchemaDerivationMethod blockResolved;
  16. private XmlSchemaObjectCollection constraints;
  17. private string defaultValue;
  18. private object elementType;
  19. private XmlSchemaDerivationMethod final;
  20. private XmlSchemaDerivationMethod finalResolved;
  21. private string fixedValue;
  22. private XmlSchemaForm form;
  23. private bool isAbstract;
  24. private bool isNillable;
  25. private string name;
  26. private XmlQualifiedName qName;
  27. private XmlQualifiedName refName;
  28. private XmlSchemaType schemaType;
  29. private XmlQualifiedName schemaTypeName;
  30. private XmlQualifiedName substitutionGroup;
  31. internal bool parentIsSchema = false;
  32. private string targetNamespace;
  33. private string hash;
  34. private static string xmlname = "element";
  35. public XmlSchemaElement()
  36. {
  37. block = XmlSchemaDerivationMethod.None;
  38. final = XmlSchemaDerivationMethod.None;
  39. constraints = new XmlSchemaObjectCollection();
  40. qName = XmlQualifiedName.Empty;
  41. refName = XmlQualifiedName.Empty;
  42. schemaTypeName = XmlQualifiedName.Empty;
  43. substitutionGroup = XmlQualifiedName.Empty;
  44. substitutionGroup = XmlQualifiedName.Empty;
  45. }
  46. #region Attributes
  47. [DefaultValue(false)]
  48. [System.Xml.Serialization.XmlAttribute("abstract")]
  49. public bool IsAbstract
  50. {
  51. get{ return isAbstract; }
  52. set{ isAbstract = value; }
  53. }
  54. [DefaultValue(XmlSchemaDerivationMethod.None)]
  55. [System.Xml.Serialization.XmlAttribute("block")]
  56. public XmlSchemaDerivationMethod Block
  57. {
  58. get{ return block; }
  59. set{ block = value; }
  60. }
  61. [DefaultValue(null)]
  62. [System.Xml.Serialization.XmlAttribute("default")]
  63. public string DefaultValue
  64. {
  65. get{ return defaultValue; }
  66. set{ defaultValue = value; }
  67. }
  68. [DefaultValue(XmlSchemaDerivationMethod.None)]
  69. [System.Xml.Serialization.XmlAttribute("final")]
  70. public XmlSchemaDerivationMethod Final
  71. {
  72. get{ return final; }
  73. set{ final = value; }
  74. }
  75. [DefaultValue(null)]
  76. [System.Xml.Serialization.XmlAttribute("fixed")]
  77. public string FixedValue
  78. {
  79. get{ return fixedValue; }
  80. set{ fixedValue = value; }
  81. }
  82. [DefaultValue(XmlSchemaForm.None)]
  83. [System.Xml.Serialization.XmlAttribute("form")]
  84. public XmlSchemaForm Form
  85. {
  86. get{ return form; }
  87. set{ form = value; }
  88. }
  89. [DefaultValue(null)]
  90. [System.Xml.Serialization.XmlAttribute("name")]
  91. public string Name
  92. {
  93. get{ return name; }
  94. set{ name = value; }
  95. }
  96. [DefaultValue(false)]
  97. [System.Xml.Serialization.XmlAttribute("nillable")]
  98. public bool IsNillable
  99. {
  100. get{ return isNillable; }
  101. set{ isNillable = value; }
  102. }
  103. [System.Xml.Serialization.XmlAttribute("ref")]
  104. public XmlQualifiedName RefName
  105. {
  106. get{ return refName; }
  107. set{ refName = value;}
  108. }
  109. [System.Xml.Serialization.XmlAttribute("substitutionGroup")]
  110. public XmlQualifiedName SubstitutionGroup
  111. {
  112. get{ return substitutionGroup; }
  113. set{ substitutionGroup = value; }
  114. }
  115. [System.Xml.Serialization.XmlAttribute("type")]
  116. public XmlQualifiedName SchemaTypeName
  117. {
  118. get{ return schemaTypeName; }
  119. set{ schemaTypeName = value; }
  120. }
  121. [XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]
  122. [XmlElement("complexType",typeof(XmlSchemaComplexType),Namespace="http://www.w3.org/2001/XMLSchema")]
  123. public XmlSchemaType SchemaType
  124. {
  125. get{ return schemaType; }
  126. set{ schemaType = value; }
  127. }
  128. [XmlElement("unique",typeof(XmlSchemaUnique),Namespace="http://www.w3.org/2001/XMLSchema")]
  129. [XmlElement("key",typeof(XmlSchemaKey),Namespace="http://www.w3.org/2001/XMLSchema")]
  130. [XmlElement("keyref",typeof(XmlSchemaKeyref),Namespace="http://www.w3.org/2001/XMLSchema")]
  131. public XmlSchemaObjectCollection Constraints
  132. {
  133. get{ return constraints; }
  134. }
  135. [XmlIgnore]
  136. public XmlQualifiedName QualifiedName
  137. {
  138. get{ return qName; }
  139. }
  140. [XmlIgnore]
  141. public object ElementType
  142. {
  143. get{ return elementType; }
  144. }
  145. [XmlIgnore]
  146. public XmlSchemaDerivationMethod BlockResolved
  147. {
  148. get{ return blockResolved; }
  149. }
  150. [XmlIgnore]
  151. public XmlSchemaDerivationMethod FinalResolved
  152. {
  153. get{ return finalResolved; }
  154. }
  155. #endregion
  156. /// <remarks>
  157. /// a) If Element has parent as schema:
  158. /// 1. name must be present and of type NCName.
  159. /// 2. ref must be absent
  160. /// 3. form must be absent
  161. /// 4. minOccurs must be absent
  162. /// 5. maxOccurs must be absent
  163. /// b) If Element has parent is not schema and ref is absent
  164. /// 1. name must be present and of type NCName.
  165. /// 2. if form equals qualified or form is absent and schema's formdefault is qualifed,
  166. /// targetNamespace is schema's targetnamespace else empty.
  167. /// 3. type and either <simpleType> or <complexType> are mutually exclusive
  168. /// 4. default and fixed must not both be present.
  169. /// 5. substitutiongroup must be absent
  170. /// 6. final must be absent
  171. /// 7. abstract must be absent
  172. /// c) if the parent is not schema and ref is set
  173. /// 1. name must not be present
  174. /// 2. all of <simpleType>,<complexType>, <key>, <keyref>, <unique>, nillable,
  175. /// default, fixed, form, block and type, must be absent.
  176. /// 3. substitutiongroup is prohibited
  177. /// 4. final is prohibited
  178. /// 5. abstract is prohibited
  179. /// 6. default and fixed must not both be present.(Actually both are absent)
  180. /// </remarks>
  181. [MonoTODO]
  182. internal int Compile(ValidationEventHandler h, XmlSchema schema)
  183. {
  184. // If this is already compiled this time, simply skip.
  185. if (this.IsComplied (schema.CompilationId))
  186. return 0;
  187. if(this.defaultValue != null && this.fixedValue != null)
  188. error(h,"both default and fixed can't be present");
  189. if(parentIsSchema)
  190. {
  191. if(this.refName != null && !RefName.IsEmpty)
  192. error(h,"ref must be absent");
  193. if(this.name == null) //b1
  194. error(h,"Required attribute name must be present");
  195. else if(!XmlSchemaUtil.CheckNCName(this.name)) // b1.2
  196. error(h,"attribute name must be NCName");
  197. else
  198. this.qName = new XmlQualifiedName(this.name, schema.TargetNamespace);
  199. if(form != XmlSchemaForm.None)
  200. error(h,"form must be absent");
  201. if(MinOccursString != null)
  202. error(h,"minOccurs must be absent");
  203. if(MaxOccursString != null)
  204. error(h,"maxOccurs must be absent");
  205. XmlSchemaDerivationMethod allfinal = (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);
  206. if(final == XmlSchemaDerivationMethod.All)
  207. finalResolved = allfinal;
  208. else if(final == XmlSchemaDerivationMethod.None)
  209. finalResolved = allfinal;
  210. else
  211. {
  212. if((final & ~allfinal) != 0)
  213. warn(h,"some values for final are invalid in this context");
  214. finalResolved = final & allfinal;
  215. }
  216. XmlSchemaDerivationMethod allblock = XmlSchemaDerivationMethod.Extension |
  217. XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution;
  218. if(block == XmlSchemaDerivationMethod.All)
  219. blockResolved = allblock;
  220. else if(block == XmlSchemaDerivationMethod.None)
  221. blockResolved = allblock;
  222. else
  223. {
  224. if((block & ~allblock) != 0)
  225. warn(h,"Some of the values for block are invalid in this context");
  226. blockResolved = block & allblock;
  227. }
  228. if(schemaType != null && schemaTypeName != null && !schemaTypeName.IsEmpty)
  229. {
  230. error(h,"both schemaType and content can't be present");
  231. }
  232. //Even if both are present, read both of them.
  233. if(schemaType != null)
  234. {
  235. if(schemaType is XmlSchemaSimpleType)
  236. {
  237. errorCount += ((XmlSchemaSimpleType)schemaType).Compile(h,schema);
  238. }
  239. else if(schemaType is XmlSchemaComplexType)
  240. {
  241. errorCount += ((XmlSchemaComplexType)schemaType).Compile(h,schema);
  242. }
  243. else
  244. error(h,"only simpletype or complextype is allowed");
  245. }
  246. if(schemaTypeName != null && !schemaTypeName.IsEmpty)
  247. {
  248. if(!XmlSchemaUtil.CheckQName(SchemaTypeName))
  249. error(h,"SchemaTypeName must be an XmlQualifiedName");
  250. }
  251. if(SubstitutionGroup != null && !SubstitutionGroup.IsEmpty)
  252. {
  253. if(!XmlSchemaUtil.CheckQName(SubstitutionGroup))
  254. error(h,"SubstitutionGroup must be a valid XmlQualifiedName");
  255. }
  256. foreach(XmlSchemaObject obj in constraints)
  257. {
  258. if(obj is XmlSchemaUnique)
  259. errorCount += ((XmlSchemaUnique)obj).Compile(h,schema);
  260. else if(obj is XmlSchemaKey)
  261. errorCount += ((XmlSchemaKey)obj).Compile(h,schema);
  262. else if(obj is XmlSchemaKeyref)
  263. errorCount += ((XmlSchemaKeyref)obj).Compile(h,schema);
  264. }
  265. }
  266. else
  267. {
  268. if(substitutionGroup != null && !substitutionGroup.IsEmpty)
  269. error(h,"substitutionGroup must be absent");
  270. if(final != XmlSchemaDerivationMethod.None)
  271. error(h,"final must be absent");
  272. if(isAbstract)
  273. error(h,"abstract must be absent");
  274. //FIXME: Should we reset the values
  275. if(MinOccurs > MaxOccurs)
  276. error(h,"minOccurs must be less than or equal to maxOccurs");
  277. if(refName == null || RefName.IsEmpty)
  278. {
  279. if(form == XmlSchemaForm.Qualified || (form == XmlSchemaForm.None && schema.ElementFormDefault == XmlSchemaForm.Qualified))
  280. this.targetNamespace = schema.TargetNamespace;
  281. else
  282. this.targetNamespace = string.Empty;
  283. if(this.name == null) //b1
  284. error(h,"Required attribute name must be present");
  285. else if(!XmlSchemaUtil.CheckNCName(this.name)) // b1.2
  286. error(h,"attribute name must be NCName");
  287. else
  288. this.qName = new XmlQualifiedName(this.name, this.targetNamespace);
  289. XmlSchemaDerivationMethod allblock = XmlSchemaDerivationMethod.Extension |
  290. XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution;
  291. if(block == XmlSchemaDerivationMethod.All)
  292. blockResolved = allblock;
  293. else if(block == XmlSchemaDerivationMethod.None)
  294. blockResolved = allblock;
  295. else
  296. {
  297. if((block & ~allblock) != 0)
  298. warn(h,"Some of the values for block are invalid in this context");
  299. blockResolved = block & allblock;
  300. }
  301. if(schemaType != null && schemaTypeName != null && !schemaTypeName.IsEmpty)
  302. {
  303. error(h,"both schemaType and content can't be present");
  304. }
  305. //Even if both are present, read both of them.
  306. if(schemaType != null)
  307. {
  308. if(schemaType is XmlSchemaSimpleType)
  309. {
  310. errorCount += ((XmlSchemaSimpleType)schemaType).Compile(h,schema);
  311. }
  312. else if(schemaType is XmlSchemaComplexType)
  313. {
  314. errorCount += ((XmlSchemaComplexType)schemaType).Compile(h,schema);
  315. }
  316. else
  317. error(h,"only simpletype or complextype is allowed");
  318. }
  319. if(schemaTypeName != null && !schemaTypeName.IsEmpty)
  320. {
  321. if(!XmlSchemaUtil.CheckQName(SchemaTypeName))
  322. error(h,"SchemaTypeName must be an XmlQualifiedName");
  323. }
  324. if(SubstitutionGroup != null && !SubstitutionGroup.IsEmpty)
  325. {
  326. if(!XmlSchemaUtil.CheckQName(SubstitutionGroup))
  327. error(h,"SubstitutionGroup must be a valid XmlQualifiedName");
  328. }
  329. foreach(XmlSchemaObject obj in constraints)
  330. {
  331. if(obj is XmlSchemaUnique)
  332. errorCount += ((XmlSchemaUnique)obj).Compile(h,schema);
  333. else if(obj is XmlSchemaKey)
  334. errorCount += ((XmlSchemaKey)obj).Compile(h,schema);
  335. else if(obj is XmlSchemaKeyref)
  336. errorCount += ((XmlSchemaKeyref)obj).Compile(h,schema);
  337. }
  338. }
  339. else
  340. {
  341. if(!XmlSchemaUtil.CheckQName(RefName))
  342. error(h,"RefName must be a XmlQualifiedName");
  343. if(name != null)
  344. error(h,"name must not be present when ref is present");
  345. if(Constraints.Count != 0)
  346. error(h,"key, keyref and unique must be absent");
  347. if(isNillable)
  348. error(h,"nillable must be absent");
  349. if(defaultValue != null)
  350. error(h,"default must be absent");
  351. if(fixedValue != null)
  352. error(h,"fixed must be null");
  353. if(form != XmlSchemaForm.None)
  354. error(h,"form must be absent");
  355. if(block != XmlSchemaDerivationMethod.None)
  356. error(h,"block must be absent");
  357. if(schemaTypeName != null && !schemaTypeName.IsEmpty)
  358. error(h,"type must be absent");
  359. if(SchemaType != null)
  360. error(h,"simpleType or complexType must be absent");
  361. qName = RefName;
  362. schema.MissingElementTypeRefs.Add (this, qName);
  363. }
  364. }
  365. // PSVI contribution for XmlSchemaElement
  366. if(refName == null || RefName.IsEmpty) {
  367. if (this.schemaType != null)
  368. this.elementType = schemaType;
  369. else {
  370. XmlSchemaType xsType = schema.SchemaTypes [schemaTypeName] as XmlSchemaType;
  371. if (xsType != null)
  372. this.elementType = xsType;
  373. else
  374. this.elementType = XmlSchemaDatatype.FromName (schemaTypeName);
  375. }
  376. }
  377. XmlSchemaUtil.CompileID(Id,this,schema.IDCollection,h);
  378. this.CompilationId = schema.CompilationId;
  379. return errorCount;
  380. }
  381. internal void SetReferedElementInfo (XmlSchemaElement element)
  382. {
  383. this.elementType = element.elementType;
  384. }
  385. [MonoTODO]
  386. internal int Validate(ValidationEventHandler h)
  387. {
  388. return errorCount;
  389. }
  390. //<element
  391. // abstract = boolean : false
  392. // block = (#all | List of (extension | restriction | substitution))
  393. // default = string
  394. // final = (#all | List of (extension | restriction))
  395. // fixed = string
  396. // form = (qualified | unqualified)
  397. // id = ID
  398. // maxOccurs = (nonNegativeInteger | unbounded) : 1
  399. // minOccurs = nonNegativeInteger : 1
  400. // name = NCName
  401. // nillable = boolean : false
  402. // ref = QName
  403. // substitutionGroup = QName
  404. // type = QName
  405. // {any attributes with non-schema namespace . . .}>
  406. // Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*))
  407. //</element>
  408. internal static XmlSchemaElement Read(XmlSchemaReader reader, ValidationEventHandler h)
  409. {
  410. XmlSchemaElement element = new XmlSchemaElement();
  411. Exception innerex;
  412. reader.MoveToElement();
  413. if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
  414. {
  415. error(h,"Should not happen :1: XmlSchemaElement.Read, name="+reader.Name,null);
  416. reader.Skip();
  417. return null;
  418. }
  419. element.LineNumber = reader.LineNumber;
  420. element.LinePosition = reader.LinePosition;
  421. element.SourceUri = reader.BaseURI;
  422. while(reader.MoveToNextAttribute())
  423. {
  424. if(reader.Name == "abstract")
  425. {
  426. element.IsAbstract = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
  427. if(innerex != null)
  428. error(h,reader.Value + " is invalid value for abstract",innerex);
  429. }
  430. else if(reader.Name == "block")
  431. {
  432. element.block = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "block");
  433. if(innerex != null)
  434. warn(h,"some invalid values for block attribute were found",innerex);
  435. }
  436. else if(reader.Name == "default")
  437. {
  438. element.defaultValue = reader.Value;
  439. }
  440. else if(reader.Name == "final")
  441. {
  442. element.Final = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "block");
  443. if(innerex != null)
  444. warn(h,"some invalid values for final attribute were found",innerex);
  445. }
  446. else if(reader.Name == "fixed")
  447. {
  448. element.fixedValue = reader.Value;
  449. }
  450. else if(reader.Name == "form")
  451. {
  452. element.form = XmlSchemaUtil.ReadFormAttribute(reader,out innerex);
  453. if(innerex != null)
  454. error(h,reader.Value + " is an invalid value for form attribute",innerex);
  455. }
  456. else if(reader.Name == "id")
  457. {
  458. element.Id = reader.Value;
  459. }
  460. else if(reader.Name == "maxOccurs")
  461. {
  462. try
  463. {
  464. element.MaxOccursString = reader.Value;
  465. }
  466. catch(Exception e)
  467. {
  468. error(h,reader.Value + " is an invalid value for maxOccurs",e);
  469. }
  470. }
  471. else if(reader.Name == "minOccurs")
  472. {
  473. try
  474. {
  475. element.MinOccursString = reader.Value;
  476. }
  477. catch(Exception e)
  478. {
  479. error(h,reader.Value + " is an invalid value for minOccurs",e);
  480. }
  481. }
  482. else if(reader.Name == "name")
  483. {
  484. element.Name = reader.Value;
  485. }
  486. else if(reader.Name == "nillable")
  487. {
  488. element.IsNillable = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
  489. if(innerex != null)
  490. error(h,reader.Value + "is not a valid value for nillable",innerex);
  491. }
  492. else if(reader.Name == "ref")
  493. {
  494. element.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
  495. if(innerex != null)
  496. error(h, reader.Value + " is not a valid value for ref attribute",innerex);
  497. }
  498. else if(reader.Name == "substitutionGroup")
  499. {
  500. element.substitutionGroup = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
  501. if(innerex != null)
  502. error(h, reader.Value + " is not a valid value for substitutionGroup attribute",innerex);
  503. }
  504. else if(reader.Name == "type")
  505. {
  506. element.SchemaTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
  507. if(innerex != null)
  508. error(h, reader.Value + " is not a valid value for type attribute",innerex);
  509. }
  510. else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
  511. {
  512. error(h,reader.Name + " is not a valid attribute for element",null);
  513. }
  514. else
  515. {
  516. XmlSchemaUtil.ReadUnhandledAttribute(reader,element);
  517. }
  518. }
  519. reader.MoveToElement();
  520. if(reader.IsEmptyElement)
  521. return element;
  522. // Content: annotation?,
  523. // (simpleType | complexType)?,
  524. // (unique | key | keyref)*
  525. int level = 1;
  526. while(reader.ReadNextElement())
  527. {
  528. if(reader.NodeType == XmlNodeType.EndElement)
  529. {
  530. if(reader.LocalName != xmlname)
  531. error(h,"Should not happen :2: XmlSchemaElement.Read, name="+reader.Name,null);
  532. break;
  533. }
  534. if(level <= 1 && reader.LocalName == "annotation")
  535. {
  536. level = 2; //Only one annotation
  537. XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
  538. if(annotation != null)
  539. element.Annotation = annotation;
  540. continue;
  541. }
  542. if(level <= 2)
  543. {
  544. if(reader.LocalName == "simpleType")
  545. {
  546. level = 3;
  547. XmlSchemaSimpleType simple = XmlSchemaSimpleType.Read(reader,h);
  548. if(simple != null)
  549. element.SchemaType = simple;
  550. continue;
  551. }
  552. if(reader.LocalName == "complexType")
  553. {
  554. level = 3;
  555. XmlSchemaComplexType complex = XmlSchemaComplexType.Read(reader,h);
  556. if(complex != null)
  557. {
  558. element.SchemaType = complex;
  559. }
  560. continue;
  561. }
  562. }
  563. if(level <= 3)
  564. {
  565. if(reader.LocalName == "unique")
  566. {
  567. level = 3;
  568. XmlSchemaUnique unique = XmlSchemaUnique.Read(reader,h);
  569. if(unique != null)
  570. element.constraints.Add(unique);
  571. continue;
  572. }
  573. else if(reader.LocalName == "key")
  574. {
  575. level = 3;
  576. XmlSchemaKey key = XmlSchemaKey.Read(reader,h);
  577. if(key != null)
  578. element.constraints.Add(key);
  579. continue;
  580. }
  581. else if(reader.LocalName == "keyref")
  582. {
  583. level = 3;
  584. XmlSchemaKeyref keyref = XmlSchemaKeyref.Read(reader,h);
  585. if(keyref != null)
  586. element.constraints.Add(keyref);
  587. continue;
  588. }
  589. }
  590. reader.RaiseInvalidElementError();
  591. }
  592. return element;
  593. }
  594. }
  595. }