semi-sleep

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  17 Posts :: 0 Stories :: 1 Comments :: 0 Trackbacks
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 New By List  By Union   By Restriction  By Extension
SimpleType N Y Y Y N
ComplexType with SimpleContent N N N Y Y (can extend from SimpleType)
ComplexType with ComplexContent
(Element Only)
Y (don't need to use <complexContext>,
use <sequence>, <any> or <all>)
N N Y Y
ComplexType with ComplexContent
(Mixed)
Y (don't need to use <complexContext>,
use <sequence>, <any> or <all>)
N N Y Y


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

posted on 2008-12-30 16:05 semi-sleep 阅读(189) 评论(0)  编辑  收藏 所属分类: xml

只有注册用户登录后才能发表评论。


网站导航: