Notes for XML Schema 20081230

1.The xml schema type system:
(contains attribute?)
  - SimpleType
  - ComplexType (contains element?)
    - SimpleContent
    - ComplexContent (can be mixed with character?)
      - Element Only
      - Mixed
For those "Y", unless otherwise explained, they should be derived from the same type.
 Create NewBy List By Union  By Restriction By Extension
SimpleTypeNYYYN
ComplexType with SimpleContentNNNYY (can extend from SimpleType)
ComplexType with ComplexContent
(Element Only)
Y (don't need to use <complexContext>,
use <sequence>, <any> or <all>)
NNYY
ComplexType with ComplexContent
(Mixed)
Y (don't need to use <complexContext>,
use <sequence>, <any> or <all>)
NNYY


2.About restriction, if A is restricted from B, then instance of A will always be valid for B. For simpleType, only facets are allow, so it should be true, for ComplexType, this means that you can use restriction to narrow down valid usage of some attributes and elements.

3.About extension, extension is more like template, if A is extended from B, this is equivalent to a datatype created by first copy B's definition and then append A's definition. So extension can be use to add new attribute or element to an existing type, and either instance of A or B may be invalid for the other. For complextContent, is a little special as that the element definition for A and B can be considered to be surrounded by a bigger <sequence>.

4.About polymiorphism, instance of datatype derived by restriction or extension can be used as instance of base datatype by using the "xsi:type" attribute. Note that it's ok for restriction, but it may cause problem in the case of extension, so the "block" attribute in <complexType> or <element> is provided to restrict the use of "xsi:type", the "block" attribute is different form the "final" attribute, the latter one is used to restrict inheritance. Also there's not a "block" attribute for <simpleType>, because its dose not support extension. For simple type derived by union, "xsi:type" can also be use to specify the member type to ease validation (may be also for data binding?).

5.Relationship between datatype, element and attribute. Element and attribute must refer to a datatype (it can be global or anonymous (by nested a <simpleType> or <complexType>)),  some datatype in turn, can contain element or attribute (complexType can contain attribute, complexContent can contain element, element and attribute can also be global (by using the "ref" attribute) or anonymous). For restriction, extension, list or union, if the base datatype is simpleType, it can also be anonymous.

Refer to "MSDN - XML Schema Element" at http://msdn.microsoft.com/en-us/library/ms256142.aspx.
Also Refer to "XML Schema Design Patterns: Is Complex Type Derivation Unnecessary?" at http://www.oreillynet.com/xml/blog/2007/07/derivation_by_implied_restrict.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值