?
Solved

Convert a number to timespan in XSL

Posted on 2006-07-19
3
Medium Priority
?
851 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

800 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