2
我很難驗證與Schematron結合使用的SXD Schema。使用Schematron和xsltproc驗證XSD Schema
繼我XSD文檔中併入<xs:appinfo>
標籤之間的Schematron如下本guide描述的步驟:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Test">
<xs:annotation>
<xs:appinfo>
<sch:pattern name="Testing schematron" xmlns:sch="http://purl.oclc.org/dsdl/schematron">
<sch:rule context="Test">
<sch:assert test="@Attribute1">Attribute 1 exists</sch:assert>
</sch:rule>
</sch:pattern>
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:attribute name="Attribute1" type="xs:string" use="optional"/>
<xs:attribute name="Attribute2" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
</xs:schema>
本文檔應該測試(或驗證)該文件
<?xml version="1.0" encoding="ISO-8859-1"?>
<Test Attribute1="attr1"/>
使用schetrontron page上列出的簡單的基於xsltproc的腳本。不幸的是,我在腳本的最後一步收到以下錯誤消息。
step3.xsl:13: parser error : Extra content at the end of the document
plates select="*|comment()|processing-instruction()" mode="M0"/></axsl:template>
^
cannot parse step3.xsl
我很感激幫助找出這個錯誤的原因。
謝謝。有用。但是鑑於XSD2已經標準化了,你還會主張使用Schematron嗎? – Olumide
你的意思是XML Schema 1.1;)? Schematron比XML SChema 1.1斷言更靈活,這些斷言對您可以使用的XPath表達式施加限制,而Schematron保留其獨特功能以允許您定義錯誤消息。然後,我的建議是在滿足您的需求時使用XSD 1.1,但請記住,如果您需要更多,仍然可以使用Schematron。 –