0

I have the below XML input file.

<?xml version="1.0" encoding="UTF-8"?>
<ns3:Bonger xmlns:ns3="http://NEXSTEP.Schemas.Bonger" xmlns:ns2="http://NEXSTEP.Schemas.NexstepTypes">
  <ROUTE_RECORD>
    <ns2:SENDER Sender_code="BO_SERVER"/>
    <ns2:RECEIPIENT Receipient_code="MASTER"/>
    <ns2:OverAllStatus>NY</ns2:OverAllStatus>
  </ROUTE_RECORD>
  <MESSAGE_RECORD>
    <InsertChange>
      <Message>
        <ns2:OpprettetEndretSlettet>
          <ns2:OpprettetTidspunkt>2021-08-09+02:00</ns2:OpprettetTidspunkt>
          <ns2:OpprettetKl>15:13:14.636+02:00</ns2:OpprettetKl>
          <ns2:EndretAv>ADMIN</ns2:EndretAv>
        </ns2:OpprettetEndretSlettet>
      </Message>
    </InsertChange>
  </MESSAGE_RECORD>
</ns3:Bonger>

Using a transformer I need to use both OpprettetTidspunkt and OpprettetKl (both date and time) and need to output something like <MSG_DATE>2021-08-09T10:48:15.057<MSG_DATE>

Please note that I need to output the MSG_DATE as ISOString format

Any ideas??

2
  • Please show the exact output you need to get in the given example. Specifically, how do you want to handle the +02:00 offset. Commented Aug 9, 2021 at 11:17
  • @michael.hor257k something like this would do <MSG_DATE>2021-06-16T08:32:17 +02:00</MSG_DATE> Commented Aug 9, 2021 at 11:39

1 Answer 1

1

Both of the outputs you show make no sense when compared to your input. Assuming that the correct output in the given example is actually:

MSG_DATE>2021-08-09T15:13:14.636+02:00</MSG_DATE>

you could do simply:

<xsl:template match="/ns3:Bonger">
    <!-- ... -->
    <MSG_DATE>
        <xsl:variable name="mod" select="MESSAGE_RECORD/InsertChange/Message/ns2:OpprettetEndretSlettet"/>
        <xsl:value-of select="substring($mod/ns2:OpprettetTidspunkt, 1, 10)"/>
        <xsl:text>T</xsl:text>
        <xsl:value-of select="$mod/ns2:OpprettetKl"/>
    </MSG_DATE>
    <!-- ... -->
</xsl:template>
Sign up to request clarification or add additional context in comments.

1 Comment

This is working as expected. Thanks alot for you help. Much Appreciated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.