本文整理汇总了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
开发者ID:.NET开发者,项目名称:System.Xml.Schema,代码行数:102,代码来源:XmlSchemaKeyref
注:本文中的System.Xml.Schema.XmlSchemaKeyref类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论