SchemaObjectWriter.cs 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071
  1. //------------------------------------------------------------------------------
  2. // <copyright file="XmlSchemaSerializer.cs" company="Microsoft">
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. // </copyright>
  5. // <owner current="true" primary="true">Microsoft</owner>
  6. //------------------------------------------------------------------------------
  7. namespace System.Xml.Serialization {
  8. using System;
  9. using System.Text;
  10. using System.IO;
  11. using System.Xml;
  12. using System.Xml.Schema;
  13. using System.Xml.Serialization;
  14. using System.Collections;
  15. using System.Collections.Specialized;
  16. internal class XmlAttributeComparer : IComparer {
  17. public int Compare(object o1, object o2) {
  18. XmlAttribute a1 = (XmlAttribute)o1;
  19. XmlAttribute a2 = (XmlAttribute)o2;
  20. int ns = String.Compare(a1.NamespaceURI, a2.NamespaceURI, StringComparison.Ordinal);
  21. if (ns == 0) {
  22. return String.Compare(a1.Name, a2.Name, StringComparison.Ordinal);
  23. }
  24. return ns;
  25. }
  26. }
  27. internal class XmlFacetComparer : IComparer {
  28. public int Compare(object o1, object o2) {
  29. XmlSchemaFacet f1 = (XmlSchemaFacet)o1;
  30. XmlSchemaFacet f2 = (XmlSchemaFacet)o2;
  31. return String.Compare(f1.GetType().Name + ":" + f1.Value, f2.GetType().Name + ":" + f2.Value, StringComparison.Ordinal);
  32. }
  33. }
  34. internal class QNameComparer : IComparer {
  35. public int Compare(object o1, object o2) {
  36. XmlQualifiedName qn1 = (XmlQualifiedName)o1;
  37. XmlQualifiedName qn2 = (XmlQualifiedName)o2;
  38. int ns = String.Compare(qn1.Namespace, qn2.Namespace, StringComparison.Ordinal);
  39. if (ns == 0) {
  40. return String.Compare(qn1.Name, qn2.Name, StringComparison.Ordinal);
  41. }
  42. return ns;
  43. }
  44. }
  45. internal class XmlSchemaObjectComparer : IComparer {
  46. QNameComparer comparer = new QNameComparer();
  47. public int Compare(object o1, object o2) {
  48. return comparer.Compare(NameOf((XmlSchemaObject)o1), NameOf((XmlSchemaObject)o2));
  49. }
  50. internal static XmlQualifiedName NameOf(XmlSchemaObject o) {
  51. if (o is XmlSchemaAttribute) {
  52. return ((XmlSchemaAttribute)o).QualifiedName;
  53. }
  54. else if (o is XmlSchemaAttributeGroup) {
  55. return ((XmlSchemaAttributeGroup)o).QualifiedName;
  56. }
  57. else if (o is XmlSchemaComplexType) {
  58. return ((XmlSchemaComplexType)o).QualifiedName;
  59. }
  60. else if (o is XmlSchemaSimpleType) {
  61. return ((XmlSchemaSimpleType)o).QualifiedName;
  62. }
  63. else if (o is XmlSchemaElement) {
  64. return ((XmlSchemaElement)o).QualifiedName;
  65. }
  66. else if (o is XmlSchemaGroup) {
  67. return ((XmlSchemaGroup)o).QualifiedName;
  68. }
  69. else if (o is XmlSchemaGroupRef) {
  70. return ((XmlSchemaGroupRef)o).RefName;
  71. }
  72. else if (o is XmlSchemaNotation) {
  73. return ((XmlSchemaNotation)o).QualifiedName;
  74. }
  75. else if (o is XmlSchemaSequence) {
  76. XmlSchemaSequence s = (XmlSchemaSequence)o;
  77. if (s.Items.Count == 0)
  78. return new XmlQualifiedName(".sequence", Namespace(o));
  79. return NameOf(s.Items[0]);
  80. }
  81. else if (o is XmlSchemaAll) {
  82. XmlSchemaAll a = (XmlSchemaAll)o;
  83. if (a.Items.Count == 0)
  84. return new XmlQualifiedName(".all", Namespace(o));
  85. return NameOf(a.Items);
  86. }
  87. else if (o is XmlSchemaChoice) {
  88. XmlSchemaChoice c = (XmlSchemaChoice)o;
  89. if (c.Items.Count == 0)
  90. return new XmlQualifiedName(".choice", Namespace(o));
  91. return NameOf(c.Items);
  92. }
  93. else if (o is XmlSchemaAny) {
  94. return new XmlQualifiedName("*", SchemaObjectWriter.ToString(((XmlSchemaAny)o).NamespaceList));
  95. }
  96. else if (o is XmlSchemaIdentityConstraint) {
  97. return ((XmlSchemaIdentityConstraint)o).QualifiedName;
  98. }
  99. return new XmlQualifiedName("?", Namespace(o));
  100. }
  101. internal static XmlQualifiedName NameOf(XmlSchemaObjectCollection items) {
  102. ArrayList list = new ArrayList();
  103. for (int i = 0; i < items.Count; i++) {
  104. list.Add(NameOf(items[i]));
  105. }
  106. list.Sort(new QNameComparer());
  107. return (XmlQualifiedName)list[0];
  108. }
  109. internal static string Namespace(XmlSchemaObject o) {
  110. while (o != null && !(o is XmlSchema)) {
  111. o = o.Parent;
  112. }
  113. return o == null ? "" : ((XmlSchema)o).TargetNamespace;
  114. }
  115. }
  116. internal class SchemaObjectWriter {
  117. StringBuilder w = new StringBuilder();
  118. int indentLevel = -1;
  119. void WriteIndent() {
  120. for (int i = 0; i < indentLevel; i++) {
  121. w.Append(" ");
  122. }
  123. }
  124. protected void WriteAttribute(string localName, string ns, string value) {
  125. if (value == null || value.Length == 0)
  126. return;
  127. w.Append(",");
  128. w.Append(ns);
  129. if (ns != null && ns.Length != 0)
  130. w.Append(":");
  131. w.Append(localName);
  132. w.Append("=");
  133. w.Append(value);
  134. }
  135. protected void WriteAttribute(string localName, string ns, XmlQualifiedName value) {
  136. if (value.IsEmpty)
  137. return;
  138. WriteAttribute(localName, ns, value.ToString());
  139. }
  140. protected void WriteStartElement(string name) {
  141. NewLine();
  142. indentLevel++;
  143. w.Append("[");
  144. w.Append(name);
  145. }
  146. protected void WriteEndElement() {
  147. w.Append("]");
  148. indentLevel--;
  149. }
  150. protected void NewLine() {
  151. w.Append(Environment.NewLine);
  152. WriteIndent();
  153. }
  154. protected string GetString() {
  155. return w.ToString();
  156. }
  157. void WriteAttribute(XmlAttribute a) {
  158. if (a.Value != null) {
  159. WriteAttribute(a.Name, a.NamespaceURI, a.Value);
  160. }
  161. }
  162. void WriteAttributes(XmlAttribute[] a, XmlSchemaObject o) {
  163. if (a == null) return;
  164. ArrayList attrs = new ArrayList();
  165. for (int i = 0; i < a.Length; i++) {
  166. attrs.Add(a[i]);
  167. }
  168. attrs.Sort(new XmlAttributeComparer());
  169. for (int i = 0; i < attrs.Count; i++) {
  170. XmlAttribute attribute = (XmlAttribute)attrs[i];
  171. WriteAttribute(attribute);
  172. }
  173. }
  174. internal static string ToString(NamespaceList list) {
  175. if (list == null)
  176. return null;
  177. switch (list.Type) {
  178. case NamespaceList.ListType.Any:
  179. return "##any";
  180. case NamespaceList.ListType.Other:
  181. return "##other";
  182. case NamespaceList.ListType.Set:
  183. ArrayList ns = new ArrayList();
  184. foreach (string s in list.Enumerate) {
  185. ns.Add(s);
  186. }
  187. ns.Sort();
  188. StringBuilder sb = new StringBuilder();
  189. bool first = true;
  190. foreach (string s in ns) {
  191. if (first) {
  192. first = false;
  193. }
  194. else {
  195. sb.Append(" ");
  196. }
  197. if (s.Length == 0) {
  198. sb.Append("##local");
  199. }
  200. else {
  201. sb.Append(s);
  202. }
  203. }
  204. return sb.ToString();
  205. default:
  206. return list.ToString();
  207. }
  208. }
  209. internal string WriteXmlSchemaObject(XmlSchemaObject o) {
  210. if (o == null) return String.Empty;
  211. Write3_XmlSchemaObject((XmlSchemaObject)o);
  212. return GetString();
  213. }
  214. void WriteSortedItems(XmlSchemaObjectCollection items) {
  215. if (items == null) return;
  216. ArrayList list = new ArrayList();
  217. for (int i = 0; i < items.Count; i++) {
  218. list.Add(items[i]);
  219. }
  220. list.Sort(new XmlSchemaObjectComparer());
  221. for (int i = 0; i < list.Count; i++) {
  222. Write3_XmlSchemaObject((XmlSchemaObject)list[i]);
  223. }
  224. }
  225. void Write1_XmlSchemaAttribute(XmlSchemaAttribute o) {
  226. if ((object)o == null) return;
  227. WriteStartElement("attribute");
  228. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  229. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  230. WriteAttribute(@"default", @"", ((System.String)o.@DefaultValue));
  231. WriteAttribute(@"fixed", @"", ((System.String)o.@FixedValue));
  232. if (o.Parent != null && !(o.Parent is XmlSchema)) {
  233. if (o.QualifiedName != null && !o.QualifiedName.IsEmpty && o.QualifiedName.Namespace != null && o.QualifiedName.Namespace.Length != 0) {
  234. WriteAttribute(@"form", @"", "qualified");
  235. }
  236. else {
  237. WriteAttribute(@"form", @"", "unqualified");
  238. }
  239. }
  240. WriteAttribute(@"name", @"", ((System.String)o.@Name));
  241. if (!o.RefName.IsEmpty) {
  242. WriteAttribute("ref", "", o.RefName);
  243. }
  244. else if (!o.SchemaTypeName.IsEmpty) {
  245. WriteAttribute("type", "", o.SchemaTypeName);
  246. }
  247. XmlSchemaUse use = o.Use == XmlSchemaUse.None ? XmlSchemaUse.Optional : o.Use;
  248. WriteAttribute(@"use", @"", Write30_XmlSchemaUse(use));
  249. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  250. Write9_XmlSchemaSimpleType((XmlSchemaSimpleType)o.@SchemaType);
  251. WriteEndElement();
  252. }
  253. void Write3_XmlSchemaObject(XmlSchemaObject o) {
  254. if ((object)o == null) return;
  255. System.Type t = o.GetType();
  256. if (t == typeof(XmlSchemaComplexType)) {
  257. Write35_XmlSchemaComplexType((XmlSchemaComplexType)o);
  258. return;
  259. }
  260. else if (t == typeof(XmlSchemaSimpleType)) {
  261. Write9_XmlSchemaSimpleType((XmlSchemaSimpleType)o);
  262. return;
  263. }
  264. else if (t == typeof(XmlSchemaElement)) {
  265. Write46_XmlSchemaElement((XmlSchemaElement)o);
  266. return;
  267. }
  268. else if (t == typeof(XmlSchemaAppInfo)) {
  269. Write7_XmlSchemaAppInfo((XmlSchemaAppInfo)o);
  270. return;
  271. }
  272. else if (t == typeof(XmlSchemaDocumentation)) {
  273. Write6_XmlSchemaDocumentation((XmlSchemaDocumentation)o);
  274. return;
  275. }
  276. else if (t == typeof(XmlSchemaAnnotation)) {
  277. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o);
  278. return;
  279. }
  280. else if (t == typeof(XmlSchemaGroup)) {
  281. Write57_XmlSchemaGroup((XmlSchemaGroup)o);
  282. return;
  283. }
  284. else if (t == typeof(XmlSchemaXPath)) {
  285. Write49_XmlSchemaXPath("xpath", "", (XmlSchemaXPath)o);
  286. return;
  287. }
  288. else if (t == typeof(XmlSchemaIdentityConstraint)) {
  289. Write48_XmlSchemaIdentityConstraint((XmlSchemaIdentityConstraint)o);
  290. return;
  291. }
  292. else if (t == typeof(XmlSchemaUnique)) {
  293. Write51_XmlSchemaUnique((XmlSchemaUnique)o);
  294. return;
  295. }
  296. else if (t == typeof(XmlSchemaKeyref)) {
  297. Write50_XmlSchemaKeyref((XmlSchemaKeyref)o);
  298. return;
  299. }
  300. else if (t == typeof(XmlSchemaKey)) {
  301. Write47_XmlSchemaKey((XmlSchemaKey)o);
  302. return;
  303. }
  304. else if (t == typeof(XmlSchemaGroupRef)) {
  305. Write55_XmlSchemaGroupRef((XmlSchemaGroupRef)o);
  306. return;
  307. }
  308. else if (t == typeof(XmlSchemaAny)) {
  309. Write53_XmlSchemaAny((XmlSchemaAny)o);
  310. return;
  311. }
  312. else if (t == typeof(XmlSchemaSequence)) {
  313. Write54_XmlSchemaSequence((XmlSchemaSequence)o);
  314. return;
  315. }
  316. else if (t == typeof(XmlSchemaChoice)) {
  317. Write52_XmlSchemaChoice((XmlSchemaChoice)o);
  318. return;
  319. }
  320. else if (t == typeof(XmlSchemaAll)) {
  321. Write43_XmlSchemaAll((XmlSchemaAll)o);
  322. return;
  323. }
  324. else if (t == typeof(XmlSchemaComplexContentRestriction)) {
  325. Write56_XmlSchemaComplexContentRestriction((XmlSchemaComplexContentRestriction)o);
  326. return;
  327. }
  328. else if (t == typeof(XmlSchemaComplexContentExtension)) {
  329. Write42_XmlSchemaComplexContentExtension((XmlSchemaComplexContentExtension)o);
  330. return;
  331. }
  332. else if (t == typeof(XmlSchemaSimpleContentRestriction)) {
  333. Write40_XmlSchemaSimpleContentRestriction((XmlSchemaSimpleContentRestriction)o);
  334. return;
  335. }
  336. else if (t == typeof(XmlSchemaSimpleContentExtension)) {
  337. Write38_XmlSchemaSimpleContentExtension((XmlSchemaSimpleContentExtension)o);
  338. return;
  339. }
  340. else if (t == typeof(XmlSchemaComplexContent)) {
  341. Write41_XmlSchemaComplexContent((XmlSchemaComplexContent)o);
  342. return;
  343. }
  344. else if (t == typeof(XmlSchemaSimpleContent)) {
  345. Write36_XmlSchemaSimpleContent((XmlSchemaSimpleContent)o);
  346. return;
  347. }
  348. else if (t == typeof(XmlSchemaAnyAttribute)) {
  349. Write33_XmlSchemaAnyAttribute((XmlSchemaAnyAttribute)o);
  350. return;
  351. }
  352. else if (t == typeof(XmlSchemaAttributeGroupRef)) {
  353. Write32_XmlSchemaAttributeGroupRef((XmlSchemaAttributeGroupRef)o);
  354. return;
  355. }
  356. else if (t == typeof(XmlSchemaAttributeGroup)) {
  357. Write31_XmlSchemaAttributeGroup((XmlSchemaAttributeGroup)o);
  358. return;
  359. }
  360. else if (t == typeof(XmlSchemaSimpleTypeRestriction)) {
  361. Write15_XmlSchemaSimpleTypeRestriction((XmlSchemaSimpleTypeRestriction)o);
  362. return;
  363. }
  364. else if (t == typeof(XmlSchemaSimpleTypeList)) {
  365. Write14_XmlSchemaSimpleTypeList((XmlSchemaSimpleTypeList)o);
  366. return;
  367. }
  368. else if (t == typeof(XmlSchemaSimpleTypeUnion)) {
  369. Write12_XmlSchemaSimpleTypeUnion((XmlSchemaSimpleTypeUnion)o);
  370. return;
  371. }
  372. else if (t == typeof(XmlSchemaAttribute)) {
  373. Write1_XmlSchemaAttribute((XmlSchemaAttribute)o);
  374. return;
  375. }
  376. }
  377. void Write5_XmlSchemaAnnotation(XmlSchemaAnnotation o) {
  378. if ((object)o == null) return;
  379. WriteStartElement("annotation");
  380. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  381. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  382. System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items;
  383. if (a != null) {
  384. for (int ia = 0; ia < a.Count; ia++) {
  385. XmlSchemaObject ai = (XmlSchemaObject)a[ia];
  386. if (ai is XmlSchemaAppInfo) {
  387. Write7_XmlSchemaAppInfo((XmlSchemaAppInfo)ai);
  388. }
  389. else if (ai is XmlSchemaDocumentation) {
  390. Write6_XmlSchemaDocumentation((XmlSchemaDocumentation)ai);
  391. }
  392. }
  393. }
  394. WriteEndElement();
  395. }
  396. void Write6_XmlSchemaDocumentation(XmlSchemaDocumentation o) {
  397. if ((object)o == null) return;
  398. WriteStartElement("documentation");
  399. WriteAttribute(@"source", @"", ((System.String)o.@Source));
  400. WriteAttribute(@"lang", @"http://www.w3.org/XML/1998/namespace", ((System.String)o.@Language));
  401. XmlNode[] a = (XmlNode[])o.@Markup;
  402. if (a != null) {
  403. for (int ia = 0; ia < a.Length; ia++) {
  404. XmlNode ai = (XmlNode)a[ia];
  405. WriteStartElement("node");
  406. WriteAttribute("xml", "", ai.OuterXml);
  407. }
  408. }
  409. WriteEndElement();
  410. }
  411. void Write7_XmlSchemaAppInfo(XmlSchemaAppInfo o) {
  412. if ((object)o == null) return;
  413. WriteStartElement("appinfo");
  414. WriteAttribute("source", "", o.Source);
  415. XmlNode[] a = (XmlNode[])o.@Markup;
  416. if (a != null) {
  417. for (int ia = 0; ia < a.Length; ia++) {
  418. XmlNode ai = (XmlNode)a[ia];
  419. WriteStartElement("node");
  420. WriteAttribute("xml", "", ai.OuterXml);
  421. }
  422. }
  423. WriteEndElement();
  424. }
  425. void Write9_XmlSchemaSimpleType(XmlSchemaSimpleType o) {
  426. if ((object)o == null) return;
  427. WriteStartElement("simpleType");
  428. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  429. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  430. WriteAttribute(@"name", @"", ((System.String)o.@Name));
  431. WriteAttribute(@"final", @"", Write11_XmlSchemaDerivationMethod(o.FinalResolved));
  432. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  433. if (o.@Content is XmlSchemaSimpleTypeUnion) {
  434. Write12_XmlSchemaSimpleTypeUnion((XmlSchemaSimpleTypeUnion)o.@Content);
  435. }
  436. else if (o.@Content is XmlSchemaSimpleTypeRestriction) {
  437. Write15_XmlSchemaSimpleTypeRestriction((XmlSchemaSimpleTypeRestriction)o.@Content);
  438. }
  439. else if (o.@Content is XmlSchemaSimpleTypeList) {
  440. Write14_XmlSchemaSimpleTypeList((XmlSchemaSimpleTypeList)o.@Content);
  441. }
  442. WriteEndElement();
  443. }
  444. string Write11_XmlSchemaDerivationMethod(XmlSchemaDerivationMethod v) {
  445. return v.ToString();
  446. }
  447. void Write12_XmlSchemaSimpleTypeUnion(XmlSchemaSimpleTypeUnion o) {
  448. if ((object)o == null) return;
  449. WriteStartElement("union");
  450. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  451. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  452. if (o.MemberTypes != null) {
  453. ArrayList list = new ArrayList();
  454. for (int i = 0; i < o.MemberTypes.Length; i++) {
  455. list.Add(o.MemberTypes[i]);
  456. }
  457. list.Sort(new QNameComparer());
  458. w.Append(",");
  459. w.Append("memberTypes=");
  460. for (int i = 0; i < list.Count; i++) {
  461. XmlQualifiedName q = (XmlQualifiedName)list[i];
  462. w.Append(q.ToString());
  463. w.Append(",");
  464. }
  465. }
  466. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  467. WriteSortedItems(o.@BaseTypes);
  468. WriteEndElement();
  469. }
  470. void Write14_XmlSchemaSimpleTypeList(XmlSchemaSimpleTypeList o) {
  471. if ((object)o == null) return;
  472. WriteStartElement("list");
  473. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  474. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  475. if ([email protected]){
  476. WriteAttribute(@"itemType", @"", o.@ItemTypeName);
  477. }
  478. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  479. Write9_XmlSchemaSimpleType((XmlSchemaSimpleType)o.@ItemType);
  480. WriteEndElement();
  481. }
  482. void Write15_XmlSchemaSimpleTypeRestriction(XmlSchemaSimpleTypeRestriction o) {
  483. if ((object)o == null) return;
  484. WriteStartElement("restriction");
  485. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  486. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  487. if ([email protected]){
  488. WriteAttribute(@"base", @"", o.@BaseTypeName);
  489. }
  490. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  491. Write9_XmlSchemaSimpleType((XmlSchemaSimpleType)o.@BaseType);
  492. WriteFacets(o.Facets);
  493. WriteEndElement();
  494. }
  495. void WriteFacets(XmlSchemaObjectCollection facets) {
  496. if (facets == null) return;
  497. ArrayList a = new ArrayList();
  498. for (int i = 0; i < facets.Count; i++) {
  499. a.Add(facets[i]);
  500. }
  501. a.Sort(new XmlFacetComparer());
  502. for (int ia = 0; ia < a.Count; ia++) {
  503. XmlSchemaObject ai = (XmlSchemaObject)a[ia];
  504. if (ai is XmlSchemaMinExclusiveFacet) {
  505. Write_XmlSchemaFacet("minExclusive", (XmlSchemaFacet)ai);
  506. }
  507. else if (ai is XmlSchemaMaxInclusiveFacet) {
  508. Write_XmlSchemaFacet("maxInclusive", (XmlSchemaFacet)ai);
  509. }
  510. else if (ai is XmlSchemaMaxExclusiveFacet) {
  511. Write_XmlSchemaFacet("maxExclusive", (XmlSchemaFacet)ai);
  512. }
  513. else if (ai is XmlSchemaMinInclusiveFacet) {
  514. Write_XmlSchemaFacet("minInclusive", (XmlSchemaFacet)ai);
  515. }
  516. else if (ai is XmlSchemaLengthFacet) {
  517. Write_XmlSchemaFacet("length", (XmlSchemaFacet)ai);
  518. }
  519. else if (ai is XmlSchemaEnumerationFacet) {
  520. Write_XmlSchemaFacet("enumeration", (XmlSchemaFacet)ai);
  521. }
  522. else if (ai is XmlSchemaMinLengthFacet) {
  523. Write_XmlSchemaFacet("minLength", (XmlSchemaFacet)ai);
  524. }
  525. else if (ai is XmlSchemaPatternFacet) {
  526. Write_XmlSchemaFacet("pattern", (XmlSchemaFacet)ai);
  527. }
  528. else if (ai is XmlSchemaTotalDigitsFacet) {
  529. Write_XmlSchemaFacet("totalDigits", (XmlSchemaFacet)ai);
  530. }
  531. else if (ai is XmlSchemaMaxLengthFacet) {
  532. Write_XmlSchemaFacet("maxLength", (XmlSchemaFacet)ai);
  533. }
  534. else if (ai is XmlSchemaWhiteSpaceFacet) {
  535. Write_XmlSchemaFacet("whiteSpace", (XmlSchemaFacet)ai);
  536. }
  537. else if (ai is XmlSchemaFractionDigitsFacet) {
  538. Write_XmlSchemaFacet("fractionDigit", (XmlSchemaFacet)ai);
  539. }
  540. }
  541. }
  542. void Write_XmlSchemaFacet(string name, XmlSchemaFacet o) {
  543. if ((object)o == null) return;
  544. WriteStartElement(name);
  545. WriteAttribute("id", "", o.Id);
  546. WriteAttribute("value", "", o.Value);
  547. if (o.IsFixed) {
  548. WriteAttribute(@"fixed", @"", XmlConvert.ToString(o.IsFixed));
  549. }
  550. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  551. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  552. WriteEndElement();
  553. }
  554. string Write30_XmlSchemaUse(XmlSchemaUse v) {
  555. string s = null;
  556. switch (v) {
  557. case XmlSchemaUse.@Optional:s = @"optional"; break;
  558. case XmlSchemaUse.@Prohibited:s = @"prohibited"; break;
  559. case XmlSchemaUse.@Required:s = @"required"; break;
  560. default: break;
  561. }
  562. return s;
  563. }
  564. void Write31_XmlSchemaAttributeGroup(XmlSchemaAttributeGroup o) {
  565. if ((object)o == null) return;
  566. WriteStartElement("attributeGroup");
  567. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  568. WriteAttribute(@"name", @"", ((System.String)o.@Name));
  569. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  570. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  571. WriteSortedItems(o.Attributes);
  572. Write33_XmlSchemaAnyAttribute((XmlSchemaAnyAttribute)o.@AnyAttribute);
  573. WriteEndElement();
  574. }
  575. void Write32_XmlSchemaAttributeGroupRef(XmlSchemaAttributeGroupRef o) {
  576. if ((object)o == null) return;
  577. WriteStartElement("attributeGroup");
  578. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  579. if (!o.RefName.IsEmpty) {
  580. WriteAttribute("ref", "", o.RefName);
  581. }
  582. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  583. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  584. WriteEndElement();
  585. }
  586. void Write33_XmlSchemaAnyAttribute(XmlSchemaAnyAttribute o) {
  587. if ((object)o == null) return;
  588. WriteStartElement("anyAttribute");
  589. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  590. WriteAttribute("namespace", "", ToString(o.NamespaceList));
  591. XmlSchemaContentProcessing process = o.@ProcessContents == XmlSchemaContentProcessing.@None ? XmlSchemaContentProcessing.Strict : o.@ProcessContents;
  592. WriteAttribute(@"processContents", @"", Write34_XmlSchemaContentProcessing(process));
  593. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  594. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  595. WriteEndElement();
  596. }
  597. string Write34_XmlSchemaContentProcessing(XmlSchemaContentProcessing v) {
  598. string s = null;
  599. switch (v) {
  600. case XmlSchemaContentProcessing.@Skip:s = @"skip"; break;
  601. case XmlSchemaContentProcessing.@Lax:s = @"lax"; break;
  602. case XmlSchemaContentProcessing.@Strict:s = @"strict"; break;
  603. default: break;
  604. }
  605. return s;
  606. }
  607. void Write35_XmlSchemaComplexType(XmlSchemaComplexType o) {
  608. if ((object)o == null) return;
  609. WriteStartElement("complexType");
  610. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  611. WriteAttribute(@"name", @"", ((System.String)o.@Name));
  612. WriteAttribute(@"final", @"", Write11_XmlSchemaDerivationMethod(o.FinalResolved));
  613. if (((System.Boolean)o.@IsAbstract) != false) {
  614. WriteAttribute(@"abstract", @"", XmlConvert.ToString((System.Boolean)((System.Boolean)o.@IsAbstract)));
  615. }
  616. WriteAttribute(@"block", @"", Write11_XmlSchemaDerivationMethod(o.BlockResolved));
  617. if (((System.Boolean)o.@IsMixed) != false) {
  618. WriteAttribute(@"mixed", @"", XmlConvert.ToString((System.Boolean)((System.Boolean)o.@IsMixed)));
  619. }
  620. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  621. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  622. if (o.@ContentModel is XmlSchemaComplexContent) {
  623. Write41_XmlSchemaComplexContent((XmlSchemaComplexContent)o.@ContentModel);
  624. }
  625. else if (o.@ContentModel is XmlSchemaSimpleContent) {
  626. Write36_XmlSchemaSimpleContent((XmlSchemaSimpleContent)o.@ContentModel);
  627. }
  628. if (o.@Particle is XmlSchemaSequence) {
  629. Write54_XmlSchemaSequence((XmlSchemaSequence)o.@Particle);
  630. }
  631. else if (o.@Particle is XmlSchemaGroupRef) {
  632. Write55_XmlSchemaGroupRef((XmlSchemaGroupRef)o.@Particle);
  633. }
  634. else if (o.@Particle is XmlSchemaChoice) {
  635. Write52_XmlSchemaChoice((XmlSchemaChoice)o.@Particle);
  636. }
  637. else if (o.@Particle is XmlSchemaAll) {
  638. Write43_XmlSchemaAll((XmlSchemaAll)o.@Particle);
  639. }
  640. WriteSortedItems(o.Attributes);
  641. Write33_XmlSchemaAnyAttribute((XmlSchemaAnyAttribute)o.@AnyAttribute);
  642. WriteEndElement();
  643. }
  644. void Write36_XmlSchemaSimpleContent(XmlSchemaSimpleContent o) {
  645. if ((object)o == null) return;
  646. WriteStartElement("simpleContent");
  647. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  648. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  649. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  650. if (o.@Content is XmlSchemaSimpleContentRestriction) {
  651. Write40_XmlSchemaSimpleContentRestriction((XmlSchemaSimpleContentRestriction)o.@Content);
  652. }
  653. else if (o.@Content is XmlSchemaSimpleContentExtension) {
  654. Write38_XmlSchemaSimpleContentExtension((XmlSchemaSimpleContentExtension)o.@Content);
  655. }
  656. WriteEndElement();
  657. }
  658. void Write38_XmlSchemaSimpleContentExtension(XmlSchemaSimpleContentExtension o) {
  659. if ((object)o == null) return;
  660. WriteStartElement("extension");
  661. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  662. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  663. if ([email protected]){
  664. WriteAttribute(@"base", @"", o.@BaseTypeName);
  665. }
  666. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  667. WriteSortedItems(o.Attributes);
  668. Write33_XmlSchemaAnyAttribute((XmlSchemaAnyAttribute)o.@AnyAttribute);
  669. WriteEndElement();
  670. }
  671. void Write40_XmlSchemaSimpleContentRestriction(XmlSchemaSimpleContentRestriction o) {
  672. if ((object)o == null) return;
  673. WriteStartElement("restriction");
  674. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  675. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  676. if ([email protected]){
  677. WriteAttribute(@"base", @"", o.@BaseTypeName);
  678. }
  679. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  680. Write9_XmlSchemaSimpleType((XmlSchemaSimpleType)o.@BaseType);
  681. WriteFacets(o.Facets);
  682. WriteSortedItems(o.Attributes);
  683. Write33_XmlSchemaAnyAttribute((XmlSchemaAnyAttribute)o.@AnyAttribute);
  684. WriteEndElement();
  685. }
  686. void Write41_XmlSchemaComplexContent(XmlSchemaComplexContent o) {
  687. if ((object)o == null) return;
  688. WriteStartElement("complexContent");
  689. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  690. WriteAttribute(@"mixed", @"", XmlConvert.ToString((System.Boolean)((System.Boolean)o.@IsMixed)));
  691. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  692. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  693. if (o.@Content is XmlSchemaComplexContentRestriction) {
  694. Write56_XmlSchemaComplexContentRestriction((XmlSchemaComplexContentRestriction)o.@Content);
  695. }
  696. else if (o.@Content is XmlSchemaComplexContentExtension) {
  697. Write42_XmlSchemaComplexContentExtension((XmlSchemaComplexContentExtension)o.@Content);
  698. }
  699. WriteEndElement();
  700. }
  701. void Write42_XmlSchemaComplexContentExtension(XmlSchemaComplexContentExtension o) {
  702. if ((object)o == null) return;
  703. WriteStartElement("extension");
  704. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  705. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  706. if ([email protected]){
  707. WriteAttribute(@"base", @"", o.@BaseTypeName);
  708. }
  709. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  710. if (o.@Particle is XmlSchemaSequence) {
  711. Write54_XmlSchemaSequence((XmlSchemaSequence)o.@Particle);
  712. }
  713. else if (o.@Particle is XmlSchemaGroupRef) {
  714. Write55_XmlSchemaGroupRef((XmlSchemaGroupRef)o.@Particle);
  715. }
  716. else if (o.@Particle is XmlSchemaChoice) {
  717. Write52_XmlSchemaChoice((XmlSchemaChoice)o.@Particle);
  718. }
  719. else if (o.@Particle is XmlSchemaAll) {
  720. Write43_XmlSchemaAll((XmlSchemaAll)o.@Particle);
  721. }
  722. WriteSortedItems(o.Attributes);
  723. Write33_XmlSchemaAnyAttribute((XmlSchemaAnyAttribute)o.@AnyAttribute);
  724. WriteEndElement();
  725. }
  726. void Write43_XmlSchemaAll(XmlSchemaAll o) {
  727. if ((object)o == null) return;
  728. WriteStartElement("all");
  729. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  730. WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs));
  731. WriteAttribute("maxOccurs", "", o.MaxOccurs == decimal.MaxValue ? "unbounded" : XmlConvert.ToString(o.MaxOccurs));
  732. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  733. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  734. WriteSortedItems(o.@Items);
  735. WriteEndElement();
  736. }
  737. void Write46_XmlSchemaElement(XmlSchemaElement o) {
  738. if ((object)o == null) return;
  739. System.Type t = o.GetType();
  740. WriteStartElement("element");
  741. WriteAttribute(@"id", @"", o.Id);
  742. WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs));
  743. WriteAttribute("maxOccurs", "", o.MaxOccurs == decimal.MaxValue ? "unbounded" : XmlConvert.ToString(o.MaxOccurs));
  744. if (((System.Boolean)o.@IsAbstract) != false) {
  745. WriteAttribute(@"abstract", @"", XmlConvert.ToString((System.Boolean)((System.Boolean)o.@IsAbstract)));
  746. }
  747. WriteAttribute(@"block", @"", Write11_XmlSchemaDerivationMethod(o.BlockResolved));
  748. WriteAttribute(@"default", @"", o.DefaultValue);
  749. WriteAttribute(@"final", @"", Write11_XmlSchemaDerivationMethod(o.FinalResolved));
  750. WriteAttribute(@"fixed", @"", o.FixedValue);
  751. if (o.Parent != null && !(o.Parent is XmlSchema)) {
  752. if (o.QualifiedName != null && !o.QualifiedName.IsEmpty && o.QualifiedName.Namespace != null && o.QualifiedName.Namespace.Length != 0) {
  753. WriteAttribute(@"form", @"", "qualified");
  754. }
  755. else {
  756. WriteAttribute(@"form", @"", "unqualified");
  757. }
  758. }
  759. if (o.Name != null && o.Name.Length != 0) {
  760. WriteAttribute(@"name", @"", o.Name);
  761. }
  762. if (o.IsNillable) {
  763. WriteAttribute(@"nillable", @"", XmlConvert.ToString(o.IsNillable));
  764. }
  765. if (!o.SubstitutionGroup.IsEmpty) {
  766. WriteAttribute("substitutionGroup", "", o.SubstitutionGroup);
  767. }
  768. if (!o.RefName.IsEmpty) {
  769. WriteAttribute("ref", "", o.RefName);
  770. }
  771. else if (!o.SchemaTypeName.IsEmpty) {
  772. WriteAttribute("type", "", o.SchemaTypeName);
  773. }
  774. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  775. Write5_XmlSchemaAnnotation(o.Annotation);
  776. if (o.SchemaType is XmlSchemaComplexType) {
  777. Write35_XmlSchemaComplexType((XmlSchemaComplexType)o.SchemaType);
  778. }
  779. else if (o.SchemaType is XmlSchemaSimpleType) {
  780. Write9_XmlSchemaSimpleType((XmlSchemaSimpleType)o.SchemaType);
  781. }
  782. WriteSortedItems(o.Constraints);
  783. WriteEndElement();
  784. }
  785. void Write47_XmlSchemaKey(XmlSchemaKey o) {
  786. if ((object)o == null) return;
  787. System.Type t = o.GetType();
  788. WriteStartElement("key");
  789. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  790. WriteAttribute(@"name", @"", ((System.String)o.@Name));
  791. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  792. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  793. Write49_XmlSchemaXPath(@"selector", @"", (XmlSchemaXPath)o.@Selector); {
  794. XmlSchemaObjectCollection a = (XmlSchemaObjectCollection)o.@Fields;
  795. if (a != null) {
  796. for (int ia = 0; ia < a.Count; ia++) {
  797. Write49_XmlSchemaXPath(@"field", @"", (XmlSchemaXPath)a[ia]);
  798. }
  799. }
  800. }
  801. WriteEndElement();
  802. }
  803. void Write48_XmlSchemaIdentityConstraint(XmlSchemaIdentityConstraint o) {
  804. if ((object)o == null) return;
  805. System.Type t = o.GetType();
  806. if (t == typeof(XmlSchemaUnique)) {
  807. Write51_XmlSchemaUnique((XmlSchemaUnique)o);
  808. return;
  809. }
  810. else if (t == typeof(XmlSchemaKeyref)) {
  811. Write50_XmlSchemaKeyref((XmlSchemaKeyref)o);
  812. return;
  813. }
  814. else if (t == typeof(XmlSchemaKey)) {
  815. Write47_XmlSchemaKey((XmlSchemaKey)o);
  816. return;
  817. }
  818. }
  819. void Write49_XmlSchemaXPath(string name, string ns, XmlSchemaXPath o) {
  820. if ((object)o == null) return;
  821. WriteStartElement(name);
  822. WriteAttribute(@"id", @"", o.@Id);
  823. WriteAttribute(@"xpath", @"", o.@XPath);
  824. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  825. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  826. WriteEndElement();
  827. }
  828. void Write50_XmlSchemaKeyref(XmlSchemaKeyref o) {
  829. if ((object)o == null) return;
  830. System.Type t = o.GetType();
  831. WriteStartElement("keyref");
  832. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  833. WriteAttribute(@"name", @"", ((System.String)o.@Name));
  834. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  835. //
  836. WriteAttribute(@"refer", @"", o.@Refer);
  837. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  838. Write49_XmlSchemaXPath(@"selector", @"", (XmlSchemaXPath)o.@Selector); {
  839. XmlSchemaObjectCollection a = (XmlSchemaObjectCollection)o.@Fields;
  840. if (a != null) {
  841. for (int ia = 0; ia < a.Count; ia++) {
  842. Write49_XmlSchemaXPath(@"field", @"", (XmlSchemaXPath)a[ia]);
  843. }
  844. }
  845. }
  846. WriteEndElement();
  847. }
  848. void Write51_XmlSchemaUnique(XmlSchemaUnique o) {
  849. if ((object)o == null) return;
  850. System.Type t = o.GetType();
  851. WriteStartElement("unique");
  852. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  853. WriteAttribute(@"name", @"", ((System.String)o.@Name));
  854. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  855. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  856. Write49_XmlSchemaXPath("selector", "", (XmlSchemaXPath)o.@Selector);
  857. XmlSchemaObjectCollection a = (XmlSchemaObjectCollection)o.@Fields;
  858. if (a != null) {
  859. for (int ia = 0; ia < a.Count; ia++) {
  860. Write49_XmlSchemaXPath("field", "", (XmlSchemaXPath)a[ia]);
  861. }
  862. }
  863. WriteEndElement();
  864. }
  865. void Write52_XmlSchemaChoice(XmlSchemaChoice o) {
  866. if ((object)o == null) return;
  867. System.Type t = o.GetType();
  868. WriteStartElement("choice");
  869. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  870. WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs));
  871. WriteAttribute(@"maxOccurs", @"", o.MaxOccurs == decimal.MaxValue ? "unbounded" : XmlConvert.ToString(o.MaxOccurs));
  872. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  873. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  874. WriteSortedItems(o.@Items);
  875. WriteEndElement();
  876. }
  877. void Write53_XmlSchemaAny(XmlSchemaAny o) {
  878. if ((object)o == null) return;
  879. WriteStartElement("any");
  880. WriteAttribute(@"id", @"", o.@Id);
  881. WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs));
  882. WriteAttribute(@"maxOccurs", @"", o.MaxOccurs == decimal.MaxValue ? "unbounded" : XmlConvert.ToString(o.MaxOccurs));
  883. WriteAttribute(@"namespace", @"", ToString(o.NamespaceList));
  884. XmlSchemaContentProcessing process = o.@ProcessContents == XmlSchemaContentProcessing.@None ? XmlSchemaContentProcessing.Strict : o.@ProcessContents;
  885. WriteAttribute(@"processContents", @"", Write34_XmlSchemaContentProcessing(process));
  886. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  887. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  888. WriteEndElement();
  889. }
  890. void Write54_XmlSchemaSequence(XmlSchemaSequence o) {
  891. if ((object)o == null) return;
  892. WriteStartElement("sequence");
  893. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  894. WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs));
  895. WriteAttribute("maxOccurs", "", o.MaxOccurs == decimal.MaxValue ? "unbounded" : XmlConvert.ToString(o.MaxOccurs));
  896. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  897. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  898. XmlSchemaObjectCollection a = (XmlSchemaObjectCollection)o.@Items;
  899. if (a != null) {
  900. for (int ia = 0; ia < a.Count; ia++) {
  901. XmlSchemaObject ai = (XmlSchemaObject)a[ia];
  902. if (ai is XmlSchemaAny) {
  903. Write53_XmlSchemaAny((XmlSchemaAny)ai);
  904. }
  905. else if (ai is XmlSchemaSequence) {
  906. Write54_XmlSchemaSequence((XmlSchemaSequence)ai);
  907. }
  908. else if (ai is XmlSchemaChoice) {
  909. Write52_XmlSchemaChoice((XmlSchemaChoice)ai);
  910. }
  911. else if (ai is XmlSchemaElement) {
  912. Write46_XmlSchemaElement((XmlSchemaElement)ai);
  913. }
  914. else if (ai is XmlSchemaGroupRef) {
  915. Write55_XmlSchemaGroupRef((XmlSchemaGroupRef)ai);
  916. }
  917. }
  918. }
  919. WriteEndElement();
  920. }
  921. void Write55_XmlSchemaGroupRef(XmlSchemaGroupRef o) {
  922. if ((object)o == null) return;
  923. WriteStartElement("group");
  924. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  925. WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs));
  926. WriteAttribute(@"maxOccurs", @"", o.MaxOccurs == decimal.MaxValue ? "unbounded" : XmlConvert.ToString(o.MaxOccurs));
  927. if (!o.RefName.IsEmpty) {
  928. WriteAttribute("ref", "", o.RefName);
  929. }
  930. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  931. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  932. WriteEndElement();
  933. }
  934. void Write56_XmlSchemaComplexContentRestriction(XmlSchemaComplexContentRestriction o) {
  935. if ((object)o == null) return;
  936. WriteStartElement("restriction");
  937. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  938. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  939. if ([email protected]){
  940. WriteAttribute(@"base", @"", o.@BaseTypeName);
  941. }
  942. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  943. if (o.@Particle is XmlSchemaSequence) {
  944. Write54_XmlSchemaSequence((XmlSchemaSequence)o.@Particle);
  945. }
  946. else if (o.@Particle is XmlSchemaGroupRef) {
  947. Write55_XmlSchemaGroupRef((XmlSchemaGroupRef)o.@Particle);
  948. }
  949. else if (o.@Particle is XmlSchemaChoice) {
  950. Write52_XmlSchemaChoice((XmlSchemaChoice)o.@Particle);
  951. }
  952. else if (o.@Particle is XmlSchemaAll) {
  953. Write43_XmlSchemaAll((XmlSchemaAll)o.@Particle);
  954. }
  955. WriteSortedItems(o.Attributes);
  956. Write33_XmlSchemaAnyAttribute((XmlSchemaAnyAttribute)o.@AnyAttribute);
  957. WriteEndElement();
  958. }
  959. void Write57_XmlSchemaGroup(XmlSchemaGroup o) {
  960. if ((object)o == null) return;
  961. WriteStartElement("group");
  962. WriteAttribute(@"id", @"", ((System.String)o.@Id));
  963. WriteAttribute(@"name", @"", ((System.String)o.@Name));
  964. WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
  965. Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
  966. if (o.@Particle is XmlSchemaSequence) {
  967. Write54_XmlSchemaSequence((XmlSchemaSequence)o.@Particle);
  968. }
  969. else if (o.@Particle is XmlSchemaChoice) {
  970. Write52_XmlSchemaChoice((XmlSchemaChoice)o.@Particle);
  971. }
  972. else if (o.@Particle is XmlSchemaAll) {
  973. Write43_XmlSchemaAll((XmlSchemaAll)o.@Particle);
  974. }
  975. WriteEndElement();
  976. }
  977. }
  978. }