} //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()
void Write57_XmlSchemaGroup(XmlSchemaGroup o) { if ((object)o == null) { return; } WriteStartElement("group"); WriteAttribute(@"id", @"", ((System.String)o.@Id)); WriteAttribute(@"name", @"", ((System.String)o.@Name)); WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o); Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation); if (o.@Particle is XmlSchemaSequence) { Write54_XmlSchemaSequence((XmlSchemaSequence)o.@Particle); } else if (o.@Particle is XmlSchemaChoice) { Write52_XmlSchemaChoice((XmlSchemaChoice)o.@Particle); } else if (o.@Particle is XmlSchemaAll) { Write43_XmlSchemaAll((XmlSchemaAll)o.@Particle); } WriteEndElement(); }
internal XSModelGroupDefinition(XmlSchemaGroup xmlGroup) { _group = xmlGroup; _name = xmlGroup.Name; if (_group.Annotation is XmlSchemaAnnotation annotation) { _annotation = XMLSchemaSerializer.CreateXSAnnotation(annotation); _annotation.BindToContainer(RootContainer, this); } if (xmlGroup.Particle is XmlSchemaGroupBase xmlGroupBase) { IXSComponent component = XMLSchemaSerializer.CreateInstance(xmlGroupBase); if (component is XSParticle particle) { _modelGroup = particle; } else if (component is XSModelGroup modelGroup) { _modelGroup = modelGroup; } } }
public static IEnumerable <XmlSchemaElement> LocalXsdElements(this XmlSchema schema) { IEnumerator enumerator = schema.Elements.Values.GetEnumerator(); while (enumerator.MoveNext()) { XmlSchemaElement current = (XmlSchemaElement)enumerator.Current; foreach (XmlSchemaElement iteratorVariable1 in current.LocalXsdElements()) { yield return(iteratorVariable1); } } IEnumerator iteratorVariable9 = schema.SchemaTypes.Values.GetEnumerator(); while (iteratorVariable9.MoveNext()) { XmlSchemaType ty = (XmlSchemaType)iteratorVariable9.Current; foreach (XmlSchemaElement iteratorVariable3 in ty.LocalXsdElements()) { yield return(iteratorVariable3); } } IEnumerator iteratorVariable12 = schema.Groups.Values.GetEnumerator(); while (iteratorVariable12.MoveNext()) { XmlSchemaGroup gr = (XmlSchemaGroup)iteratorVariable12.Current; foreach (XmlSchemaElement iteratorVariable5 in gr.LocalXsdElements()) { yield return(iteratorVariable5); } } }
public List <ChildEntry> GetChildren(XmlSchemaGroup group) { var childrenFinder = new ChildrenFinder(this); childrenFinder.Traverse(group); return(childrenFinder.GetChildren()); }
public void Pass_XmlSchemaAnnotation_XmlSchemaGroup_XmlSchemaAny_Invalid(string TypeToPass) { XmlSchemaValidator val = CreateValidator(new XmlSchemaSet()); XmlSchemaObject obj = new XmlSchemaAnnotation(); switch (TypeToPass) { case "annotation": obj = new XmlSchemaAnnotation(); break; case "group": obj = new XmlSchemaGroup(); break; case "any": obj = new XmlSchemaAny(); break; default: Assert.True(false); break; } try { val.Initialize(obj); } catch (ArgumentException) { return; } Assert.True(false); }
private static void Equal(XmlSchemaGroup expected, XmlSchemaGroup actual) { AnnotatedEqual(expected, actual); Assert.Equal(expected.Name, actual.Name); IsEquivalentTo(expected.Particle, actual.Particle); Assert.Equal(expected.QualifiedName, actual.QualifiedName); }
/// <summary> /// Creates a new group type /// </summary> public static XmlSchemaGroup CreateGroupType(string name) { var groupType = new XmlSchemaGroup { Name = name + "GroupCT" }; return(groupType); }
public void IterateThrough(XmlSchemaGroup obj) { if (_functionalVisitor.StartProcessing(obj)) { obj.Particle.Accept(this); } _functionalVisitor.EndProcessing(obj); }
public void DumpGroup (XmlSchemaGroup g) { depth++; IndentLine ("**Group**"); IndentLine ("Name: " + g.Name); depth--; }
private bool LoadXmlSchemaGroup(XmlSchemaGroup group) { if (group == null) { return(false); } _groups.Add(group.Name, group); return(true); }
private List <XmlSchemaAny> GetAnyElements(XmlSchemaGroup group) { var children = GetChildren(group); var result = new List <XmlSchemaAny>(); if (children != null) { GetAnyElements(result, children); } return(result); }
void ProcessGroup(XmlSchemaGroup G, P_PSMDiagram diagram) { Print("Group: " + G.Name + Environment.NewLine, 0); P_PSMClass C = new P_PSMClass() { Name = G.QualifiedName }; diagram.GlobalIDs.Add(C.Name, C); diagram.UsedNames.Add(C.Name); diagram.Children.Add(C); C.Parent = diagram; TraverseParticle(G.Particle, 1, C, diagram); }
public static List <XmlSchemaGroup> extractGroups(XmlSchema schema) { List <XmlSchemaGroup> list = new List <XmlSchemaGroup>(); foreach (object item in schema.Items) { if (item is XmlSchemaGroup) { XmlSchemaGroup group = (XmlSchemaGroup)item; list.Add(group); } } return(list); }
/// <summary> /// Creates a group that contains all of the elements that may be children of the root. /// That is, all types, and and explicit relationship instances. /// </summary> private void AddRootChildren() { // Example of inheritance declaration //<xs:group name="rootchildren"> // <xs:choice> // <xs:element ref="person" /> // <xs:element ref="employee" /> // <xs:element ref="manager" /> // <xs:element ref="worksFor.instance" /> // </xs:choice> //</xs:group> // Create a group, named "rootchildren" var rootChildrenGroup = new XmlSchemaGroup(); rootChildrenGroup.Name = "rootchildren"; rootChildrenGroup.Particle = new XmlSchemaChoice(); // All types var types = EffectiveTypes(_schemaManager.GetInstancesOfType(A(Aliases.Type))); foreach (EffectiveType type in types) { bool isAbstract = _schemaManager.GetBoolFieldValue(type.Type, Aliases2.IsAbstract); if (isAbstract) { continue; } var typeElement = new XmlSchemaElement(); typeElement.RefName = NameUsed(type.Alias.ToQualifiedName()); rootChildrenGroup.Particle.Items.Add(typeElement); } // All relationships var relationships = EffectiveRelationships(_schemaManager.GetInstancesOfType(A(Aliases.Relationship))); foreach (EffectiveRelationship relationship in relationships) { var relElement = new XmlSchemaElement(); relElement.RefName = NameUsed(relationship.Alias.ToQualifiedName(suffix: XmlParser.RelationshipInstanceSuffix)); rootChildrenGroup.Particle.Items.Add(relElement); } XmlSchema xsd = GetSchema(Aliases.CoreNamespace); xsd.Items.Insert(0, rootChildrenGroup); }
// Utilities private XmlSchemaGroup FindGroup(XmlQualifiedName qname) { foreach (XmlSchema schema in schemas) { foreach (XmlQualifiedName name in schema.Groups.Names) { XmlSchemaGroup group = schema.Groups [name] as XmlSchemaGroup; if (group.Name == qname.Name) { return(group); } } } return(null); }
/// <summary> /// Creates a group that contains all of the types that inherit from a given type, /// as well as the type itself. Reference this group when any inherited type is suitable. /// </summary> private void AddTypeDescendents(EffectiveType entityType, XmlSchema xsd) { // Example of inheritance declaration //<xs:group name="is_person"> // <xs:choice> // <xs:element ref="person" /> // <xs:element ref="employee" /> // <xs:element ref="manager" /> // </xs:choice> //</xs:group> // Create a group, named "is_%typename%" var isType = new XmlSchemaGroup(); isType.Name = NameDeclared("is_" + entityType.Alias.Value, entityType.Alias.Namespace); isType.Particle = new XmlSchemaChoice(); // Determine valid descendents IEnumerable <Entity> descendents; bool isSealed = _schemaManager.GetBoolFieldValue(entityType.Type, Aliases2.IsSealed); if (isSealed) { descendents = new List <Entity> { entityType.Type } } ; else { descendents = _schemaManager.GetDecendants(entityType.Type); } // Render each type foreach (EffectiveType desc in EffectiveTypes(descendents)) { bool isAbstract = _schemaManager.GetBoolFieldValue(desc.Type, Aliases2.IsAbstract); if (isAbstract) { continue; } var derivedType = new XmlSchemaElement(); derivedType.RefName = NameUsed(desc.Alias.ToQualifiedName()); isType.Particle.Items.Add(derivedType); } xsd.Items.Add(isType); }
public override void FixtureInit() { XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection(); schemas.Add(SchemaCompletionData); XmlSchemaCompletionData xsdSchemaCompletionData = new XmlSchemaCompletionData(ResourceManager.GetXsdSchema()); schemas.Add(xsdSchemaCompletionData); XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xsdSchemaCompletionData, String.Empty); string xml = GetSchema(); int index = xml.IndexOf("ref=\"block\""); index = xml.IndexOf("block", index); schemaGroup = (XmlSchemaGroup)XmlView.GetSchemaObjectSelected(xml, index, provider, SchemaCompletionData); }
public override void FixtureInit() { XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection(); schemas.Add(SchemaCompletion); XmlSchemaCompletion xsdSchemaCompletion = new XmlSchemaCompletion(ResourceManager.ReadXsdSchema()); schemas.Add(xsdSchemaCompletion); string xml = GetSchema(); int index = xml.IndexOf("ref=\"block\""); index = xml.IndexOf("block", index); XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion); schemaGroup = (XmlSchemaGroup)schemaDefinition.GetSelectedSchemaObject(xml, index); }
} //WriteXmlSchemaAttributeGroup() //XmlSchemaGroup public static void WriteXmlSchemaGroup(XmlSchemaGroup group, XmlSchema myXmlSchema, XmlTextWriter myXmlTextWriter, string RefName) { myXmlTextWriter.WriteStartElement("group", XmlSchema.Namespace); if (RefName == null) { myXmlTextWriter.WriteAttributeString("name", XmlSchema.Namespace, group.Name); } //if else { myXmlTextWriter.WriteAttributeString("ref", XmlSchema.Namespace, RefName); } //else WriteXmlSchemaParticle(group.Particle, myXmlSchema, myXmlTextWriter); myXmlTextWriter.WriteEndElement(); } //WriteXmlSchemaGroup()
private void RegistEleForRefAttribute(string xsdFileName) { XmlSchema rootSchema = GetSchemaFromFile(xsdFileName); string subfolerName = xsdFileName.Replace(".xsd", ""); foreach (XmlSchemaObject item in rootSchema.Items) { if (item is XmlSchemaSimpleType) { XmlSchemaSimpleType xsst = item as XmlSchemaSimpleType; includePath.Add(xsst.Name, subfolerName); } else if (item is XmlSchemaComplexType) { XmlSchemaComplexType xsct = item as XmlSchemaComplexType; includePath.Add(xsct.Name, subfolerName); } else if (item is XmlSchemaElement) { XmlSchemaElement xe = item as XmlSchemaElement; if (xe.RefName.IsEmpty) { //string nametype = xe.ElementSchemaType.Name; //string nametype2 = xe.SchemaTypeName.Name; //ref 가 없는 element만 넣어서 나중에 이 List를 뒤져서 Type을 알아냄 elementRef.Add(xe.Name, xe.SchemaTypeName.Name); //ref 가 없고 substitutionGroup이 있는 element만 넣어서 나중에 이 List를 뒤져서 substitution 에 추가함 if (!xe.SubstitutionGroup.IsEmpty) { KeyValuePair <string, string> pair = new KeyValuePair <string, string>(xe.SubstitutionGroup.Name, xe.Name); elementSubstitutionRef.Add(pair); } } } else if (item is XmlSchemaGroup) { XmlSchemaGroup xe = item as XmlSchemaGroup; elementGroupRef.Add(xe.Name, xe); } } }
internal XmlSchemaObject FindSchemaGroup(XmlSchema s, string localName) { if (s.Groups == null) { return((XmlSchemaObject)null); } foreach (XmlSchemaObject xmlSchemaObject in (IEnumerable)s.Groups.Values) { if (xmlSchemaObject is XmlSchemaGroup) { XmlSchemaGroup xmlSchemaGroup = (XmlSchemaGroup)xmlSchemaObject; if (xmlSchemaGroup.Name == localName) { return((XmlSchemaObject)xmlSchemaGroup); } } } return((XmlSchemaObject)null); }
private TypeModel CreateTypeModel(Uri source, XmlSchemaGroup group, NamespaceModel namespaceModel, XmlQualifiedName qualifiedName, List <DocumentationModel> docs) { var name = "I" + _configuration.NamingProvider.GroupTypeNameFromQualifiedName(qualifiedName); if (namespaceModel != null) { name = namespaceModel.GetUniqueTypeName(name); } var interfaceModel = new InterfaceModel(_configuration) { Name = name, Namespace = namespaceModel, XmlSchemaName = qualifiedName }; interfaceModel.Documentation.AddRange(docs); if (namespaceModel != null) { namespaceModel.Types[name] = interfaceModel; } if (!qualifiedName.IsEmpty) { var key = BuildKey(group, qualifiedName); Types[key] = interfaceModel; } var particle = group.Particle; var items = GetElements(particle); var properties = CreatePropertiesForElements(source, interfaceModel, particle, items.Where(i => !(i.XmlParticle is XmlSchemaGroupRef))); interfaceModel.Properties.AddRange(properties); var interfaces = items.Select(i => i.XmlParticle).OfType <XmlSchemaGroupRef>() .Select(i => (InterfaceModel)CreateTypeModel(CodeUtilities.CreateUri(i.SourceUri), Groups[i.RefName], i.RefName)); interfaceModel.AddInterfaces(interfaces); return(interfaceModel); }
} //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()
private bool LoadXmlSchemaGroupRef(XmlSchemaGroupRef groupRef) { if (groupRef == null) { return(false); } if (groupRef.RefName != null) { XmlSchemaParticle part = null; string groupName = groupRef.RefName.Name; if (xcontoler._complexTypes.ContainsKey(groupName)) { XmlSchemaComplexType cct = xcontoler._complexTypes[groupName]; part = cct.Particle; } else if (xcontoler._groups.ContainsKey(groupName)) { XmlSchemaGroup group = xcontoler._groups[groupName]; part = group.Particle; } LoadXmlSchemaObject(part); } return(true); }
private void Write57_XmlSchemaGroup(XmlSchemaGroup o) { if (o != null) { this.WriteStartElement("group"); this.WriteAttribute("id", "", o.Id); this.WriteAttribute("name", "", o.Name); this.WriteAttributes(o.UnhandledAttributes, o); this.Write5_XmlSchemaAnnotation(o.Annotation); if (o.Particle is XmlSchemaSequence) { this.Write54_XmlSchemaSequence((XmlSchemaSequence)o.Particle); } else if (o.Particle is XmlSchemaChoice) { this.Write52_XmlSchemaChoice((XmlSchemaChoice)o.Particle); } else if (o.Particle is XmlSchemaAll) { this.Write43_XmlSchemaAll((XmlSchemaAll)o.Particle); } this.WriteEndElement(); } }
private static XmlSchema CreateFakeSoapEncodingSchema(string ns, string name) { var schema = new XmlSchema(); schema.TargetNamespace = ns; var item = new XmlSchemaGroup(); item.Name = "Array"; var sequence = new XmlSchemaSequence(); var any = new XmlSchemaAny(); any.MinOccurs = 0M; any.MaxOccurs = 79228162514264337593543950335M; sequence.Items.Add(any); any.Namespace = "##any"; any.ProcessContents = XmlSchemaContentProcessing.Lax; item.Particle = sequence; schema.Items.Add(item); var type = new XmlSchemaComplexType(); type.Name = name; var ref2 = new XmlSchemaGroupRef(); ref2.RefName = new XmlQualifiedName("Array", ns); type.Particle = ref2; var attribute = new XmlSchemaAttribute(); attribute.RefName = new XmlQualifiedName("arrayType", ns); type.Attributes.Add(attribute); schema.Items.Add(type); attribute = new XmlSchemaAttribute(); attribute.Use = XmlSchemaUse.None; attribute.Name = "arrayType"; schema.Items.Add(attribute); AddSimpleType(schema, "base64", "base64Binary"); AddElementAndType(schema, "anyURI", ns); AddElementAndType(schema, "base64Binary", ns); AddElementAndType(schema, "boolean", ns); AddElementAndType(schema, "byte", ns); AddElementAndType(schema, "date", ns); AddElementAndType(schema, "dateTime", ns); AddElementAndType(schema, "decimal", ns); AddElementAndType(schema, "double", ns); AddElementAndType(schema, "duration", ns); AddElementAndType(schema, "ENTITIES", ns); AddElementAndType(schema, "ENTITY", ns); AddElementAndType(schema, "float", ns); AddElementAndType(schema, "gDay", ns); AddElementAndType(schema, "gMonth", ns); AddElementAndType(schema, "gMonthDay", ns); AddElementAndType(schema, "gYear", ns); AddElementAndType(schema, "gYearMonth", ns); AddElementAndType(schema, "hexBinary", ns); AddElementAndType(schema, "ID", ns); AddElementAndType(schema, "IDREF", ns); AddElementAndType(schema, "IDREFS", ns); AddElementAndType(schema, "int", ns); AddElementAndType(schema, "integer", ns); AddElementAndType(schema, "language", ns); AddElementAndType(schema, "long", ns); AddElementAndType(schema, "Name", ns); AddElementAndType(schema, "NCName", ns); AddElementAndType(schema, "negativeInteger", ns); AddElementAndType(schema, "NMTOKEN", ns); AddElementAndType(schema, "NMTOKENS", ns); AddElementAndType(schema, "nonNegativeInteger", ns); AddElementAndType(schema, "nonPositiveInteger", ns); AddElementAndType(schema, "normalizedString", ns); AddElementAndType(schema, "positiveInteger", ns); AddElementAndType(schema, "QName", ns); AddElementAndType(schema, "short", ns); AddElementAndType(schema, "string", ns); AddElementAndType(schema, "time", ns); AddElementAndType(schema, "token", ns); AddElementAndType(schema, "unsignedByte", ns); AddElementAndType(schema, "unsignedInt", ns); AddElementAndType(schema, "unsignedLong", ns); AddElementAndType(schema, "unsignedShort", ns); return(schema); }
public static void Main() { XmlSchema schema = new XmlSchema(); // <xs:element name="thing1" type="xs:string"/> XmlSchemaElement elementThing1 = new XmlSchemaElement(); schema.Items.Add(elementThing1); elementThing1.Name = "thing1"; elementThing1.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); // <xs:element name="thing2" type="xs:string"/> XmlSchemaElement elementThing2 = new XmlSchemaElement(); schema.Items.Add(elementThing2); elementThing2.Name = "thing2"; elementThing2.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); // <xs:element name="thing3" type="xs:string"/> XmlSchemaElement elementThing3 = new XmlSchemaElement(); schema.Items.Add(elementThing3); elementThing3.Name = "thing3"; elementThing3.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); // <xs:attribute name="myAttribute" type="xs:decimal"/> XmlSchemaAttribute myAttribute = new XmlSchemaAttribute(); schema.Items.Add(myAttribute); myAttribute.Name = "myAttribute"; myAttribute.SchemaTypeName = new XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema"); // <xs:group name="myGroupOfThings"> XmlSchemaGroup myGroupOfThings = new XmlSchemaGroup(); schema.Items.Add(myGroupOfThings); myGroupOfThings.Name = "myGroupOfThings"; // <xs:sequence> XmlSchemaSequence sequence = new XmlSchemaSequence(); myGroupOfThings.Particle = sequence; // <xs:element ref="thing1"/> XmlSchemaElement elementThing1Ref = new XmlSchemaElement(); sequence.Items.Add(elementThing1Ref); elementThing1Ref.RefName = new XmlQualifiedName("thing1"); // <xs:element ref="thing2"/> XmlSchemaElement elementThing2Ref = new XmlSchemaElement(); sequence.Items.Add(elementThing2Ref); elementThing2Ref.RefName = new XmlQualifiedName("thing2"); // <xs:element ref="thing3"/> XmlSchemaElement elementThing3Ref = new XmlSchemaElement(); sequence.Items.Add(elementThing3Ref); elementThing3Ref.RefName = new XmlQualifiedName("thing3"); // <xs:complexType name="myComplexType"> XmlSchemaComplexType myComplexType = new XmlSchemaComplexType(); schema.Items.Add(myComplexType); myComplexType.Name = "myComplexType"; // <xs:group ref="myGroupOfThings"/> XmlSchemaGroupRef myGroupOfThingsRef = new XmlSchemaGroupRef(); myComplexType.Particle = myGroupOfThingsRef; myGroupOfThingsRef.RefName = new XmlQualifiedName("myGroupOfThings"); // <xs:attribute ref="myAttribute"/> XmlSchemaAttribute myAttributeRef = new XmlSchemaAttribute(); myComplexType.Attributes.Add(myAttributeRef); myAttributeRef.RefName = new XmlQualifiedName("myAttribute"); XmlSchemaSet schemaSet = new XmlSchemaSet(); schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallbackOne); schemaSet.Add(schema); schemaSet.Compile(); XmlSchema compiledSchema = null; foreach (XmlSchema schema1 in schemaSet.Schemas()) { compiledSchema = schema1; } XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); compiledSchema.Write(Console.Out, nsmgr); }
static void Check(ConformanceCheckContext ctx, ConformanceChecker checker, Hashtable visitedObjects, XmlSchemaObject value) { if (value == null) { return; } if (visitedObjects.Contains(value)) { return; } visitedObjects.Add(value, value); if (value is XmlSchemaImport) { XmlSchemaImport so = (XmlSchemaImport)value; checker.Check(ctx, so); } else if (value is XmlSchemaAll) { XmlSchemaAll so = (XmlSchemaAll)value; checker.Check(ctx, so); CheckObjects(ctx, checker, visitedObjects, so.Items); } else if (value is XmlSchemaAnnotation) { XmlSchemaAnnotation so = (XmlSchemaAnnotation)value; checker.Check(ctx, so); CheckObjects(ctx, checker, visitedObjects, so.Items); } else if (value is XmlSchemaAttribute) { XmlSchemaAttribute so = (XmlSchemaAttribute)value; checker.Check(ctx, so); } else if (value is XmlSchemaAttributeGroup) { XmlSchemaAttributeGroup so = (XmlSchemaAttributeGroup)value; checker.Check(ctx, so); CheckObjects(ctx, checker, visitedObjects, so.Attributes); Check(ctx, checker, visitedObjects, so.AnyAttribute); Check(ctx, checker, visitedObjects, so.RedefinedAttributeGroup); } else if (value is XmlSchemaAttributeGroupRef) { XmlSchemaAttributeGroupRef so = (XmlSchemaAttributeGroupRef)value; checker.Check(ctx, so); } else if (value is XmlSchemaChoice) { XmlSchemaChoice so = (XmlSchemaChoice)value; checker.Check(ctx, so); CheckObjects(ctx, checker, visitedObjects, so.Items); } else if (value is XmlSchemaComplexContent) { XmlSchemaComplexContent so = (XmlSchemaComplexContent)value; checker.Check(ctx, so); Check(ctx, checker, visitedObjects, so.Content); } else if (value is XmlSchemaComplexContentExtension) { XmlSchemaComplexContentExtension so = (XmlSchemaComplexContentExtension)value; checker.Check(ctx, so); Check(ctx, checker, visitedObjects, so.Particle); CheckObjects(ctx, checker, visitedObjects, so.Attributes); Check(ctx, checker, visitedObjects, so.AnyAttribute); } else if (value is XmlSchemaComplexContentRestriction) { XmlSchemaComplexContentRestriction so = (XmlSchemaComplexContentRestriction)value; checker.Check(ctx, so); Check(ctx, checker, visitedObjects, so.Particle); CheckObjects(ctx, checker, visitedObjects, so.Attributes); Check(ctx, checker, visitedObjects, so.AnyAttribute); } else if (value is XmlSchemaComplexType) { XmlSchemaComplexType so = (XmlSchemaComplexType)value; checker.Check(ctx, so); Check(ctx, checker, visitedObjects, so.ContentModel); Check(ctx, checker, visitedObjects, so.Particle); CheckObjects(ctx, checker, visitedObjects, so.Attributes); Check(ctx, checker, visitedObjects, so.AnyAttribute); Check(ctx, checker, visitedObjects, so.ContentTypeParticle); Check(ctx, checker, visitedObjects, so.AttributeWildcard); } else if (value is XmlSchemaElement) { XmlSchemaElement so = (XmlSchemaElement)value; checker.Check(ctx, so); Check(ctx, checker, visitedObjects, so.SchemaType); CheckObjects(ctx, checker, visitedObjects, so.Constraints); } else if (value is XmlSchemaGroup) { XmlSchemaGroup so = (XmlSchemaGroup)value; checker.Check(ctx, so); Check(ctx, checker, visitedObjects, so.Particle); } else if (value is XmlSchemaGroupRef) { XmlSchemaGroupRef so = (XmlSchemaGroupRef)value; checker.Check(ctx, so); } else if (value is XmlSchemaIdentityConstraint) { XmlSchemaIdentityConstraint so = (XmlSchemaIdentityConstraint)value; checker.Check(ctx, so); CheckObjects(ctx, checker, visitedObjects, so.Fields); Check(ctx, checker, visitedObjects, so.Selector); } else if (value is XmlSchemaKeyref) { XmlSchemaKeyref so = (XmlSchemaKeyref)value; checker.Check(ctx, so); } else if (value is XmlSchemaRedefine) { XmlSchemaRedefine so = (XmlSchemaRedefine)value; checker.Check(ctx, so); CheckObjects(ctx, checker, visitedObjects, so.Items); } else if (value is XmlSchemaSequence) { XmlSchemaSequence so = (XmlSchemaSequence)value; checker.Check(ctx, so); CheckObjects(ctx, checker, visitedObjects, so.Items); } else if (value is XmlSchemaSimpleContent) { XmlSchemaSimpleContent so = (XmlSchemaSimpleContent)value; checker.Check(ctx, so); Check(ctx, checker, visitedObjects, so.Content); } else if (value is XmlSchemaSimpleContentExtension) { XmlSchemaSimpleContentExtension so = (XmlSchemaSimpleContentExtension)value; checker.Check(ctx, so); CheckObjects(ctx, checker, visitedObjects, so.Attributes); Check(ctx, checker, visitedObjects, so.AnyAttribute); } else if (value is XmlSchemaSimpleContentRestriction) { XmlSchemaSimpleContentRestriction so = (XmlSchemaSimpleContentRestriction)value; checker.Check(ctx, so); CheckObjects(ctx, checker, visitedObjects, so.Attributes); Check(ctx, checker, visitedObjects, so.AnyAttribute); CheckObjects(ctx, checker, visitedObjects, so.Facets); } else if (value is XmlSchemaSimpleType) { XmlSchemaSimpleType so = (XmlSchemaSimpleType)value; checker.Check(ctx, so); Check(ctx, checker, visitedObjects, so.Content); } else if (value is XmlSchemaSimpleTypeList) { XmlSchemaSimpleTypeList so = (XmlSchemaSimpleTypeList)value; checker.Check(ctx, so); } else if (value is XmlSchemaSimpleTypeRestriction) { XmlSchemaSimpleTypeRestriction so = (XmlSchemaSimpleTypeRestriction)value; checker.Check(ctx, so); CheckObjects(ctx, checker, visitedObjects, so.Facets); } else if (value is XmlSchemaSimpleTypeUnion) { XmlSchemaSimpleTypeUnion so = (XmlSchemaSimpleTypeUnion)value; checker.Check(ctx, so); } }
internal void Depends(XmlSchemaObject item, ArrayList refs) { if (item == null || scope[item] != null) { return; } Type t = item.GetType(); if (typeof(XmlSchemaType).IsAssignableFrom(t)) { XmlQualifiedName baseName = XmlQualifiedName.Empty; XmlSchemaType baseType = null; XmlSchemaParticle particle = null; XmlSchemaObjectCollection attributes = null; if (item is XmlSchemaComplexType) { XmlSchemaComplexType ct = (XmlSchemaComplexType)item; if (ct.ContentModel != null) { XmlSchemaContent content = ct.ContentModel.Content; if (content is XmlSchemaComplexContentRestriction) { baseName = ((XmlSchemaComplexContentRestriction)content).BaseTypeName; attributes = ((XmlSchemaComplexContentRestriction)content).Attributes; } else if (content is XmlSchemaSimpleContentRestriction) { XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction)content; if (restriction.BaseType != null) { baseType = restriction.BaseType; } else { baseName = restriction.BaseTypeName; } attributes = restriction.Attributes; } else if (content is XmlSchemaComplexContentExtension) { XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)content; attributes = extension.Attributes; particle = extension.Particle; baseName = extension.BaseTypeName; } else if (content is XmlSchemaSimpleContentExtension) { XmlSchemaSimpleContentExtension extension = (XmlSchemaSimpleContentExtension)content; attributes = extension.Attributes; baseName = extension.BaseTypeName; } } else { attributes = ct.Attributes; particle = ct.Particle; } if (particle is XmlSchemaGroupRef) { XmlSchemaGroupRef refGroup = (XmlSchemaGroupRef)particle; particle = ((XmlSchemaGroup)schemas.Find(refGroup.RefName, typeof(XmlSchemaGroup), false)).Particle; } else if (particle is XmlSchemaGroupBase) { particle = (XmlSchemaGroupBase)particle; } } else if (item is XmlSchemaSimpleType) { XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)item; XmlSchemaSimpleTypeContent content = simpleType.Content; if (content is XmlSchemaSimpleTypeRestriction) { baseType = ((XmlSchemaSimpleTypeRestriction)content).BaseType; baseName = ((XmlSchemaSimpleTypeRestriction)content).BaseTypeName; } else if (content is XmlSchemaSimpleTypeList) { XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)content; if (list.ItemTypeName != null && !list.ItemTypeName.IsEmpty) { baseName = list.ItemTypeName; } if (list.ItemType != null) { baseType = list.ItemType; } } else if (content is XmlSchemaSimpleTypeRestriction) { baseName = ((XmlSchemaSimpleTypeRestriction)content).BaseTypeName; } else if (t == typeof(XmlSchemaSimpleTypeUnion)) { XmlQualifiedName[] memberTypes = ((XmlSchemaSimpleTypeUnion)item).MemberTypes; if (memberTypes != null) { for (int i = 0; i < memberTypes.Length; i++) { XmlSchemaType type = (XmlSchemaType)schemas.Find(memberTypes[i], typeof(XmlSchemaType), false); AddRef(refs, type); } } } } if (baseType == null && !baseName.IsEmpty && baseName.Namespace != XmlSchema.Namespace) { baseType = (XmlSchemaType)schemas.Find(baseName, typeof(XmlSchemaType), false); } if (baseType != null) { AddRef(refs, baseType); } if (particle != null) { Depends(particle, refs); } if (attributes != null) { for (int i = 0; i < attributes.Count; i++) { Depends(attributes[i], refs); } } } else if (t == typeof(XmlSchemaElement)) { XmlSchemaElement el = (XmlSchemaElement)item; if (!el.SubstitutionGroup.IsEmpty) { if (el.SubstitutionGroup.Namespace != XmlSchema.Namespace) { XmlSchemaElement head = (XmlSchemaElement)schemas.Find(el.SubstitutionGroup, typeof(XmlSchemaElement), false); AddRef(refs, head); } } if (!el.RefName.IsEmpty) { el = (XmlSchemaElement)schemas.Find(el.RefName, typeof(XmlSchemaElement), false); AddRef(refs, el); } else if (!el.SchemaTypeName.IsEmpty) { XmlSchemaType type = (XmlSchemaType)schemas.Find(el.SchemaTypeName, typeof(XmlSchemaType), false); AddRef(refs, type); } else { Depends(el.SchemaType, refs); } } else if (t == typeof(XmlSchemaGroup)) { Depends(((XmlSchemaGroup)item).Particle); } else if (t == typeof(XmlSchemaGroupRef)) { XmlSchemaGroup group = (XmlSchemaGroup)schemas.Find(((XmlSchemaGroupRef)item).RefName, typeof(XmlSchemaGroup), false); AddRef(refs, group); } else if (typeof(XmlSchemaGroupBase).IsAssignableFrom(t)) { foreach (XmlSchemaObject o in ((XmlSchemaGroupBase)item).Items) { Depends(o, refs); } } else if (t == typeof(XmlSchemaAttributeGroupRef)) { XmlSchemaAttributeGroup group = (XmlSchemaAttributeGroup)schemas.Find(((XmlSchemaAttributeGroupRef)item).RefName, typeof(XmlSchemaAttributeGroup), false); AddRef(refs, group); } else if (t == typeof(XmlSchemaAttributeGroup)) { foreach (XmlSchemaObject o in ((XmlSchemaAttributeGroup)item).Attributes) { Depends(o, refs); } } else if (t == typeof(XmlSchemaAttribute)) { XmlSchemaAttribute at = (XmlSchemaAttribute)item; if (!at.RefName.IsEmpty) { at = (XmlSchemaAttribute)schemas.Find(at.RefName, typeof(XmlSchemaAttribute), false); AddRef(refs, at); } else if (!at.SchemaTypeName.IsEmpty) { XmlSchemaType type = (XmlSchemaType)schemas.Find(at.SchemaTypeName, typeof(XmlSchemaType), false); AddRef(refs, type); } else { Depends(at.SchemaType, refs); } } if (typeof(XmlSchemaAnnotated).IsAssignableFrom(t)) { XmlAttribute[] attrs = (XmlAttribute[])((XmlSchemaAnnotated)item).UnhandledAttributes; if (attrs != null) { for (int i = 0; i < attrs.Length; i++) { XmlAttribute attribute = attrs[i]; if (attribute.LocalName == Wsdl.ArrayType && attribute.NamespaceURI == Wsdl.Namespace) { string dims; XmlQualifiedName qname = TypeScope.ParseWsdlArrayType(attribute.Value, out dims, item); XmlSchemaType type = (XmlSchemaType)schemas.Find(qname, typeof(XmlSchemaType), false); AddRef(refs, type); } } } } }