我處理,看起來像一個XML架構:XML:爲避免XS /默認值:擴展
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="XML" type="XMLType"/>
<xs:complexType name="client_summaryType">
<xs:complexContent mixed="true">
<xs:extension base="xs:any"><xs:sequence><xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded" /></xs:sequence>
<xs:attribute type="xs:string" name="cid"/>
<!-- other attributes -->
<xs:anyAttribute processContents="skip" /></xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="XMLType">
<xs:choice maxOccurs="unbounded">
<xs:element minOccurs="0" maxOccurs="unbounded" type="client_summaryType" name="client_summary"/>
</xs:choice>
</xs:complexType>
</xs:schema>
我不斷收到的錯誤是:
attribute 'base': The QName value '{http://www.w3.org/2001/XMLSchema}any' does not resolve to a(n) simple type definition.
現在,我的問題是,我該如何避免xs:extension
陷阱?我不能使用base="xs:string"
,因爲我想包含client_summaryType
中的元素。顯然,我也不能使用xs:element
或xs:any
。我可以使用什麼,仍然使用complexContent
,沒有它從任何地方繼承的東西,只是讓我定義我想要的和驗證對此?所以,我不想處理xs:extension
問題,但我確實想要使用xs:complexContent
(因此對內容進行驗證)。這可以做到嗎?
謝謝。
嘿邁克爾,我試過了,但我得到'[$元素]不能有內容與它的類型爲空'或沿着這些線的東西的錯誤。 – 2011-01-11 03:03:51