-- 作者:f1029303
-- 发布时间:9/14/2007 11:37:00 AM
--
chapter 1: <schema targetNamespace="http://www.example.com/IPO" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ipo="http://www.example.com/IPO"> 是這樣理解的 targetNamespace="http://www.example.com/IPO" xmlns:ipo="http://www.example.com/IPO" 這個是 目标名字空间(target namespace) 一個xmlschema文檔只能有一個 目标名字空间 xmlns 是必須的帶上的﹐ ipo是命名前綴﹐作用是下面XML文檔中﹐ 如果是目标名字空间的類型﹐前綴就可以改為 ipo:xxxx chapter 2: xmlns="http://www.w3.org/2001/XMLSchema" 這個是 标准名字空间(standard namespace) 它是定义Schema语法的标准﹐由w3c來定義的﹐ 這個不多說。 chapter 3: 還有如下的 <schema targetNamespace='http://www.SampleStore.com/Account' xmlns='http://www.w3.org/1999/xmlSchema' xmlns:ACC= 'http://www.SampleStore.com/Account' xmlns:PART= 'http://www.PartnerStore.com/PartsCatalog'> <import namespace='http://www.PartnerStore.com/PartsCatalog' schemaLocation='http://www.ProductStandards.org/repository/alpha.xsd'/> xmlns:PART= 'http://www.PartnerStore.com/PartsCatalog' <import namespace='http://www.PartnerStore.com/PartsCatalog' schemaLocation='http://www.ProductStandards.org/repository/alpha.xsd'/> 這個是 源名字空间(source namespaces) 一個xmlschema文檔可以有多個 源名字空间(目前我只能引用一個,引用兩個以上的﹐沒有辦法加前綴﹐一直都沒有找到資料) chapter4: 以下是代碼你可以看看有沒有幫助 <?xml version="1.0" encoding="gb2312"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jeff="http://www.jeff.com/xmlschema" xmlns:jeffreg="http://example.org/prod" targetNamespace="http://www.jeff.com/xmlschema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:import namespace="http://example.org/prod" schemaLocation="E:\Training Doc\XML\example\example9.xsd"/> <xs:element name="bookshop"> <xs:annotation> <xs:documentation>this is example</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="books" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="book"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="ISBN"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="\d{1}-\d{3}-\d{5}-\d{1}"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="price" type="xs:double"/> <xs:element name="public" type="xs:string"/> <xs:choice> <xs:element name="author" type="xs:string"/> <xs:element name="phone" type="jeff:stringSpec"/> </xs:choice> </xs:sequence> <xs:attribute name="memo" type="xs:string"/> </xs:complexType> </xs:element> <xs:element name="otherInfor"> <xs:complexType> <xs:sequence> <xs:element name="buyDate" type="jeff:dateFormat"/> <xs:element name="isDestroy" type="xs:boolean"/> <xs:element name="number" type="jeffreg:SizeType"/> </xs:sequence> <xs:attribute name="recordPeople"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="jeff"/> <xs:enumeration value="jeffreg"/> <xs:enumeration value="admin"/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name="recordDate" type="jeff:dateFormat"/> <!--attribute recordpeople--> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="index" type="jeff:stringIndex"/> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="shopname" type="xs:string"/> </xs:complexType> </xs:element> <!--attribute bookAttribute <xs:attributeGroup name="bookAttribute"> <xs:attribute name="memo" type="xs:string"/> </xs:attributeGroup> --> <!--simple type stringSpec--> <xs:simpleType name="stringSpec"> <xs:restriction base="xs:string"> <xs:pattern value="\d{4}-\d{8}"/> </xs:restriction> </xs:simpleType> <!--simple type dateFormat--> <xs:simpleType name="dateFormat"> <xs:restriction base="xs:date"> <xs:pattern value="\d{4}-\d{2}-\d{2}"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="stringIndex"> <xs:restriction base="xs:string"> <xs:pattern value="\d{4}"/> </xs:restriction> </xs:simpleType> </xs:schema>
|