private List <XmlSchemaElement> GetAllSchemaElements(XmlSchemaParticle particule) { if (particule is XmlSchemaSequence) { return(GetAllSchemaElements((particule as XmlSchemaSequence).Items)); } else if (particule is XmlSchemaChoice) { return(GetAllSchemaElements((particule as XmlSchemaChoice).Items)); } return(null); }
private void BuildProperties(XmlSchemaElement parentElement, XmlSchemaType schemaType, ClrContentTypeInfo typeInfo) { XmlSchemaComplexType ct = schemaType as XmlSchemaComplexType; if (ct != null) { if (ct.TypeCode == XmlTypeCode.Item) { return; } XmlSchemaParticle particleToProperties = ct.ContentTypeParticle; XmlSchemaComplexType baseType = ct.BaseXmlSchemaType as XmlSchemaComplexType; if (schemaType.GetContentType() == XmlSchemaContentType.TextOnly) { //Try to create a text property for the simple content ClrPropertyInfo property = BuildComplexTypeTextProperty(parentElement, ct); if (property != null) { typeInfo.AddMember(property); } if (baseType == null) { //Derived from Simple type, first step simpleContent extension TraverseAttributes(ct.AttributeUses, typeInfo); } else { //Derived from another complex type simple content, generate the content only if there are additional restrictions if (!ct.IsDerivedByRestriction()) //process attributes only if not derived by restriction { TraverseAttributes(ct.AttributeUses, baseType.AttributeUses, typeInfo); } } } else { Debug.Assert(baseType != null); //ComplexType with complexContent is always derived from another complexType if (ct.IsDerivedByRestriction()) { //Do not handle restrictions on complex content? return; } if (particleToProperties.GetParticleType() != ParticleType.Empty) { TraverseParticle(particleToProperties, baseType, typeInfo, ct.DerivedBy); } TraverseAttributes(ct.AttributeUses, baseType.AttributeUses, typeInfo); } } else { typeInfo.AddMember(BuildSimpleTypeTextProperty(parentElement, schemaType as XmlSchemaSimpleType)); } }
public override void GetExpectedParticles(ArrayList al) { // if not started, then just collect all items from seq. if (currentAutomata == null) { foreach (XmlSchemaParticle p in seq.CompiledItems) { al.Add(p); if (!p.ValidateIsEmptiable()) { break; } } return; } // automata for ongoing iteration if (currentAutomata != null) { currentAutomata.GetExpectedParticles(al); if (!currentAutomata.EvaluateIsEmptiable()) { return; } // remaining items after currentAutomata for (int i = current + 1; i < seq.CompiledItems.Count; i++) { XmlSchemaParticle p = seq.CompiledItems [i] as XmlSchemaParticle; al.Add(p); if (!p.ValidateIsEmptiable()) { break; } } } // itself if (Occured + 1 == seq.ValidatedMaxOccurs) { return; } { for (int i = 0; i <= current; i++) { al.Add(seq.CompiledItems [i]); } } }
private void GetProperties(XmlSchema xmlSchema, string elementname) { foreach (object xItem in xmlSchema.SchemaTypes.Values) { XmlSchemaComplexType item = xItem as XmlSchemaComplexType; #region item if (item != null) { if (item.Name.Equals(elementname)) { XmlSchemaContentModel model = item.ContentModel; XmlSchemaComplexContent complex = model as XmlSchemaComplexContent; SoapClasses newClass = this.GetClass(elementname); if (complex != null && newClass != null) { XmlSchemaComplexContentExtension extension = complex.Content as XmlSchemaComplexContentExtension; XmlSchemaParticle particle = extension.Particle; XmlSchemaSequence sequence = particle as XmlSchemaSequence; if (extension != null) { newClass.SuperClassType = extension.BaseTypeName.Name; } if (sequence != null) { foreach (XmlSchemaElement childElement in sequence.Items) { if (newClass != null) { SoapClassProperties newProp = new SoapClassProperties(XpoDefault.Session); newProp.Name = childElement.Name; newProp.PropertyClassType = childElement.SchemaTypeName.Name; newProp.IsArray = childElement.SchemaTypeName.Name.StartsWith("ArrayOf");//.Equals("unbounded")); newClass.Properties.Add(newProp); } } } newClass.Save(); } return; } } #endregion } }
private string getFlags(XmlSchemaParticle particle) { string flags = "O"; if (particle.MinOccurs > 0) { flags = "M"; } if (particle.MaxOccursString == "unbounded") { flags += "R"; } return(flags); }
private void WalkSchemaParticle(List <string> list, XmlSchemaParticle particle) { if (particle is XmlSchemaElement) { list.Add(((XmlSchemaElement)particle).Name); } else if (particle is XmlSchemaGroupBase) { XmlSchemaGroupBase xsgb = particle as XmlSchemaGroupBase; foreach (XmlSchemaParticle p in xsgb.Items) { this.WalkSchemaParticle(list, p); } } }
public static bool Contains(this XmlSchemaParticle particle, XmlSchemaParticle childParticle) { XmlSchemaGroupBase groupBase = particle as XmlSchemaGroupBase; if (groupBase != null) { foreach (XmlSchemaParticle item in groupBase.Items) { if (item == childParticle) { return(true); } } } return(false); }
public override XsdValidationState EvaluateStartElement(string localName, string ns) { this.emptiableComputed = false; bool flag = true; int i = 0; while (i < this.choice.CompiledItems.Count) { XmlSchemaParticle xsobj = (XmlSchemaParticle)this.choice.CompiledItems[i]; XsdValidationState xsdValidationState = base.Manager.Create(xsobj); XsdValidationState xsdValidationState2 = xsdValidationState.EvaluateStartElement(localName, ns); if (xsdValidationState2 != XsdValidationState.Invalid) { base.OccuredInternal++; if (base.Occured > this.choice.ValidatedMaxOccurs) { return(XsdValidationState.Invalid); } if (base.Occured == this.choice.ValidatedMaxOccurs) { return(xsdValidationState2); } return(base.Manager.MakeSequence(xsdValidationState2, this)); } else { if (!this.emptiableComputed) { flag &= xsdValidationState.EvaluateIsEmptiable(); } i++; } } if (!this.emptiableComputed) { if (flag) { this.emptiable = true; } if (!this.emptiable) { this.emptiable = (this.choice.ValidatedMinOccurs <= base.Occured); } this.emptiableComputed = true; } return(XsdValidationState.Invalid); }
/// <summary> /// Gets the child elements of the given XML particle that are eligible to /// be the next element in the XML document. /// </summary> /// <param name="p_xspParticle">The particle whoe children are to be retrieved.</param> /// <returns>A list of the child elements of the given XML particle that are eligible to /// be the next element in the XML document.</returns> private List <KeyValuePair <string, string> > GetChildrenElements(XmlSchemaParticle p_xspParticle) { if (p_xspParticle is XmlSchemaElement) { XmlSchemaElement xseElement = (XmlSchemaElement)p_xspParticle; return(new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>(xseElement.Name, GetDocumentation(xseElement)) }); } else if (p_xspParticle is XmlSchemaSequence) { XmlSchemaSequence xssSequence = (XmlSchemaSequence)p_xspParticle; List <KeyValuePair <string, string> > lstChoices = new List <KeyValuePair <string, string> >(); foreach (XmlSchemaParticle xspParticle in xssSequence.Items) { lstChoices.AddRange(GetChildrenElements(xspParticle)); if (xspParticle.MinOccurs > 0) { break; } } return(lstChoices); } else if (p_xspParticle is XmlSchemaChoice) { XmlSchemaChoice xscChoice = (XmlSchemaChoice)p_xspParticle; List <KeyValuePair <string, string> > lstChoices = new List <KeyValuePair <string, string> >(); foreach (XmlSchemaParticle xspParticle in xscChoice.Items) { lstChoices.AddRange(GetChildrenElements(xspParticle)); } return(lstChoices); } else if (p_xspParticle is XmlSchemaAll) { XmlSchemaAll xsaAll = (XmlSchemaAll)p_xspParticle; List <KeyValuePair <string, string> > lstChoices = new List <KeyValuePair <string, string> >(); foreach (XmlSchemaParticle xspParticle in xsaAll.Items) { lstChoices.AddRange(GetChildrenElements(xspParticle)); } return(lstChoices); } return(null); }
public static IEnumerable <XmlSchemaElement> GetAlternativesFromParticle(XmlSchemaParticle particle) { if (particle is XmlSchemaElement) { yield return(particle as XmlSchemaElement); yield break; } XmlSchemaParticle result; XmlSchemaSequence seq = particle as XmlSchemaSequence; if (seq != null) { foreach (XmlSchemaObject o in seq.Items) { result = o as XmlSchemaParticle; if (result != null) { foreach (XmlSchemaElement el in GetAlternativesFromParticle(result)) { yield return(el); } } } } XmlSchemaChoice ch = particle as XmlSchemaChoice; if (ch != null) { foreach (XmlSchemaObject a in ch.Items) { result = a as XmlSchemaParticle; if (result != null) { foreach (XmlSchemaElement el2 in GetAlternativesFromParticle(result)) { yield return(el2); } } } } }
public override XsdValidationState EvaluateStartElement(string localName, string ns) { emptiableComputed = false; bool allChildrenEmptiable = true; for (int i = 0; i < choice.CompiledItems.Count; i++) { XmlSchemaParticle xsobj = (XmlSchemaParticle)choice.CompiledItems [i]; XsdValidationState xa = Manager.Create(xsobj); XsdValidationState result = xa.EvaluateStartElement(localName, ns); if (result != XsdValidationState.Invalid) { OccuredInternal++; if (Occured > choice.ValidatedMaxOccurs) { return(XsdValidationState.Invalid); } else if (Occured == choice.ValidatedMaxOccurs) { return(result); } else { return(Manager.MakeSequence(result, this)); } } if (!emptiableComputed) { allChildrenEmptiable &= xa.EvaluateIsEmptiable(); } } if (!emptiableComputed) { if (allChildrenEmptiable) { emptiable = true; } if (!emptiable) { emptiable = choice.ValidatedMinOccurs <= Occured; } emptiableComputed = true; } return(XsdValidationState.Invalid); }
private Occurs GetOccurence(XmlSchemaParticle particle) { Occurs occur; if (particle.MinOccurs == new decimal(1)) { occur = (!(particle.MaxOccurs == new decimal(1)) ? Occurs.OneOrMore : Occurs.One); } else if (!(particle.MinOccurs == new decimal(0))) { Debug.Assert(particle.MinOccurs > new decimal(1)); occur = Occurs.OneOrMore; } else { occur = (!(particle.MaxOccurs == new decimal(1)) ? Occurs.ZeroOrMore : Occurs.ZeroOrOne); } return(occur); }
private void BuildProperties(XmlSchemaElement parentElement, XmlSchemaType schemaType, ClrContentTypeInfo typeInfo) { XmlSchemaComplexType ct = schemaType as XmlSchemaComplexType; if (ct == null) { typeInfo.AddMember(this.BuildSimpleTypeTextProperty(parentElement, schemaType as XmlSchemaSimpleType)); } else if (ct.TypeCode != XmlTypeCode.Item) { XmlSchemaParticle particleToProperties = ct.ContentTypeParticle; XmlSchemaComplexType baseType = ct.BaseXmlSchemaType as XmlSchemaComplexType; if (schemaType.GetContentType() != XmlSchemaContentType.TextOnly) { Debug.Assert(baseType != null); if (ct.IsDerivedByRestriction()) { return; } if (particleToProperties.GetParticleType() != ParticleType.Empty) { this.TraverseParticle(particleToProperties, baseType, typeInfo, ct.DerivedBy); } this.TraverseAttributes(ct.AttributeUses, baseType.AttributeUses, typeInfo); } else { ClrPropertyInfo property = this.BuildComplexTypeTextProperty(parentElement, ct); if (property != null) { typeInfo.AddMember(property); } if (baseType == null) { this.TraverseAttributes(ct.AttributeUses, typeInfo); } else if (!ct.IsDerivedByRestriction()) { this.TraverseAttributes(ct.AttributeUses, baseType.AttributeUses, typeInfo); } } } }
/// <summary> /// Finds the element specified in the given stack, starting from the given XML particle. /// </summary> /// <param name="p_xspParticle">The particle at which to being the search.</param> /// <param name="p_stkCode">A stack describing a path to an XML element.</param> /// <returns>The element specified by the given stack, or <c>null</c> if no such /// element could be found.</returns> private XmlSchemaElement findElement(XmlSchemaParticle p_xspParticle, Stack <string> p_stkCode) { if (p_xspParticle is XmlSchemaElement) { XmlSchemaElement xseElement = (XmlSchemaElement)p_xspParticle; if (p_stkCode.Peek().Equals(xseElement.Name)) { p_stkCode.Pop(); if (p_stkCode.Count == 0) { return(xseElement); } if (xseElement.ElementSchemaType is XmlSchemaComplexType) { XmlSchemaComplexType xctElement = (XmlSchemaComplexType)xseElement.ElementSchemaType; if (xctElement.ContentTypeParticle != null) { return(findElement(xctElement.ContentTypeParticle, p_stkCode)); } } //if this isn't a complex type, then this element has no children, // so if this isn't the element we are looking for, we are looking // in the wrong part of the schema tree. } } else if (p_xspParticle is XmlSchemaGroupBase) { //this handle sequences, choices, and all XmlSchemaGroupBase xbsGroup = (XmlSchemaGroupBase)p_xspParticle; XmlSchemaElement xseElement = null; foreach (XmlSchemaParticle xspParticle in xbsGroup.Items) { xseElement = findElement(xspParticle, p_stkCode); if (xseElement != null) { return(xseElement); } } } return(null); }
private static void TraverseParticle(XmlSchemaParticle particle, ArrayList elementDeclsInContentModel) { if (particle is XmlSchemaElement) { XmlSchemaElement value = particle as XmlSchemaElement; elementDeclsInContentModel.Add(value); } else if (particle is XmlSchemaGroupBase) { foreach (XmlSchemaParticle item in (particle as XmlSchemaGroupBase).Items) { TraverseParticle(item, elementDeclsInContentModel); } } else if (particle is XmlSchemaAny) { m_processContent = (particle as XmlSchemaAny).ProcessContents; } }
public static bool Contains(this XmlSchemaParticle particle, XmlSchemaParticle childParticle) { bool flag; XmlSchemaGroupBase groupBase = particle as XmlSchemaGroupBase; if (groupBase != null) { foreach (XmlSchemaParticle item in groupBase.Items) { if (item == childParticle) { flag = true; return(flag); } } } flag = false; return(flag); }
/*void Start() * { * XmlSchemaComplexType complexType; * foreach (XmlSchemaType type in xs.SchemaTypes.Values) * { * complexType = type as XmlSchemaComplexType; * if (complexType != null) * TraverseParticle(complexType.ContentTypeParticle); * } * * foreach (XmlSchemaElement el in xs.Elements.Values) * TraverseParticle(el); * }*/ void TraverseParticle(XmlSchemaParticle particle, string paramElementName) { if (particle != null) { if (particle is XmlSchemaSequence) { XmlSchemaSequence seqxml = particle as XmlSchemaSequence; foreach (object obj in seqxml.Items) { if (obj is XmlSchemaElement) { XmlSchemaElement elem = obj as XmlSchemaElement; string name = elem.Name; if (elem.SchemaTypeName != null && !string.IsNullOrEmpty(elem.SchemaTypeName.Name)) { parameterMappings[paramElementName].Add(name, elem.SchemaTypeName.Name); } } } } if (particle is XmlSchemaElement) { XmlSchemaElement elem = particle as XmlSchemaElement; if (elem.RefName.IsEmpty) { XmlSchemaType type = (XmlSchemaType)elem.ElementSchemaType; XmlSchemaComplexType complexType = type as XmlSchemaComplexType; if (complexType != null && complexType.Name == null) { TraverseParticle(complexType.ContentTypeParticle, null); } } } else if (particle is XmlSchemaGroupBase) { //xs:all, xs:choice, xs:sequence //XmlSchemaGroupBase baseParticle = particle as XmlSchemaGroupBase; //foreach (XmlSchemaParticle subParticle in baseParticle.Items) //TraverseParticle(subParticle,null); } } }
private static void TraverseParticle(XmlSchemaParticle particle, ArrayList elementDeclsInContentModel) { if (particle is XmlSchemaElement) { XmlSchemaElement value = particle as XmlSchemaElement; elementDeclsInContentModel.Add(value); } else { if (!(particle is XmlSchemaGroupBase)) { return; } foreach (XmlSchemaParticle item in (particle as XmlSchemaGroupBase).Items) { TraverseParticle(item, elementDeclsInContentModel); } } }
public SQLSchema(string XMLSchemaPath, bool identity, bool includeFileId = false) { //Store whether we are including a file id IncludeFileId = includeFileId; Identity = identity; //If required, create a table to hold the names and ids of multiple files if (includeFileId) { SQLDatabase.DropTable("__File"); FileTable = new SQLTable(); FileTable.Name = "__File"; FileTable.Columns.Add(new SQLColumn("FileName", new SQLDataType("string", 255), true, false, FileTable)); FileTable.Schema = this; FileTable.Create(false); } //Load the schema XmlSchemaSet ss = new XmlSchemaSet(); ss.Add(null, XMLSchemaPath); //For each schema in the collection - ha, there's only ever one, but how else do you get to the schema collection? foreach (XmlSchema schema in ss.Schemas()) { //Get the namespace NameSpace = schema.TargetNamespace; //Loop through the top-level elements - only be one of these too foreach (XmlSchemaElement schemaElement in schema.Elements.Values) { //Cast the schema element to a particle XmlSchemaParticle schemaParticle = (XmlSchemaParticle)schemaElement; //Point to the root of the table hierarchy XmlNode node = TableHierarchy; //Recurse through all of the particles in the schema TraverseParticle(schemaParticle, schema, node); } } }
/// <summary> /// Returns the XmlSchemaElement specified by the given qname defined in the given particle. /// </summary> /// <param name="particle"></param> /// <param name="qname"></param> /// <returns></returns> private XmlSchemaElement GetXmlSchemaElementFromParticle(XmlSchemaParticle particle, XmlQualifiedName qname) { XmlSchemaElement xe = null; var xsgb = particle as XmlSchemaGroupBase; var xsgr = particle as XmlSchemaGroupRef; if (xsgb != null) { xe = GetXmlElementFromXmlSchemaGroupBase(xsgb, qname); } else if (xsgr != null) { xe = GetXmlElementFromXmlSchemaGroupBase(xsgr.Particle, qname); } else if (particle != null) { Debug.Fail("Unable to handle case where particle type is " + particle.GetType()); } return(xe); }
public static bool ContainsWildCard(this XmlSchemaParticle particle, XmlSchemaAny any) { XmlSchemaGroupBase groupBase = particle as XmlSchemaGroupBase; if (groupBase != null) { foreach (XmlSchemaParticle p in groupBase.Items) { if (p == any) { return(true); } else if (p.ContainsWildCard(any)) { return(true); } } } return(false); }
public static bool ContainsElement(this XmlSchemaParticle particle, XmlSchemaElement element) { XmlSchemaGroupBase groupBase = particle as XmlSchemaGroupBase; if (groupBase != null) { foreach (XmlSchemaParticle p in groupBase.Items) { if (p == element) { return(true); } else if (p.ContainsElement(element)) { return(true); } } } return(false); }
internal XSParticle(XmlSchemaParticle particle) : this() { if (!string.IsNullOrEmpty(particle.MinOccursString)) { _minOccurs = ValueFactory.Create(particle.MinOccurs); } if (particle.MaxOccursString == XS_UNBOUNDED) { _maxOccurs = ValueFactory.Create(decimal.MinusOne); } else if (!string.IsNullOrEmpty(particle.MaxOccursString)) { _minOccurs = ValueFactory.Create(particle.MaxOccurs); } _term = XMLSchemaSerializer.CreateIXSFragment(particle); }
private ChildEntry AddLeaf(ChildType childType, XmlSchemaObject parent, XmlSchemaParticle particle) { if (_childEntryStack.Count == 0) { var root = new List <ChildEntry>(); _childEntryStack.Push(root); } var childEntry = new ChildEntry { ChildType = childType, MinOccurs = particle == null ? 1 : particle.MinOccurs, MaxOccurs = particle == null ? 1 : particle.MaxOccurs, Particle = particle, Parent = parent }; _childEntryStack.Peek().Add(childEntry); return(childEntry); }
/* * ParseParticle * * This method parses an XML particle. A particle can be one of the following: * * XmlSchemaElement * XmlSchemaGroupBase - can be Sequence, Choice or All. * XmlSchemaGroupRef */ private static IPluglet ParseParticle(IPluglet parent, XmlSchemaParticle pa, XmlSchema schema) { //Console.WriteLine("ParseParticle.. " + pa.Id); IPluglet ret = null; if (pa is XmlSchemaElement) { ret = ParseElement(parent, (XmlSchemaElement)pa, schema); } else if (pa is XmlSchemaAny) { AppendSchemaError("SchemaCode107EXmlSchemaAnyFound"); } else if (pa is XmlSchemaGroupBase) { if (pa is XmlSchemaAll) { AppendSchemaError("SchemaCode108EXmlSchemaAllFound"); } else if (pa is XmlSchemaSequence) { AppendSchemaError("SchemaCode109EXmlSchemaSequenceFound"); } else if (pa is XmlSchemaChoice) { AppendSchemaError("SchemaCode110EXmlSchemaChoiceFound"); } } else if (pa is XmlSchemaGroupRef) { ParseParticle(parent, (XmlSchemaParticle)((XmlSchemaGroupRef)pa).Particle, schema); } return(ret); }
void CollectSubElements(XmlSchemaParticle particle) { // choice | sequence XmlSchemaGroupBase sgb = particle as XmlSchemaGroupBase; if (sgb != null) { foreach (XmlSchemaObject xso in sgb.Items) { XmlSchemaElement xse = xso as XmlSchemaElement; if (xse != null) { // If it's a ref, xse.QualifiedName.Name is the name of the element ElementWrapper elw = new ElementWrapper(xse, false); if (elw.IsComplexType) { Add(this.complexSubElements, xse); } else { Add(this.simpleSubElements, xse); } continue; } XmlSchemaParticle subParticle = xso as XmlSchemaParticle; if (subParticle != null) { CollectSubElements(subParticle); continue; } } } // group XmlSchemaGroupRef groupRef = particle as XmlSchemaGroupRef; if (groupRef != null) { CollectSubElements(groupRef.Particle); } }
public override void GetExpectedParticles(ArrayList al) { if (this.currentAutomata == null) { foreach (XmlSchemaObject xmlSchemaObject in this.seq.CompiledItems) { XmlSchemaParticle xmlSchemaParticle = (XmlSchemaParticle)xmlSchemaObject; al.Add(xmlSchemaParticle); if (!xmlSchemaParticle.ValidateIsEmptiable()) { break; } } return; } if (this.currentAutomata != null) { this.currentAutomata.GetExpectedParticles(al); if (!this.currentAutomata.EvaluateIsEmptiable()) { return; } for (int i = this.current + 1; i < this.seq.CompiledItems.Count; i++) { XmlSchemaParticle xmlSchemaParticle2 = this.seq.CompiledItems[i] as XmlSchemaParticle; al.Add(xmlSchemaParticle2); if (!xmlSchemaParticle2.ValidateIsEmptiable()) { break; } } } if (base.Occured + 1 == this.seq.ValidatedMaxOccurs) { return; } for (int j = 0; j <= this.current; j++) { al.Add(this.seq.CompiledItems[j]); } }
public override bool EvaluateEndElement() { this.emptiableComputed = false; if (this.choice.ValidatedMinOccurs > base.Occured + 1) { return(false); } if (this.choice.ValidatedMinOccurs <= base.Occured) { return(true); } for (int i = 0; i < this.choice.CompiledItems.Count; i++) { XmlSchemaParticle xsobj = (XmlSchemaParticle)this.choice.CompiledItems[i]; if (base.Manager.Create(xsobj).EvaluateIsEmptiable()) { return(true); } } return(false); }
IEnumerable <XmlSchemaElement> GetElementsInParticle(XmlSchemaParticle p) { if (p is XmlSchemaElement) { yield return((XmlSchemaElement)p); } else { var gb = p as XmlSchemaGroupBase; if (gb != null) { foreach (XmlSchemaParticle pp in gb.Items) { foreach (var e in GetElementsInParticle(pp)) { yield return(e); } } } } }
Shape ProcessParticle(XmlSchemaParticle xsp, Shape parent) { Shape s; if (xsp == XmlSchemaParticle.Empty) { return(null); } if (xsp is XmlSchemaElement) { s = ProcessParticleElement((XmlSchemaElement)xsp); } else if (xsp is XmlSchemaSequence) { s = ProcessParticleGroup((XmlSchemaSequence)xsp, BindingType.Sequence); } else if (xsp is XmlSchemaChoice) { s = ProcessParticleGroup((XmlSchemaChoice)xsp, BindingType.Choice); } else if (xsp is XmlSchemaAll) { s = ProcessParticleGroup((XmlSchemaAll)xsp, BindingType.All); } else //XmlSchemaAny { return(null); //Ignore Any in the content model } if (xsp.MaxOccurs > 1) { Shape rep = new Shape(s.Name, BindingType.Repeat); rep.AddSubShape(s); s = rep; } if (parent != null) { parent.AddSubShape(s); } return(s); }
public void DumpParticle (XmlSchemaParticle p) { if (p is XmlSchemaGroupBase) DumpGroupBase ((XmlSchemaGroupBase) p); else if (p is XmlSchemaElement) DumpElementNoRecurse ((XmlSchemaElement) p); else if (p is XmlSchemaAny) DumpAny ((XmlSchemaAny) p); else IndentLine (p); }
} //WriteXmlSchemaSimpleType() //XmlSchemaParticle public static void WriteXmlSchemaParticle(XmlSchemaParticle particle, XmlSchema myXmlSchema, XmlTextWriter myXmlTextWriter) { if (particle is XmlSchemaElement) { WriteXmlSchemaElement((XmlSchemaElement)particle, myXmlSchema, myXmlTextWriter); } //if else if (particle is XmlSchemaSequence) { myXmlTextWriter.WriteStartElement("sequence", XmlSchema.Namespace); foreach(XmlSchemaParticle particle1 in ((XmlSchemaSequence)particle).Items) WriteXmlSchemaParticle(particle1, myXmlSchema, myXmlTextWriter); myXmlTextWriter.WriteEndElement(); } //else if else if (particle is XmlSchemaGroupRef) { XmlSchemaGroupRef xsgr = (XmlSchemaGroupRef)particle; XmlSchemaGroup group = (XmlSchemaGroup)myXmlSchema.Groups[xsgr.RefName]; WriteXmlSchemaGroup(group, myXmlSchema, myXmlTextWriter, xsgr.RefName.Name); } //else if else { Console.WriteLine("Not Implemented for this type: {0}", particle.ToString()); } //else } //WriteXmlSchemaParticle()
} //WriteExampleAttribute() // Write example particles public static void WriteExampleParticle(XmlSchemaParticle particle, XmlSchema myXmlSchema, XmlTextWriter myXmlTextWriter) { Decimal max; if (particle.MaxOccurs == -1 || particle.MaxOccurs > 10000) { max = 5; } //if else { max = particle.MaxOccurs; } //else for (int i = 0; i < max; i ++) { if (particle is XmlSchemaElement) { WriteExampleElement((XmlSchemaElement)particle, myXmlSchema, myXmlTextWriter); } //if else if (particle is XmlSchemaSequence) { foreach (XmlSchemaParticle particle1 in ((XmlSchemaSequence)particle).Items) WriteExampleParticle(particle1, myXmlSchema, myXmlTextWriter); } //else if else if (particle is XmlSchemaGroupRef) { XmlSchemaGroupRef xsgr = (XmlSchemaGroupRef)particle; XmlSchemaGroup group = (XmlSchemaGroup)myXmlSchema.Groups[xsgr.RefName]; WriteExampleParticle(group.Particle, myXmlSchema, myXmlTextWriter); } //else if else { Console.WriteLine("Not Implemented for this type: {0}", particle.ToString()); } //else } //for } //WriteExampleParticle()