0

I have an Xpath code in a BizTalk Expression shape which is return this error :

'min(/[local-name()='EmployeeUDM_Response' and namespace-uri()='http://Securitas/ESB/Schemas/v2/EmployeeUDM']/[local-name()='Return']/[local-name()='Employee']/[local-name()='Contracts']/[local-name()='Contract']/[local-name()='EmployementStartDate']/xs:dateTime(.))' has an invalid token.

I got this error several time before but it was because I had put a bad path

Xpath Code:

xpath("min(/*[local-name()='EmployeeUDM_Response' and namespace-uri()='http://Securitas/ESB/Schemas/v2/EmployeeUDM']/*[local-name()='Return']/*[local-name()='Employee']/*[local-name()='Contracts']/*[local-name()='Contract']/*[local-name()='EmployementStartDate']/xs:dateTime(.))")

XML file:

- <Employee date="date_0" rostarproject="rostarproject_1" xmlns:ns0="http://Securitas.ESB.HR.EmployeeUDMToRostar.MDSRequest_Schema">
    <UPN>UPN_0</UPN>
    <SAMAccountName>SAMAccountName_0</SAMAccountName>
    <Number>Number_0</Number>
    <SagaNumber>SagaNumber_0</SagaNumber>
    <SurNameFull>SurNameFull_0</SurNameFull>
    <FirstName>FirstName_0</FirstName>
    <GivenName>GivenName_0</GivenName>
    <Gender>Gender_0</Gender>
    <DateOfBirth>DateOfBirth_0</DateOfBirth>
    <EmailPrivate>EmailPrivate_0</EmailPrivate>
    <PhoneMobilePrivate>PhoneMobilePrivate_0</PhoneMobilePrivate>
    <PhonePrivate>PhonePrivate_0</PhonePrivate>
    <EmployementStartDate>EmployementStartDate_0</EmployementStartDate>
    <EmployementEndDate>EmployementEndDate_0</EmployementEndDate>
    - <Contracts>
        - <Contract>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <Type>Type_0</Type>
            <DissimelarCAO>DissimelarCAO_0</DissimelarCAO>
            <PhaseID>PhaseID_0</PhaseID>
            <PB_CAO>PB_CAO_0</PB_CAO>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <Type>Type_0</Type>
            <DissimelarCAO>DissimelarCAO_0</DissimelarCAO>
            <PhaseID>PhaseID_0</PhaseID>
            <PB_CAO>PB_CAO_0</PB_CAO>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <Type>Type_0</Type>
            <DissimelarCAO>DissimelarCAO_0</DissimelarCAO>
            <PhaseID>PhaseID_0</PhaseID>
            <PB_CAO>PB_CAO_0</PB_CAO>
        </Contract>
    </Contracts>
    - <Functions>
        - <Function>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <Position>Position_0</Position>
            <CostCenterCode>CostCenterCode_0</CostCenterCode>
            <CostCenter>CostCenter_0</CostCenter>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <Position>Position_0</Position>
            <CostCenterCode>CostCenterCode_0</CostCenterCode>
            <CostCenter>CostCenter_0</CostCenter>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <Position>Position_0</Position>
            <CostCenterCode>CostCenterCode_0</CostCenterCode>
            <CostCenter>CostCenter_0</CostCenter>
        </Function>
    </Functions>
    - <Adresses>
        - <Adress>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <StreetNumber>StreetNumber_0</StreetNumber>
            <StreetNumberAddition>StreetNumberAddition_0</StreetNumberAddition>
            <Street>Street_0</Street>
            <ZipCode>ZipCode_0</ZipCode>
            <City>City_0</City>
            <Country>Country_0</Country>
            <Type>Type_0</Type>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <StreetNumber>StreetNumber_0</StreetNumber>
            <StreetNumberAddition>StreetNumberAddition_0</StreetNumberAddition>
            <Street>Street_0</Street>
            <ZipCode>ZipCode_0</ZipCode>
            <City>City_0</City>
            <Country>Country_0</Country>
            <Type>Type_0</Type>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <StreetNumber>StreetNumber_0</StreetNumber>
            <StreetNumberAddition>StreetNumberAddition_0</StreetNumberAddition>
            <Street>Street_0</Street>
            <ZipCode>ZipCode_0</ZipCode>
            <City>City_0</City>
            <Country>Country_0</Country>
            <Type>Type_0</Type>
        </Adress>
    </Adresses>
    - <Wages>
        - <Wage>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <DissimelarZipCode>DissimelarZipCode_0</DissimelarZipCode>
            <MAXKM>MAXKM_0</MAXKM>
            <RightTravelHours>RightTravelHours_0</RightTravelHours>
            <RightTravelExpense>RightTravelExpense_0</RightTravelExpense>
            <RightAdditions>RightAdditions_0</RightAdditions>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <DissimelarZipCode>DissimelarZipCode_0</DissimelarZipCode>
            <MAXKM>MAXKM_0</MAXKM>
            <RightTravelHours>RightTravelHours_0</RightTravelHours>
            <RightTravelExpense>RightTravelExpense_0</RightTravelExpense>
            <RightAdditions>RightAdditions_0</RightAdditions>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <DissimelarZipCode>DissimelarZipCode_0</DissimelarZipCode>
            <MAXKM>MAXKM_0</MAXKM>
            <RightTravelHours>RightTravelHours_0</RightTravelHours>
            <RightTravelExpense>RightTravelExpense_0</RightTravelExpense>
            <RightAdditions>RightAdditions_0</RightAdditions>
        </Wage>
    </Wages>
    - <Roosters>
        - <Rooster>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <WeekAmountOfHours>WeekAmountOfHours_0</WeekAmountOfHours>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <WeekAmountOfHours>WeekAmountOfHours_0</WeekAmountOfHours>
            <StartDate>StartDate_0</StartDate>
            <EndDate>EndDate_0</EndDate>
            <WeekAmountOfHours>WeekAmountOfHours_0</WeekAmountOfHours>
        </Rooster>
    </Roosters>
</ns0:Employee>

I expected the output of XML with the oldest 'EmployementStartDate'

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
Davon
  • 121
  • 2
  • 9
  • BizTalk doesn't support xslt 2.0 See this [thread](https://stackoverflow.com/questions/44841104/is-there-xslt-2-0-or-3-0-support-in-biztalk-server-2016-mapping). – Ed Bangga Apr 22 '19 at 01:32

1 Answers1

1

min() is available in XPath 2.0 but not XPath 1.0 (though perhaps it's available in Biztalk?)

You need to change /[local-name()='x'] to /*[local-name()='x'] everywhere.

The construct XXX/xs:date-time(.) also requires XPath 2.0.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • My version of BizTalk is 2013 and it doesn't support Xpath 2.0. You're right! Thank you. I'm actually looking for an equivalent code to do the same. I'll post here when I found it. – Davon Apr 19 '19 at 12:29