[英]XML XSD - Allowing arbitrary grand children elements
我想創建一個XSD架構,其中只有根元素及其直接子元素由XSD監管。 換句話說,我想允許根元素的任意孫子,而根元素和子元素由XSD嚴格驗證。 所以,如果我有
<text>
<language>
...
</language>
</text>
它應該強制存在文本和語言,但不限制我添加的級別以下的XML標記。
這有可能嗎? 我已經使用過XSD但在很大程度上沒有找到參考,也沒有說明我可以做到,也沒有禁止這樣做。
在孫子級別使用xsd:any :
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<xs:element name="text">
<xs:complexType>
<xs:sequence>
<xs:element name="language">
<xs:complexType>
<xs:sequence>
<xs:any/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
其他考慮:
minOccurs
和maxOccurs
)。 mixed="true"
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.