本文整理汇总了C#中System.Xml.Schema.XmlSchema.CompileSchemaInSet方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchema.CompileSchemaInSet方法的具体用法?C# XmlSchema.CompileSchemaInSet怎么用?C# XmlSchema.CompileSchemaInSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Schema.XmlSchema
的用法示例。
在下文中一共展示了XmlSchema.CompileSchemaInSet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBuildInSchema
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;
}
示例2: GetBuildInSchema
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;
}