框架
<?xml version="1.0" encoding="utf-8"?> <schema id="Stocks" targetNamespace="http://tempuri.org/Stocks" elementFormDefault="qualified" xmlns:this="http://tempuri.org/Stocks" xmlns="http://www.w3.org/2001/XMLSchema" > <!--=====================================定义k线 Type=========================================--> <!--定义简易元素--> <element name="OpenPrice" type="this:PriceRang" /> <element name="ClosePrice" type="this:PriceRang"/> <element name="HightPrice" type="this:PriceRang"/> <element name ="LowPrice" type="this:PriceRang"/> <element name="KLine" type="this:OCHLElement" /> <!--定义一个类型 表示股价的范围--> <simpleType name="PriceRang"> <restriction base="decimal"> <minInclusive value ="0"></minInclusive> <maxExclusive value="100000000000"></maxExclusive> </restriction> </simpleType> <!--定义K线复合元素--> <complexType name="OCHLElement" mixed="true" > <sequence > <element ref="this:OpenPrice" maxOccurs="1"/> <element ref="this:ClosePrice" maxOccurs="1"/> <element ref="this:HightPrice" maxOccurs="1"/> <element ref="this:LowPrice" maxOccurs="1"/> </sequence> </complexType> <!--==============================================================================--> <!--根元素--> <element name ="Stock" type="this:stock" /> <!--定义公司名称 范围--> <complexType name="stock" > <sequence > <element ref="this:Company" maxOccurs="1"/> <element ref="this:KLine" maxOccurs="unbounded"/> </sequence> </complexType> <!--根元素--> <element name ="Company" type="this:CompanyNameRang" /> <!--定义公司名称 范围--> <simpleType name="CompanyNameRang"> <restriction base="string"> <pattern value="[a-zA-Z][a-zA-Z][a-zA-Z]+"/> </restriction> </simpleType> </schema>
框架解释
建立一个k线 框架。
用已经定义的Stock框架 ,建立实例文档
<?xml version="1.0" encoding="utf-8" ?> <Stock xmlns="http://tempuri.org/Stocks"> <Company>tengXun</Company> <KLine> <OpenPrice>15</OpenPrice> <ClosePrice>15.54</ClosePrice> <HightPrice>15.90</HightPrice> <LowPrice>14.90</LowPrice> </KLine> <KLine> <OpenPrice>16</OpenPrice> <ClosePrice>17.54</ClosePrice> <HightPrice>17.54</HightPrice> <LowPrice>15.90</LowPrice> </KLine> </Stock>