Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 最早日期_Xml_Xslt_Xslt 1.0 - Fatal编程技术网

Xml 最早日期

Xml 最早日期,xml,xslt,xslt-1.0,Xml,Xslt,Xslt 1.0,需要获取最接近常规日期列表的日期,当前日期显示在标签当前日期 xslt版本1.0 <current_date>04.04.2014 13:00:00</current_date> <property_value id="8"> <property_id>96</property_id> <entity_id>237</entity_id> <property_dir_id>0&

需要获取最接近常规日期列表的日期,当前日期显示在标签当前日期

xslt版本1.0

<current_date>04.04.2014 13:00:00</current_date>
<property_value id="8">
    <property_id>96</property_id>
    <entity_id>237</entity_id>
    <property_dir_id>0</property_dir_id>
    <tag_name>event_date</tag_name>
    <value>19.04.2014 18:00:00</value>
</property_value>
<property_value id="9">
    <property_id>96</property_id>
    <entity_id>237</entity_id>
    <property_dir_id>0</property_dir_id>
    <tag_name>event_date</tag_name>
    <value>05.05.2014 22:00:00</value>
</property_value>
<property_value id="10">
    <property_id>96</property_id>
    <entity_id>237</entity_id>
    <property_dir_id>0</property_dir_id>
    <tag_name>event_date</tag_name>
    <value>07.06.2014 17:00:00</value>
</property_value>
04.04.2014 13:00:00
96
237
0
活动日期
19.04.2014 18:00:00
96
237
0
活动日期
05.05.2014 22:00:00
96
237
0
活动日期
07.06.2014 17:00:00

我不知道你说的“最早的”和“最近的”是什么意思。但是,您可以使用以下技术对日期进行排序:

<xsl:variable name="sortedDateCsvList">
  <xsl:for-each select="property_value/value | current_date">
    <xsl:sort select="substring(.,7,4)"/><!-- year -->
    <xsl:sort select="substring(.,4,2)"/><!-- month -->
    <xsl:sort select="substring(.,1,2)"/><!-- day -->
    <xsl:sort select="substring(.,12)"/><!-- time -->
    <xsl:value-of select="concat(., ',')"/>
  </xsl:for-each>
</xsl:variable>

然后,您可以使用该变量执行以下几项操作:

  • 提取最早的日期:

    前面的子字符串($sortedDataTecsvList,,)

  • 提取当前日期之后最近的日期:

    substring-before(substring-before($sortedDateCsvList,current_date),',')

或者,如果将属性
order=“descending”
添加到所有
元素,则可以获取当前日期之前最年轻的日期和最近的日期