xml – 使用schematron进行xsd验证
发布时间:2020-12-16 23:17:02 所属栏目:百科 来源:网络整理
导读:我正在尝试将schematron验证添加到我的xsd中. 这是我的新xsd: xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sch="http://www.ascc.net/xml/schematron" elementFormDefault="qualified" gt; xs:element name="books" xs:complextype xs:se
我正在尝试将schematron验证添加到我的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将无效.建议为什么? 更新 UPDATE2 解决方法
您的第二次更新可能是该主题的最佳参考. XSD本身不允许您使用一种机制来验证schematron以及架构本身. xsd:appinfo元素允许您嵌入不同模式语言的验证信息,但它专门用于应用程序(因此名称).
这意味着你需要做一些事情来启用它.您引用的论文提供了最佳方法,归结为: >使用XSLT提取schematron 根据您的环境,您可能需要考虑查看XProc实现(calabash或calumet)以实现该管道. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Swift - 使用CoreLocation获取设备方向(真实方向,磁极方向
- c# – SMTP和OAuth 2
- c# – 将标记向下转换为HTML的正则表达式
- actionscript-3 – addChild():我怎么知道DisplayObject实
- ruby-on-rails-3 – Carrierwave:如何裁剪和调整大小以使最
- cuda:Missing recommended library: libGLU.so,libX11.so,l
- 去哪儿PostgreSQL开发指南
- Swift学习(一):自定义运算符 operator
- 如何将DBUtil中使用BeanListHandler中转返回的List存入一个
- QT 操作Sqlite数据库