這是我的第一個問題,這是已經回答了:XML Schema - Is it possible to allow a certain element only once in the whole document?如何用xml模式重新定義xhtml body元素?
現在我要重新定義XHTML的body
元素,並添加唯一約束它。這是我redefine.xsd
內xhtml-struct-1.xsd
<xs:group
name="xhtml.html.content">
<xs:sequence>
<xs:element
name="head"
type="xhtml.head.type"/>
<xs:element
name="body"
type="xhtml.body.type"/>
</xs:sequence>
</xs:group>
定義我嘗試這樣做:
<xs:redefine schemaLocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd">
<xs:group name="xhtml.html.content">
<xs:sequence>
<xs:element name="head" type="xhtml.head.type" />
<xs:element name="body" type="xhtml.body.type" >
<xs:unique name="highlander">
<xs:selector xpath=".//mylang:content"/>
<xs:field xpath="."/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:group>
</xs:redefine>
org.xml.sax.SAXParseException; systemId: file:xhtml-struct-1.xsd; lineNumber:113; columnNumber:35; mg-props-correct.2:針對組''xhtml.html.content_fn3dktizrknc9pi'檢測到循環 。 遞歸跟隨粒子的{term}值會生成一個 粒子,其{term}是該組本身。
我treid其他幾十個變種,但我總是得到奇怪的錯誤,我不明白。我如何用XML Schema重新定義xhtml body元素?
對不起,但你的回答沒有幫助我。重新定義xhtml.body.type不起作用,因爲xs:unique只允許作爲xs:element的子元素,所以我無法將唯一定義添加到xhtml.body.type。當我再次引用組時,我只是'添加'其他元素,但我想替換此組中的元素定義 – Janning
您是對的,錯過了詳細信息。抱歉。由於我目前在重新定義XHTML XSD方面遇到類似的麻煩,我也對這個問題感興趣。我認爲這與XSD有關,它支持重新定義超集或子集,但不包含與以前相同的元素。你有沒有試過做兩步重定義 - 重新定義第一個包含XSD頭元素的子集,在第二個XSD中重新定義爲超集重新集成所有修改的主體元素? – soletan