问题描述
每当修订日期大于发布日期时,我都必须在输出xml中显示一条错误消息。我必须将每个修订日期与相应的出版日期进行比较。输入xml中可以有多个“修订日期”,但是一本书只有一个发布日期。
在运行XSLT代码时,由于要在输出xml中未显示错误消息,因此我正在执行日期比较的测试表达式变为false。
下面是输入XML:
<catalog>
<book id="bk101">
<author>Gambardella,Matthew</author>
<title>XML Developer's Guide</title>
<publish_date>2020-10-01</publish_date>
<revision_date>2019-09-02</revision_date>
<revision_date>2021-12-02</revision_date>
</book>
<book id="bk102">
<author>John,Doe</author>
<title>XPath Developer's Guide</title>
<publish_date>2020-12-01</publish_date>
<revision_date>2018-11-02</revision_date>
<revision_date>2022-12-02</revision_date>
<revision_date>2023-12-02</revision_date>
</book>
</catalog>
下面是XSLT代码段:
<xsl:for-each select="/catalog/book">
<xsl:for-each select="revision_date">
<xsl:if test="xs:date(revision_date) > xs:date(publish_date)">
<Error><xsl:text>Revision date should be lesser than publish date.</xsl:text></Error>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)