<ROOTNODE>
<Blocks>
<Block>
<Ref/>
<BlockDates Start="2015-10-20" End="2015-10-25" />
<Types>
<Type TypeCode="SGL">
<TypeAllocations>
<TypeAllocation Start="2015-10-26" End="2015-10-27" />
<TypeAllocation Start="2015-10-26" End="2015-10-25" />
</TypeAllocations>
</Type>
<Type TypeCode="SGL">
<TypeAllocations>
<TypeAllocation Start="2015-10-28" End="2015-10-29" />
<TypeAllocation Start="2015-10-26" End="2015-10-27" />
</TypeAllocations>
</Type>
</Types>
</Block>
<Block>
<Ref/>
<BlockDates Start="2015-10-26" End="2015-10-30"/>
<Types>
<Type TypeCode="SG">
<TypeAllocations>
<TypeAllocation Start="2015-10-31" End="2015-11-01" />
<TypeAllocation Start="2015-10-25" End="2015-10-24" />
</TypeAllocations>
</Type>
<Type TypeCode="SG">
<TypeAllocations>
<TypeAllocation Start="2015-10-21" End="2015-10-25" />
<TypeAllocation Start="2015-10-23" End="2015-11-27" />
</TypeAllocations>
</Type>
</Types>
</Block>
</Blocks>
</ROOTNODE>我试图找到一种方法来判断日期是否在日期之外。可以有任意数量的元素和元素。上述情况在所有情况下都应失败。下面是我试过的。然而,我觉得它的出路,因为它只找到了第一个。任何帮助都是非常感谢的!
<sch:pattern name="Testing Start and End dates">
<sch:rule context="blk:InvBlock">
<sch:report test="translate(blk:InvBlockDates/@Start, '-', '') <= translate(blk:RoomTypes/blk:RoomType/blk:RoomTypeAllocations/blk:RoomTypeAllocation/@Start, '-', '') or translate(blk:InvBlockDates/@End, '-', '') <= translate(blk:RoomTypes/blk:RoomType/blk:RoomTypeAllocations/blk:RoomTypeAllocation/@End, '-', '')"> Allocation @Start and @End dates can not be outside the Block @Start and @End dates. </sch:report>
</sch:rule>
</sch:pattern> 发布于 2016-10-14 16:47:54
我不确定您是否想报告验证错误,如果至少有一个TypeAllocation与错误的Start或End,或者您想要检查所有这些。如果您只想检查其中至少一个错误,则可以使用
<sch:pattern>
<sch:rule context="Block">
<sch:report test="Types/Type/TypeAllocations/TypeAllocation[
translate(@Start, '-', '') > translate(current()/BlockDates/@Start, '-', '')
or
translate(@End, '-', '') > translate(current()/BlockDates/@End, '-', '')]"> Allocation @Start and @End dates can not be outside the Block @Start and @End dates. </sch:report>
</sch:rule>
</sch:pattern> 我认为。如果Schematron的版本不支持使用current()函数,那么在示例的上下文中,我建议您可以使用ancestor::Block而不是current():
<sch:pattern>
<sch:rule context="Block">
<sch:report test="Types/Type/TypeAllocations/TypeAllocation[
translate(@Start, '-', '') > translate(ancestor::Block/BlockDates/@Start, '-', '')
or
translate(@End, '-', '') > translate(ancestor::Block/BlockDates/@End, '-', '')]"> Allocation @Start and @End dates can not be outside the Block @Start and @End dates. </sch:report>
</sch:rule>
</sch:pattern> 发布于 2016-10-17 16:27:59
我能够使用以下方法完成这项工作。非常感谢你的帮助马丁!
<sch:rule context="Block">
<sch:report test="Types/Type/TypeAllocations/TypeAllocation[
translate(@Start, '-', '') < translate(ancestor::Block/BlockDates/@Start, '-', '') ]
or
Types/Type/TypeAllocations/TypeAllocation[translate(@End, '-', '') > translate(ancestor::Block/BlockDates/@End, '-', '')] ">
Allocation @Start and @End dates can not be outside the Block @Start and @End dates.
</sch:report>
</sch:rule>https://stackoverflow.com/questions/40047766
复制相似问题