當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlSchemaKeyref類代碼示例

本文整理匯總了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;未經允許,請勿轉載。