我正在嘗試爲xsd中的元素應用模式。在xsd中寫入模式<a attributes><img/></a>
元素是XHTML類型。
我想要應用這樣的模式。
<a attributes="some set of attributes"><img attributes="some set of attribtes"/></a>
規則:
<a> tag with attributes followed by <img> with attributes.
樣品有效數據:
<a xlink:href="some link" title="Image" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
<img alt="No Image" title="No Image" xlink:href="soem path for image" xlink:title="Image" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" />
</a>
無效:
<a>data<img/></a>--Data Present, no attributes
<a><img>abcd</img></a>--data Present, No attributes
<a><img/></a>---No attributes
任何一個可以建議如何寫模式這一點。
<xsd:restriction base="xs:string">
<xs:pattern value="Need help"/>
</xsd:restriction>
謝謝。
爲什麼不從有效的XML生成xsd然後用它來驗證其他xml? – Urik