栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何从类创建XSD架构?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何从类创建XSD架构?

您可以使用

XSD.exe
(可从Visual Studio安装中获得。)

public sealed class Configuration{ public string Name { get; set; } public Levels Level { get; set; } public ConfigurationSpec Spec { get; set; }} public abstract class ConfigurationSpec { } public class ConfigurationSpec1    {   }public class ConfigurationSpec2 {   }

结果是

<?xml version="1.0" encoding="utf-8"?><xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">  <xs:element name="Levels" type="Levels" />  <xs:simpleType name="Levels">    <xs:restriction base="xs:string">      <xs:enumeration value="Easy" />      <xs:enumeration value="Medium" />      <xs:enumeration value="Hard" />    </xs:restriction>  </xs:simpleType>  <xs:element name="Configuration" nillable="true" type="Configuration" />  <xs:complexType name="Configuration">    <xs:sequence>      <xs:element minOccurs="0" maxOccurs="1" name="Name" type="xs:string" />      <xs:element minOccurs="1" maxOccurs="1" name="Level" type="Levels" />      <xs:element minOccurs="0" maxOccurs="1" name="Spec" type="ConfigurationSpec" />    </xs:sequence>  </xs:complexType>  <xs:complexType name="ConfigurationSpec" abstract="true" />  <xs:element name="ConfigurationSpec" nillable="true" type="ConfigurationSpec" />  <xs:element name="ConfigurationSpec1" nillable="true" type="ConfigurationSpec1" />  <xs:complexType name="ConfigurationSpec1" />  <xs:element name="ConfigurationSpec2" nillable="true" type="ConfigurationSpec2" />  <xs:complexType name="ConfigurationSpec2" /></xs:schema>

您要做的就是编译程序集,并

XSD.exe
以程序集的路径作为参数运行。
XSD.exe /?
也具有所有参数的列表。

例:

XSD.exe C:DevProject1BinDebuglibrary.dll



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/465437.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号