XSLT Question

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi. I have a question using XSLT in C# (it is a XSLT question). I use a ZPathDocument to load my XML, then a XslCompiledTransform to load my XSLT and then I apply the Transform method and it works fine. But I have a question for what I am trying to transform.

I have a node that looks like this
<Node Date="05062011" Time="1630" />
I want to have it look a DateTime so it looks like
<Node DateTime="2011-05-06T16:30:00" />
So I use XSLT like this
<xsl:value-of select="substring(@Date, 5, 4)"/>-<xsl:value-of select="substring(@Date, 1, 2)"/>-<xsl:value-of select="substring(@Date, 3, 2)"/>T<xsl:value-of select="substring(@Time, 1, 2)"/>:<xsl:value-of select="substring(@Time,
3, 2)"/>:00
And it works fine, now my problem is I dont know how to increment to the next day if time is > 23:59, ie 2011-05-06 with a time of 24:30 would become 2011-05-07 with a time of 00:30. Lets take this example:
<Node Date="05062011" Time="2630" />
I want it to be
<Node DateTime="2011-05-07T02:30:00" />
Can anyone help me with the XSLT?

View the full article
 
Back
Top