Я пытаюсь получить первую строку, которая соответствует критериям и отсортирована по des c в wd: Completed_DateTime. Там может быть несколько строк, которые соответствуют критериям. Например, wd: Instance_Set_Reference / wd: ID [@wd: type = 'Customer_Category_ID' и text () = 'CRDRG'] ниже XML вернет две строки, но я хочу, чтобы первое значение wd: Instance_Set_Reference / wd: ID [@wd: type = 'Customer_Category_ID' и text () = 'CRDRG'] отсортировано по des c на wd: Completed_DateTime.
Sample XML -
<?xml version='1.0' encoding='UTF-8'?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wd="urn:com.workday/bsvc">
<env:Body>
<wd:Get_Integration_Events_Response
xmlns:wd="urn:com.workday/bsvc"
wd:version="v34.0">
<wd:Request_Criteria>
<wd:Integration_System_Reference
wd:Descriptor="INTXXXX REV FINRA Connect Customer Invoice PDF Outbound Studio">
<wd:ID wd:type="WID">0ef644a34de5012532e30ad25003dcf1</wd:ID>
<wd:ID wd:type="Integration_System_ID">INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio_Collection/INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio/StartHere</wd:ID>
</wd:Integration_System_Reference>
<wd:Integration_Event_Status_Reference wd:Descriptor="Completed">
<wd:ID wd:type="WID">d8b0bcd8446c11de98360015c5e6daf6</wd:ID>
<wd:ID wd:type="Background_Process_Instance_Status_ID">Completed</wd:ID>
</wd:Integration_Event_Status_Reference>
<wd:Integration_Event_Status_Reference wd:Descriptor="Completed with Warnings">
<wd:ID wd:type="WID">d8b0c34a446c11de98360015c5e6daf6</wd:ID>
<wd:ID wd:type="Background_Process_Instance_Status_ID">CompletedWithWarnings</wd:ID>
</wd:Integration_Event_Status_Reference>
</wd:Request_Criteria>
<wd:Response_Filter>
<wd:Page>1</wd:Page>
<wd:Count>50</wd:Count>
</wd:Response_Filter>
<wd:Response_Results>
<wd:Total_Results>2</wd:Total_Results>
<wd:Total_Pages>1</wd:Total_Pages>
<wd:Page_Results>2</wd:Page_Results>
<wd:Page>1</wd:Page>
</wd:Response_Results>
<wd:Response_Data>
<wd:Integration_Event>
<wd:Integration_Event_Data>
<wd:Completed_DateTime>2020-03-12T08:13:56.457-07:00</wd:Completed_DateTime>
<wd:Percent_Complete>1</wd:Percent_Complete>
<wd:Integration_Runtime_Parameter_Data>
<wd:Launch_Configurable_Name>INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio_Collection/INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio/StartHere</wd:Launch_Configurable_Name>
<wd:Parameter_Name wd:Label="InvoicePrintStartDateTime (Required)">DateTime</wd:Parameter_Name>
<wd:Date>2019-03-12T08:13:15.000-07:00</wd:Date>
</wd:Integration_Runtime_Parameter_Data>
<wd:Integration_Runtime_Parameter_Data>
<wd:Launch_Configurable_Name>INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio_Collection/INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio/StartHere</wd:Launch_Configurable_Name>
<wd:Parameter_Name wd:Label="InvoicePrintEndDateTime (Required)">DateTime</wd:Parameter_Name>
<wd:Date>2020-03-12T08:13:42.138-07:00</wd:Date>
</wd:Integration_Runtime_Parameter_Data>
<wd:Integration_Runtime_Parameter_Data>
<wd:Launch_Configurable_Name>INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio_Collection/INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio/StartHere</wd:Launch_Configurable_Name>
<wd:Parameter_Name wd:Label="Revenue Stream">Customer Category of Billable Entity</wd:Parameter_Name>
<wd:Instance_Set_Reference
wd:Descriptor="(TRXXX)">
<wd:ID wd:type="WID">df63f2db7473018e586236fcdc00fa06</wd:ID>
<wd:ID wd:type="Customer_Category_ID">TRXXX</wd:ID>
</wd:Instance_Set_Reference>
</wd:Integration_Runtime_Parameter_Data>
</wd:Integration_Event_Data>
</wd:Integration_Event>
<wd:Integration_Event>
<wd:Integration_Event_Data>
<wd:Completed_DateTime>2019-11-20T11:27:33.111-08:00</wd:Completed_DateTime>
<wd:Percent_Complete>1</wd:Percent_Complete>
<wd:Integration_Runtime_Parameter_Data>
<wd:Launch_Configurable_Name>INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio_Collection/INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio/StartHere</wd:Launch_Configurable_Name>
<wd:Parameter_Name wd:Label="InvoicePrintStartDateTime (Required)">DateTime</wd:Parameter_Name>
<wd:Date>2015-11-20T11:19:57.000-08:00</wd:Date>
</wd:Integration_Runtime_Parameter_Data>
<wd:Integration_Runtime_Parameter_Data>
<wd:Launch_Configurable_Name>INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio_Collection/INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio/StartHere</wd:Launch_Configurable_Name>
<wd:Parameter_Name wd:Label="InvoicePrintEndDateTime (Required)">DateTime</wd:Parameter_Name>
<wd:Date>2019-11-20T11:27:22.179-08:00</wd:Date>
</wd:Integration_Runtime_Parameter_Data>
<wd:Integration_Runtime_Parameter_Data>
<wd:Launch_Configurable_Name>INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio_Collection/INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio/StartHere</wd:Launch_Configurable_Name>
<wd:Parameter_Name wd:Label="Revenue Stream">Customer Category of Billable Entity</wd:Parameter_Name>
<wd:Instance_Set_Reference
wd:Descriptor="(CRXXX)">
<wd:ID wd:type="WID">df63f2db7473018e586236fcdc00fa06</wd:ID>
<wd:ID wd:type="Customer_Category_ID">CRXXX</wd:ID>
</wd:Instance_Set_Reference>
</wd:Integration_Runtime_Parameter_Data>
</wd:Integration_Event_Data>
</wd:Integration_Event>
<wd:Integration_Event>
<wd:Integration_Event_Data>
<wd:Completed_DateTime>2020-02-10T11:27:33.111-08:00</wd:Completed_DateTime>
<wd:Percent_Complete>1</wd:Percent_Complete>
<wd:Integration_Runtime_Parameter_Data>
<wd:Launch_Configurable_Name>INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio_Collection/INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio/StartHere</wd:Launch_Configurable_Name>
<wd:Parameter_Name wd:Label="InvoicePrintStartDateTime (Required)">DateTime</wd:Parameter_Name>
<wd:Date>2015-11-20T11:19:57.000-08:00</wd:Date>
</wd:Integration_Runtime_Parameter_Data>
<wd:Integration_Runtime_Parameter_Data>
<wd:Launch_Configurable_Name>INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio_Collection/INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio/StartHere</wd:Launch_Configurable_Name>
<wd:Parameter_Name wd:Label="InvoicePrintEndDateTime (Required)">DateTime</wd:Parameter_Name>
<wd:Date>2019-11-20T11:27:22.179-08:00</wd:Date>
</wd:Integration_Runtime_Parameter_Data>
<wd:Integration_Runtime_Parameter_Data>
<wd:Launch_Configurable_Name>INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio_Collection/INTXXXX_REV_FINRA_Connect_Customer_Invoice_PDF_Outbound_Studio/StartHere</wd:Launch_Configurable_Name>
<wd:Parameter_Name wd:Label="Revenue Stream">Customer Category of Billable Entity</wd:Parameter_Name>
<wd:Instance_Set_Reference
wd:Descriptor="(CRXXX)">
<wd:ID wd:type="WID">df63f2db7473018e586236fcdc00fa06</wd:ID>
<wd:ID wd:type="Customer_Category_ID">CRXXX</wd:ID>
</wd:Instance_Set_Reference>
</wd:Integration_Runtime_Parameter_Data>
</wd:Integration_Event_Data>
</wd:Integration_Event>
</wd:Response_Data>
</wd:Get_Integration_Events_Response>
</env:Body>
</env:Envelope>
Sample XSLT -
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wd="urn:com.workday/bsvc" exclude-result-prefixes="xs env wd">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:for-each select="/env:Envelope/env:Body/wd:Get_Integration_Events_Response/wd:Response_Data/wd:Integration_Event/wd:Integration_Event_Data[wd:Integration_Runtime_Parameter_Data/wd:Instance_Set_Reference/wd:ID[@wd:type = 'Customer_Category_ID']/text()= 'CRXXX']">
<xsl:sort select="wd:Completed_DateTime" order="descending"/>
<xsl:if test="position()=1">
<Revenue_Stream>
<xsl:value-of select="wd:Integration_Runtime_Parameter_Data/wd:Instance_Set_Reference/wd:ID[@wd:type = 'Customer_Category_ID']/text()"/>
</Revenue_Stream>
<Completion_date>
<xsl:value-of select="wd:Completed_DateTime"/>
</Completion_date>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Ожидаемый результат -
<Root>
<Revenue_Stream>CRXXX</Revenue_Stream>
<Completion_date>2020-02-10T11:27:33.111-08:00</Completion_date>
</Root>
Мне нужно выбрать это значение из XML, в котором будет много строк. Так что я не уверен, что подход, который я использую, эффективен с точки зрения производительности. Некоторые рекомендации по этому вопросу будут оценены.