本文整理匯總了C#中System.Xml.Schema.XmlSchemaKeyref類的典型用法代碼示例。如果您正苦於以下問題:C# XmlSchemaKeyref類的具體用法?C# XmlSchemaKeyref怎麽用?C# XmlSchemaKeyref使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
XmlSchemaKeyref類屬於System.Xml.Schema命名空間,在下文中一共展示了XmlSchemaKeyref類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ValidationCallback
//引入命名空間
using System;
using System.Collections;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.Schema;
public class XmlSchemaObjectGenerator {
private static void ValidationCallback(object sender, ValidationEventArgs args ){
if(args.Severity == XmlSeverityType.Warning)
Console.Write("WARNING: ");
else if(args.Severity == XmlSeverityType.Error)
Console.Write("ERROR: ");
Console.WriteLine(args.Message);
}
public static void Main() {
XmlTextReader tr = new XmlTextReader("empty.xsd");
XmlSchema schema = XmlSchema.Read(tr, new ValidationEventHandler(ValidationCallback));
schema.ElementFormDefault = XmlSchemaForm.Qualified;
schema.TargetNamespace = "http://www.example.com/Report";
{
XmlSchemaElement element = new XmlSchemaElement();
element.Name = "purchaseReport";
XmlSchemaComplexType element_complexType = new XmlSchemaComplexType();
XmlSchemaSequence element_complexType_sequence = new XmlSchemaSequence();
{
XmlSchemaElement element_complexType_sequence_element = new XmlSchemaElement();
element_complexType_sequence_element.Name = "region";
element_complexType_sequence_element.SchemaTypeName =
new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema")
;
{
XmlSchemaKeyref element_complexType_sequence_element_keyref = new XmlSchemaKeyref();
element_complexType_sequence_element_keyref.Name = "dummy2";
element_complexType_sequence_element_keyref.Selector = new XmlSchemaXPath();
element_complexType_sequence_element_keyref.Selector.XPath = "r:zip/r:part";
{
XmlSchemaXPath field = new XmlSchemaXPath();
field.XPath = "@number";
element_complexType_sequence_element_keyref.Fields.Add(field);
}
element_complexType_sequence_element_keyref.Refer =
new XmlQualifiedName("pNumKey", "http://www.example.com/Report")
;
element_complexType_sequence_element.Constraints.Add(element_complexType_sequence_element_keyref);
}
element_complexType_sequence.Items.Add(element_complexType_sequence_element);
}
element_complexType.Particle = element_complexType_sequence;
{
XmlSchemaAttribute element_complexType_attribute = new XmlSchemaAttribute();
element_complexType_attribute.Name = "periodEnding";
element_complexType_attribute.SchemaTypeName =
new XmlQualifiedName("date", "http://www.w3.org/2001/XMLSchema")
;
element_complexType.Attributes.Add(element_complexType_attribute);
}
element.SchemaType = element_complexType;
{
XmlSchemaKey element_key = new XmlSchemaKey();
element_key.Name = "pNumKey";
element_key.Selector = new XmlSchemaXPath();
element_key.Selector.XPath = "r:parts/r:part";
{
XmlSchemaXPath field = new XmlSchemaXPath();
field.XPath = "@number";
element_key.Fields.Add(field);
}
element.Constraints.Add(element_key);
}
schema.Items.Add(element);
}
schema.Write(Console.Out);
}/* Main() */
}
//XmlSchemaObjectGenerator