发布0115
大石头 编写于 2020-01-15 01:11:37
X
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Model2020"
    targetNamespace="http://www.newlifex.com/Model2020.xsd"
    elementFormDefault="qualified"
    xmlns="http://www.newlifex.com/Model2020.xsd"
    xmlns:mstns="http://www.newlifex.com/Model2020.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:annotation>
    <xs:documentation xml:lang="zh-cn">
      新生命Xml模型文件架构说明
    </xs:documentation>
  </xs:annotation>

  <xs:element name="Tables" type="TablesType"></xs:element>

  <xs:complexType name="TablesType">
    <xs:sequence>
      <xs:element name="Table" type="TableType" maxOccurs="unbounded" ></xs:element>
    </xs:sequence>
    <xs:attribute name="Version" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          使用该模型文件的XCode版本
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="NameSpace" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          所生成实体类的命名空间
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="ConnName" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          实体类的数据库连接名
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Output" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          输出目录,绝对或相对地址,相对的是模型文件所在目录
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="BaseClass" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          实体类的基类
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="ChineseFileName" type="BooleanType">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          是否使用中文作为实体类文件名
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="IgnoreNameCase" type="BooleanType">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          是否忽略表名/字段名大小写,默认false,表示类名和表名采用不区分大小写来判断是否相等
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <!--Table-start-->
  <xs:complexType name="TableType">
    <xs:annotation>
      <xs:documentation xml:lang="zh-cn">
        一个Table就是一个实体类,对应一张数据表
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="Columns" type="ColumnsType">
        <xs:annotation>
          <xs:documentation xml:lang="zh-cn">
            属性/字段列表
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Indexes" type="IndexesType" minOccurs="0">
        <xs:annotation>
          <xs:documentation xml:lang="zh-cn">
            索引列表,并根据列名生成拓展查询方法
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="Name" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          生成的实体类名,TableName对应数据库表名,TableName为空则用此属性作为表名
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="TableName" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          数据库表名,为空则默认为Name
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="BaseType" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          基类
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Owner" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          所有者
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="ConnName" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          连接名
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="DbType" type="DbTypeType">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          数据库类型
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="IsView" type="BooleanType">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          是否视图
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="DisplayName" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          显示名。如果有Description则使用Description,否则使用Name
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Description" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          表描述
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="InsertOnly" type="BooleanType">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          仅插入数据,比如日志型
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <!--以下是拓展属性-->
    <xs:attribute name="RenderGenEntity" type="BooleanType">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          是否生成泛型,生成泛型自动添加模型检查模式(控制实体类是在初始化连接时还是第一次使用该实体类的数据表时检查模型)
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="IgnoreNameCase" type="BooleanType">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          是否忽略表名/字段名大小写,默认false,表示类名和表名采用不区分大小写来判断是否相等
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

  </xs:complexType>
  <!--Table-end-->

  <xs:simpleType name="DbTypeType">
    <xs:annotation>
      <xs:documentation>
        数据库类型,生成数据库表的是时候会针对数据库类型做处理
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:enumeration value="Access" ></xs:enumeration>
      <xs:enumeration value="MySql" ></xs:enumeration>
      <xs:enumeration value="Oracle" ></xs:enumeration>
      <xs:enumeration value="PostgreSQL" ></xs:enumeration>
      <xs:enumeration value="SqlCe" ></xs:enumeration>
      <xs:enumeration value="SQLite" ></xs:enumeration>
      <xs:enumeration value="SqlServer" ></xs:enumeration>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="ColumnsType">
    <xs:sequence>
      <xs:element name="Column" type="ColumnType" maxOccurs="unbounded"></xs:element>
    </xs:sequence>
  </xs:complexType>

  <!--Column-start-->
  <xs:complexType name="ColumnType">
    <xs:attribute name="Name" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          名称,对应实体类属性名,ColumnName为空时使用此属性
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="ColumnName" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          列名
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="DataType" type="DataTypeType">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          数据类型,对应C#的类型
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="RawType" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          原始数据类型,当且仅当目标数据库同为该数据库类型时,采用实体属性信息上的RawType作为反向工程的目标字段类型,以期获得开发和生产的最佳兼容。
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Identity" type="BooleanType">
      <xs:annotation>
        <xs:documentation>
          自增标识
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="PrimaryKey" type="BooleanType">
      <xs:annotation>
        <xs:documentation>
          主键
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Master" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          主字段。主字段作为业务主要字段,代表当前数据行意义
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Length" type="xs:int">
      <xs:annotation>
        <xs:documentation>
          长度,字符串-1表示无限大
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Precision" type="xs:int">
      <xs:annotation>
        <xs:documentation>
          精度
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Scale" type="xs:int">
      <xs:annotation>
        <xs:documentation>
          位数
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Nullable" type="BooleanType">
      <xs:annotation>
        <xs:documentation>
          允许空
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="DisplayName" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          显示名。如果有Description则使用Description,否则使用Name
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Description" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          说明
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Type" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          生成自定义类型,比如枚举,值可以是类型名也可以是命名空间+类型名
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
  <!--Column-end-->

  <!--BooleanType-start-->
  <xs:simpleType name="BooleanType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="True" ></xs:enumeration>
      <xs:enumeration value="False" ></xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
  <!--BooleanType-end-->

  <!--DataType-start-->
  <xs:simpleType name="DataTypeType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Boolean" ></xs:enumeration>
      <xs:enumeration value="SByte" ></xs:enumeration>
      <xs:enumeration value="Byte" ></xs:enumeration>
      <xs:enumeration value="Int16" ></xs:enumeration>
      <xs:enumeration value="UInt16" ></xs:enumeration>
      <xs:enumeration value="UInt16" ></xs:enumeration>
      <xs:enumeration value="Int32" ></xs:enumeration>
      <xs:enumeration value="UInt32" ></xs:enumeration>
      <xs:enumeration value="Int64" ></xs:enumeration>
      <xs:enumeration value="UInt64" ></xs:enumeration>
      <xs:enumeration value="Single" ></xs:enumeration>
      <xs:enumeration value="Double" ></xs:enumeration>
      <xs:enumeration value="Decimal" ></xs:enumeration>
      <xs:enumeration value="DateTime" ></xs:enumeration>
      <xs:enumeration value="String" ></xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
  <!--DataType-end-->

  <xs:complexType name="IndexesType">
    <xs:sequence>
      <xs:element name="Index" type="IndexType" maxOccurs="unbounded"></xs:element>
    </xs:sequence>
  </xs:complexType>


  <!--Index-start-->
  <xs:complexType name="IndexType">
    <xs:annotation>
      <xs:documentation xml:lang="zh-cn">
        索引,同时生成对应的拓展查询方法
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="Name">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          索引名
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Columns" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          列名,英文逗号字符相隔,比如:ID,Name
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Unique" type="BooleanType">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          是否唯一
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="PrimaryKey" type="BooleanType">
      <xs:annotation>
        <xs:documentation xml:lang="zh-cn">
          是否主键
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
  <!--Index-end-->

</xs:schema>