Solved

Convert a number to timespan in XSL

Posted on 2006-07-19
3
837 Views
Last Modified: 2010-05-18
Hello,

I am receiving an XML data island from a web application that I then convert to Microsoft Project XML via an xsl stylesheet I am creating.  One of the tags called "Duration" that the Microsoft Project requires is of type "timespan".  An acceptable entry for this is:

<Duration>PT80H0M0S</Duration>

Which I think corresponds to 10 days.  (At least that what my duration value is in MSProject.)

But anyway, in the data island I am receiving has the duration as just an integer, like 10,15, 20, etc in days.  How can I convert it to this type of format in my xsl sheet?  I don't really know what PT80H0M0S means.  

Thanks.
0
Comment
Question by:dentyne
  • 2
3 Comments
 
LVL 9

Expert Comment

by:owenli27
ID: 17141631
I believe that Timespan is NET Framework type.
PT80H0M0S means 80 hours and 0 min and 0 secods.  The second char 'T' means TIME.

A example:
P2Y3M18DT10H0M20S is 2 years, 3 months, 18 days, 10 hours, 0 minutes, and 20 seconds.

if you get your "Duration" days as integer, it is very easy to convert it to Hours by times 24 and concatenate it with rest of string. Do you need XSL code for this?
0
 
LVL 9

Accepted Solution

by:
owenli27 earned 500 total points
ID: 17141768
in case you need this line:  <xsl:value-of select="concat('PT', (text()*24), 'H0M0S')" />
0
 
LVL 1

Author Comment

by:dentyne
ID: 17146442
Hi Owen,

Thanks for the help.  I think this will do the trick.  
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question