我正在尝试将schematron验证添加到我的xsd中.
这是我的新xsd:
这是我的新xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> xmlns:sch="http://www.ascc.net/xml/schematron" elementFormDefault="qualified" > <xs:element name="books"> <xs:complextype> <xs:sequence> ;P <xs:element name="book" type="bookType" maxoccurs="unbounded"> <xs:annotation> <xs:appinfo> <sch:pattern id="onLoanTests" xmlns:sch="http://purl.oclc.org/dsdl/schematron"> <sch:rule context="book"> <sch:report test="@on-loan and not(@return-date)"> Every book that is on loan must have a return date </sch:report> </sch:rule> </sch:pattern> </xs:appinfo> </xs:annotation> </xs:element> </xs:sequence> </xs:complextype> </xs:element> <xs:complextype name="bookType"> <xs:sequence> <xs:element name="title" type="xs:string" /> <xs:element name="author" type="xs:string" /> <xs:element name="publication-date" type="xs:string" /> </xs:sequence> <xs:attribute name="publisher" type="xs:string" use="required" /> <xs:attribute name="on-loan" type="xs:string" use="required" /> <xs:attribute name="return-date" type="xs:string" use="optional" /> </xs:complextype> </xs:schema>
这是我的测试xml:
<books> <book publisher="ddd" on-loan="sdsd"> <title>idan title</title> <author>idan author</author> <publication-date>idan date</publication-date> </book> </books>
使用我提供的xml我没有得到验证错误.
我假设我会收到消息“每本借出的书必须有一个返回日期”并且xml将无效.建议为什么?
更新
我确实通过在oXygen xml编辑器中使用schematron验证来使其工作.
但是,我想如何在我的代码中使用?
我需要安装一些特别的东西吗?链接到另一个图书馆?
UPDATE2
在“处理”部分显然是here,所有需要的步骤都是详细的.
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。