【发布时间】:2016-10-11 20:01:58
【问题描述】:
<ROOTNODE>
<Blocks>
<Block>
<Ref/>
<BlockDates Start="2015-10-20" End="2015-10-20" />
<Types>
<Type TypeCode="SGL" />
</Types>
</Block>
<Block>
<Ref/>
<BlockDates Start="2015-10-19" End="2015-10-18"/>
<Types>
<Type TypeCode="SGL" />
</Types>
</Block>
</Blocks>
</ROOTNODE>
如果@Start 日期小于前面的@End 日期,我需要报告错误。但前提是@TypeCode 与前面的@TypeCode 相同。以上应该会产生错误。以下是我尝试过的。任何帮助表示赞赏!
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
<sch:pattern>
<sch:rule context="BlockDates|Type">
<sch:report test="translate(@Start, '-', '') <= translate(preceding::*/@End, '-', '') and @TypeCode = preceding::*/@TypeCode"> Error start date is before end date and type codes match. </sch:report>
</sch:rule> </sch:pattern>
</sch:schema>
【问题讨论】:
-
马丁,这很完美。 -谢谢!
标签: xslt xpath schematron