zoukankan      html  css  js  c++  java
  • XmlSchema:采用编码实现

    /*--===------------------------------------------===---
    XmlSchema:采用编码实现
                许明会    2007年12月13日 21:37:23
    --===------------------------------------------===---
    */
    using System;
    using System.Xml;
    using System.Xml.Schema;

    namespace xumh
    {
        
    public class runMyApp
        {
            
    static void Main()
            {
                
    //准备XmlSchema
                XmlSchema schema = new XmlSchema();
                
    //准备复杂类型元素Book
                XmlSchemaElement eleBook = new XmlSchemaElement();
                eleBook.Name 
    = "Book";
                XmlSchemaComplexType type 
    = new XmlSchemaComplexType();
                XmlSchemaSequence seq 
    = new XmlSchemaSequence();
                type.Particle 
    =  seq;
                eleBook.SchemaType 
    = type;
                schema.Items.Add(eleBook);

                
    //添加元素Title
                XmlSchemaElement eleTitle = new XmlSchemaElement();
                eleTitle.Name 
    = "Title";
                eleTitle.SchemaTypeName 
    = new XmlQualifiedName("string",
                    
    "http://www.w3.org/2001/XMLSchema");

                
    //添加元素Publisher
                XmlSchemaElement elePub = new XmlSchemaElement();
                elePub.Name 
    = "Publisher";
                elePub.SchemaTypeName 
    = new XmlQualifiedName("string",
                    
    "http://www.w3.org/2001/XMLSchema");
                
                seq.Items.Add(eleTitle);
                seq.Items.Add(elePub);

                
    //验证可靠性
                schema.Compile(new ValidationEventHandler(ValidationHander));
                System.IO.StreamWriter sw
    = new System.IO.StreamWriter(@".\out.xsd");
                schema.Write(sw.BaseStream);
            }
            
    static void ValidationHander(object sender, ValidationEventArgs e)
            {
                Console.WriteLine(
    "架构验证失败!");
                Console.WriteLine(e.Message);

            }
        };
    }
  • 相关阅读:
    poj2942 点-双联通+二分图染色
    poj1523割顶-点双联通
    poj3694 边-双连通分量+lca
    poj3177边-双连通分量
    poj3352 边-双联通分量
    Codeforces Round #377 (Div. 2) F
    Educational Codeforces Round 30D. Merge Sort
    洛谷p3369 treap
    hdu3572线性欧拉筛
    HYSBZ
  • 原文地址:https://www.cnblogs.com/flaaash/p/994170.html
Copyright © 2011-2022 走看看