internal static XmlSchema GetBuildInSchema() { if (builtInSchemaForXmlNS == null) { XmlSchema schema = new XmlSchema { TargetNamespace = "http://www.w3.org/XML/1998/namespace" }; schema.Namespaces.Add("xml", "http://www.w3.org/XML/1998/namespace"); XmlSchemaAttribute item = new XmlSchemaAttribute { Name = "lang", SchemaTypeName = new XmlQualifiedName("language", "http://www.w3.org/2001/XMLSchema") }; schema.Items.Add(item); XmlSchemaAttribute attribute2 = new XmlSchemaAttribute { Name = "base", SchemaTypeName = new XmlQualifiedName("anyURI", "http://www.w3.org/2001/XMLSchema") }; schema.Items.Add(attribute2); XmlSchemaAttribute attribute3 = new XmlSchemaAttribute { Name = "space" }; XmlSchemaSimpleType type = new XmlSchemaSimpleType(); XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction { BaseTypeName = new XmlQualifiedName("NCName", "http://www.w3.org/2001/XMLSchema") }; XmlSchemaEnumerationFacet facet = new XmlSchemaEnumerationFacet { Value = "default" }; restriction.Facets.Add(facet); XmlSchemaEnumerationFacet facet2 = new XmlSchemaEnumerationFacet { Value = "preserve" }; restriction.Facets.Add(facet2); type.Content = restriction; attribute3.SchemaType = type; attribute3.DefaultValue = "preserve"; schema.Items.Add(attribute3); XmlSchemaAttributeGroup group = new XmlSchemaAttributeGroup { Name = "specialAttrs" }; XmlSchemaAttribute attribute4 = new XmlSchemaAttribute { RefName = new XmlQualifiedName("lang", "http://www.w3.org/XML/1998/namespace") }; group.Attributes.Add(attribute4); XmlSchemaAttribute attribute5 = new XmlSchemaAttribute { RefName = new XmlQualifiedName("space", "http://www.w3.org/XML/1998/namespace") }; group.Attributes.Add(attribute5); XmlSchemaAttribute attribute6 = new XmlSchemaAttribute { RefName = new XmlQualifiedName("base", "http://www.w3.org/XML/1998/namespace") }; group.Attributes.Add(attribute6); schema.Items.Add(group); schema.IsPreprocessed = true; schema.CompileSchemaInSet(new NameTable(), null, null); Interlocked.CompareExchange<XmlSchema>(ref builtInSchemaForXmlNS, schema, null); } return builtInSchemaForXmlNS; }
internal static XmlSchema GetBuildInSchema() { if (builtInSchemaForXmlNS == null) { XmlSchema tempSchema = new XmlSchema(); tempSchema.TargetNamespace = XmlReservedNs.NsXml; tempSchema.Namespaces.Add("xml", XmlReservedNs.NsXml); XmlSchemaAttribute lang = new XmlSchemaAttribute(); lang.Name = "lang"; lang.SchemaTypeName = new XmlQualifiedName("language", XmlReservedNs.NsXs); tempSchema.Items.Add(lang); XmlSchemaAttribute xmlbase = new XmlSchemaAttribute(); xmlbase.Name = "base"; xmlbase.SchemaTypeName = new XmlQualifiedName("anyURI", XmlReservedNs.NsXs); tempSchema.Items.Add(xmlbase); XmlSchemaAttribute space = new XmlSchemaAttribute(); space.Name = "space"; XmlSchemaSimpleType type = new XmlSchemaSimpleType(); XmlSchemaSimpleTypeRestriction r = new XmlSchemaSimpleTypeRestriction(); r.BaseTypeName = new XmlQualifiedName("NCName", XmlReservedNs.NsXs); XmlSchemaEnumerationFacet space_default = new XmlSchemaEnumerationFacet(); space_default.Value = "default"; r.Facets.Add(space_default); XmlSchemaEnumerationFacet space_preserve = new XmlSchemaEnumerationFacet(); space_preserve.Value = "preserve"; r.Facets.Add(space_preserve); type.Content = r; space.SchemaType = type; space.DefaultValue = "preserve"; tempSchema.Items.Add(space); XmlSchemaAttributeGroup attributeGroup = new XmlSchemaAttributeGroup(); attributeGroup.Name = "specialAttrs"; XmlSchemaAttribute langRef = new XmlSchemaAttribute(); langRef.RefName = new XmlQualifiedName("lang", XmlReservedNs.NsXml); attributeGroup.Attributes.Add(langRef); XmlSchemaAttribute spaceRef = new XmlSchemaAttribute(); spaceRef.RefName = new XmlQualifiedName("space", XmlReservedNs.NsXml); attributeGroup.Attributes.Add(spaceRef); XmlSchemaAttribute baseRef = new XmlSchemaAttribute(); baseRef.RefName = new XmlQualifiedName("base", XmlReservedNs.NsXml); attributeGroup.Attributes.Add(baseRef); tempSchema.Items.Add(attributeGroup); tempSchema.IsPreprocessed = true; tempSchema.CompileSchemaInSet(new NameTable(), null, null); //compile built-in schema Interlocked.CompareExchange<XmlSchema>(ref builtInSchemaForXmlNS, tempSchema, null); } return builtInSchemaForXmlNS; }