我需要使用普通的 XPath 3.0 对一系列元素进行排序,所以没有 XQuery、没有 XSL-T 和没有代码。我试过以下这个关于如何使用排序功能的答案,但我不是 XPath 专家,所以我不知道如何使用它。
所以,我的文档基本上有以下结构:
<?xml version="1.0" encoding="UTF-8"?>
<AppointmentList>
<Appointment id="11" creatorID="1" creationDate="2018-03-01" reschedulable="ja" appointmentSeries="ja">
<Start date="2018-03-14" time="12:00:00"/>
<End date="2018-03-14" time="13:30:00"/>
<Description>Vorführung</Description>
</Appointment>
<Appointment id="22" creatorID="2" creationDate="2018-02-14" reschedulable="ja" appointmentSeries="nein">
<Start date="2018-03-20" time="13:00:00"/>
<End date="2018-03-20" time="14:00:00"/>
<Description>Programm Meeting</Description>
<Benachrichtigung art="EMail"/>
</Appointment>
<Appointment id="33" creatorID="3" creationDate="2018-02-23" reschedulable="nein" appointmentSeries="ja">
<Start date="2018-02-24" time="15:00:00"/>
<End date="2018-02-24" time="16:00:00"/>
<Description>Burglary Report</Description>
<Benachrichtigung art="Beep"/>
</Appointment>
<Appointment id="44" creatorID="1" creationDate="2018-01-01" reschedulable="nein" appointmentSeries="nein">
<Start date="2018-05-01" time="10:00:00"/>
<End date="2018-05-01" time="17:00:00"/>
<Description>Besprechung Ministerium</Description>
</Appointment>
<Appointment id="55" creatorID="8" creationDate="2018-02-28" reschedulable="nein" appointmentSeries="nein">
<Start date="2018-06-08" time="08:00:00"/>
<End date="2018-06-09" time="18:00:00"/>
<Description>Spam Konferenz</Description>
</Appointment>
<Appointment id="66" creatorID="10" creationDate="2018-03-22" reschedulable="nein" appointmentSeries="nein">
<Start date="2018-05-07" time="08:00:00"/>
<End date="2018-05-07" time="18:00:00"/>
<Description>XML Tutorium</Description>
</Appointment>
<Appointment id="77" creatorID="9" creationDate="2018-03-15" reschedulable="ja" appointmentSeries="nein">
<Start date="2018-04-20" time="08:00:00"/>
<End date="2018-04-20" time="09:00:00"/>
<Description>Abschlussprüfung</Description>
</Appointment>
<Appointment id="88" creatorID="7" creationDate="2018-03-09" reschedulable="nein" appointmentSeries="ja">
<Start date="2018-03-14" time="17:00:00"/>
<End date="2018-03-14" time="18:00:00"/>
<Description>Versammlung Workaholics</Description>
</Appointment>
<Appointment id="99" creatorID="6" creationDate="2018-02-01" reschedulable="nein" appointmentSeries="nein">
<Start date="2018-02-28" time="10:00:00"/>
<End date="2018-02-28" time="17:00:00"/>
<Description>Fortbildung Datenbanken</Description>
</Appointment>
</AppointmentList>
我想按日期升序排列三个下一个约会。因此,从现在开始的下一个约会位于结果序列的第一个位置,并且从距现在最近的第三个日期开始的约会应该是序列的最后一个元素。下面显示的查询为我提供了尚未发生的约会,但我无法弄清楚如何正确应用排序功能。
/AppointmentList/Appointment[fn:dateTime(Start/@date, Start/@time) > fn:current-dateTime()]
谢谢,因为我找不到关于 fn:sort 函数的任何好的文档。