So i have a dateTime like "2022-06-25T03:00:00+02:00" and i have to just remove the seconds and retain everything else.
eg: "2022-06-25T03:00+02:00"
Below is the input xml, i have to tranform the data to match the eg: that i ahve mentioned above.
Could someone please help? Note: I am new to XQuery, so please tell me what is that your xquery doing too.
Input XML
<?xml version="1.0" encoding="UTF-8"?>
<Message xsi:schemaLocation="http://abcd.ch http://abcd.ch/ns/Message.xsd" xmlns="http://abcd.ch/ns/Message" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<messageId>4894954fyfuguyutfu_98798_98798</messageId>
<messageType>Message</messageType>
<messageDate>2022-06-23T12:49:11+02:00</messageDate>
</Message>
Expected output XML
<?xml version="1.0" encoding="UTF-8"?>
<Nomination xmlns="http://www.example.com" Release="1" Version="EGAS40">
<Identification v="ABC123"/>
<Type v="55G"/>
<messageDate v="2022-06-23T12:49+02:00"/>
</Nomination>
The easiest approach is using fn:replace
with RegEx:
replace(xs:string($file/dateTimeValue),'(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}):\d{2}(\+\d{2}:\d{2})','$1$2')
Result is
2022-06-25T03:00+02:00
You could not convert the resulting string back to an xs:dateTime
because, well, it would be wrong format (obviously).