【发布时间】:2019-07-18 17:44:54
【问题描述】:
我需要帮助来查找此 XML 代码中的重叠日期。我需要确保结束日期不小于或等于进行中的开始日期。
<Inventory>
<StatusApplicationControl Start="2019-07-18" End="2019-07-18" InvTypeCode="STDX" />
<InvCounts>
<InvCount CountType="2" Count="9" />
</InvCounts>
</Inventory>
<Inventory>
<StatusApplicationControl Start="2019-07-18" End="2019-07-19" InvTypeCode="STDX" />
<InvCounts>
<InvCount CountType="2" Count="8" />
</InvCounts>
</Inventory>
我已经尝试了以下代码。
<rule context="Inventory">
<report test="translate(StatusApplicationControl/@Start, '-', '') <= translate(preceding::Inventory/preceding::StatusApplicationControl/@End, '-', '')">The @Start="<value-of select="@Start"/>" and @End="<value-of select="@End"/>" dates are overlaping</report>
</rule>
我希望打印此消息 - Start="2019-07-18" 小于或等于 End="2019-07-18" 日期
非常感谢任何帮助!
【问题讨论】:
-
不清楚你的实际输出是什么。除此之外,您的消息似乎使用了同一上下文中的
Start和End属性。 -
感谢 Alejandro,我更改了上面的代码,现在它可以工作了,但是我无法获取开始日期和结束日期的值。如果我弄清楚了,我会发布答案。
-
如果您在比较
StatusApplicationControl/@Start和preceding::Inventory/preceding::StatusApplicationControl/@End,为什么您的消息使用@Start和@End? -
因为这些值只能来自上下文。因此,要获取这些值,上下文必须是
context="Inventory/StatusApplicationControl" -
但是你想要“其他”
@End属性...
标签: xpath schematron