0

How can I changes the below xml timestamp attribute value to xs:dateTime Format.

<TimeValidations>
<timestamp>2017-01-30 09:30:10</timestamp>
</TimeValidations>

I need to convert timestamp attribute value(2002-05-30 09:30:10) to ISO 8601 format like

2017-01-30T09:30:10(xs:dateTime) 

in XSLT 1.0.Can anyone help me to do this conversion?

1 Answer 1

1

Maybe I'm thinking in a too simple way, but if your format differs from the desired format always only in the T seperating date and time parts, you could use translate-function:

<xsl:template match="/TimeValidations/timestamp">
  <xsl:value-of select="translate(.,' ', 'T')"/>
</xsl:template>

When applied to your xml, it yields 2017-01-30T09:30:10. Of course, you could then use this to construct an xs:datetime value.

Sign up to request clarification or add additional context in comments.

Comments

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.