當使用XML Schema來聲明一個complexType
只有一個子元素,所有下面三種方式實現這一目標:如何聲明一個complexType只有一個子元素?
<xs:complexType> <xs:sequence> <xs:element ref="somevalue"/> </xs:sequence> </xs:comlexType>
<xs:complexType> <xs:choice> <xs:element ref="somevalue"/> </xs:choice> </xs:comlexType>
<xs:complexType> <xs:all> <xs:element ref="somevalue"/> </xs:all> </xs:comlexType>
顯然,sequence
,choice
和all
沒有必要爲一個單一的元素,因爲它們應該用來指示多個元素的順序。 是否有更簡明的方法來聲明只有一個子元素的complexType
?(即一個,消除了使用sequence
,all
或choice
,不知何故)
[架構規範的早期工作草案](http://www.w3.org/TR/2000/WD-xmlschema-1-20000407/#declare-type)假設嵌套'元素「聲明直接在'complexType'內部,但是在規範達到其最終形式之前將其刪除,以便總是需要顯式的'sequence','choice'或'all'。 –
好吧,我會選擇順序:) – MengT