<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>
答案 0 :(得分:1)
我会使用<sch:pattern>
<sch:rule context="Block[Types/Type/@TypeCode = preceding-sibling::Block[1]/Types/Type/@TypeCode]">
<sch:assert test="translate(BlockDates/@Start, '-', '') < translate(preceding-sibling::Block[1]/@End, '-', '')"></sch:assert>
</sch:rule>
</sch:pattern>
元素作为上下文:
currentBusiness.on('value', (snapshot) => {
currentBusinessData = snapshot.val()
this.setState({isLoading: false})
});