]> permondes.de Git - OpenWorkBench2MSP_Converter.git/blame - OWB2MSPConverterB.xsl
Initial publication on git of project from 2006
[OpenWorkBench2MSP_Converter.git] / OWB2MSPConverterB.xsl
CommitLineData
ecd11c60 1<?xml version="1.0"?>\r
2<!--XSLT 1.0 - http://home.tiscali.de/hillerd - conversion of OpenWorkbench to MS Project -->\r
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">\r
4<xsl:output method="xml" omit-xml-declaration="no"/>\r
5<xsl:output method="xml" cdata-section-elements="Notes"/>\r
6\r
7<xsl:key name="KeyTaskwID" match="Task" use="@wID"/> <!-- Task wID key -->\r
8<xsl:key name="KeyBaseCalName" match="BaseCalendars/Calendar" use="@name"/> <!-- Calendar name key -->\r
9<xsl:key name="KeyDepUID" match="Dependency" use="@successorUID"/> <!-- Dependency successor UID key-->\r
10<xsl:key name="KeyDepID" match="Dependency" use="@successorID"/> <!-- Dependency successor ID key-->\r
11<xsl:key name="KeyPoolRes" match="PoolResource" use="@resourceId"/> <!-- Poolresource ID key -->\r
12\r
13<!-- ****************************************************************** start with WORKBENCH_PROJECT **************** -->\r
14<xsl:template match="/WORKBENCH_PROJECT">\r
15 <xsl:apply-templates select="Projects/Project"/> <!-- insert all Projects/Project -->\r
16</xsl:template>\r
17\r
18<!-- ****************************************************************** PROJECT ************************************* -->\r
19<xsl:template match="Project">\r
20 <Project xmlns="http://schemas.microsoft.com/project">\r
21 <Name><xsl:value-of select="@name"/></Name>\r
22 <StartDate><xsl:value-of select="@start"/></StartDate>\r
23 <FinishDate><xsl:value-of select="@finish"/></FinishDate>\r
24 <CalendarUID> <!-- Project Calendar is "Standard" -->\r
25 <xsl:value-of select='key("KeyBaseCalName", "Standard")/@sID'/>\r
26 </CalendarUID> \r
27 <MinutesPerDay>480</MinutesPerDay> <!-- 8h / day -->\r
28 <HonorConstraints>0</HonorConstraints> <!-- Schedule by task dependencies, not by constraints -->\r
29 <WeekStartDay>1</WeekStartDay> <!-- week starts on Monday -->\r
30 <MicrosoftProjectServerURL>0</MicrosoftProjectServerURL> <!-- Project was not generated by MS -->\r
31 <Autolink>0</Autolink> <!-- Do not autolink inserted tasks -->\r
32 <ProjectExternallyEdited>1</ProjectExternallyEdited> <!-- Project was externally edited -->\r
33\r
34 <Calendars> \r
35 <xsl:apply-templates select='//BaseCalendars/Calendar'/> <!-- Basecalendars -->\r
36 <!-- Resource Calendars -->\r
37 <xsl:apply-templates select="//PoolResource[Calendar]" mode="ResourceCal"/>\r
38 </Calendars>\r
39 <Tasks>\r
40 <xsl:apply-templates select="Tasks/Task"/> <!-- insert all Task(s) -->\r
41 </Tasks>\r
42 <Resources>\r
43 <xsl:apply-templates select="//PoolResource"/> <!-- insert all PoolResource(s) -->\r
44 </Resources>\r
45 <Assignments>\r
46 <xsl:apply-templates select=".//Assignment"/> <!-- insert all Assignment(s) anywhere below -->\r
47 </Assignments>\r
48 </Project>\r
49</xsl:template>\r
50\r
51<!-- ****************************************************************** Calendar **************************** -->\r
52<xsl:template match="Calendar">\r
53 <Calendar>\r
54 <UID><xsl:value-of select="@sID"/></UID>\r
55 <Name><xsl:value-of select="@name"/></Name> \r
56 <IsBaseCalendar>1</IsBaseCalendar> <!-- all are baseCalendars --> \r
57 <BaseCalendarUID> <!-- use -1 if has no basecalendar -->\r
58 <xsl:choose>\r
59 <xsl:when test='count(@baseCalendar)>0'>\r
60 <xsl:value-of select='key("KeyBaseCalName", @baseCalendar)/@sID'/>\r
61 </xsl:when>\r
62 <xsl:otherwise>-1</xsl:otherwise>\r
63 </xsl:choose>\r
64 </BaseCalendarUID>\r
65 <Weekdays>\r
66 <xsl:apply-templates select="Days/Day[@dayOfWeek]"/> <!-- insert Day with values from MON to SUN -->\r
67 <xsl:apply-templates select='Days/Day[@start]' mode='startfinish'/> <!-- insert exceptions -->\r
68 </Weekdays>\r
69 </Calendar>\r
70</xsl:template>\r
71\r
72<!-- ****************************************************************** Calendar/Days/Day (MON-SUN) ***************** -->\r
73<xsl:template match="Day">\r
74 <Weekday>\r
75 <DayType>\r
76 <xsl:choose>\r
77 <xsl:when test='@dayOfWeek="SUN"'>1</xsl:when>\r
78 <xsl:when test='@dayOfWeek="MON"'>2</xsl:when>\r
79 <xsl:when test='@dayOfWeek="TUE"'>3</xsl:when>\r
80 <xsl:when test='@dayOfWeek="WED"'>4</xsl:when>\r
81 <xsl:when test='@dayOfWeek="THU"'>5</xsl:when>\r
82 <xsl:when test='@dayOfWeek="FRI"'>6</xsl:when>\r
83 <xsl:when test='@dayOfWeek="SAT"'>7</xsl:when>\r
84 <xsl:otherwise>0</xsl:otherwise> \r
85 </xsl:choose>\r
86 </DayType>\r
87 <DayWorking>\r
88 <xsl:choose>\r
89 <xsl:when test='@isWorkDay="true"'>1</xsl:when>\r
90 <xsl:otherwise>0</xsl:otherwise>\r
91 </xsl:choose>\r
92 </DayWorking> \r
93 <WorkingTimes>\r
94 <xsl:apply-templates select="Shifts/Shift"/> <!-- insert working time; MSP only allows up to 5 -->\r
95 </WorkingTimes>\r
96 </Weekday>\r
97</xsl:template>\r
98\r
99<!-- ****************************************************************** Calendar/Days/Day (with startfinish data) *** -->\r
100<!-- *** can come from Basecalendar and Resourcecalendar ************************************************************ -->\r
101<xsl:template match="Day" mode="startfinish">\r
102 <WeekDay>\r
103 <DayType>0</DayType>\r
104 <DayWorking>\r
105 <xsl:choose>\r
106 <xsl:when test='@isWorkDay="true"'>1</xsl:when>\r
107 <xsl:otherwise>0</xsl:otherwise>\r
108 </xsl:choose>\r
109 </DayWorking> \r
110 <TimePeriod>\r
111 <FromDate><xsl:value-of select='concat(@start,"T00:00:00")'/></FromDate>\r
112 <ToDate> <!-- if finish not given provide start -->\r
113 <xsl:choose>\r
114 <xsl:when test='count(@finish)>0'><xsl:value-of select='concat(@finish,"T23:59:00")'/></xsl:when>\r
115 <xsl:otherwise><xsl:value-of select='concat(@start,"T23:59:00")'/></xsl:otherwise>\r
116 </xsl:choose>\r
117 </ToDate> \r
118 </TimePeriod>\r
119 <xsl:if test='@isWorkDay="true"'> <!-- exceptional working time has standard time -->\r
120 <WorkingTimes>\r
121 <WorkingTime>\r
122 <FromTime>08:00:00</FromTime> \r
123 <ToTime>12:00:00</ToTime> \r
124 </WorkingTime>\r
125 <WorkingTime>\r
126 <FromTime>13:00:00</FromTime> \r
127 <ToTime>17:00:00</ToTime> \r
128 </WorkingTime>\r
129 </WorkingTimes>\r
130 </xsl:if>\r
131 </WeekDay>\r
132</xsl:template>\r
133\r
134<!-- ****************************************************************** Calendar/Days/Day/Shifts/Shift ****** -->\r
135<xsl:template match="Shift">\r
136 <WorkingTime>\r
137 <FromTime><xsl:value-of select="@start"/></FromTime>\r
138 <ToTime><xsl:value-of select="@finish"/></ToTime>\r
139 </WorkingTime>\r
140</xsl:template>\r
141\r
142<!-- ****************************************************************** Calendar of PoolResource (ResourceCal) ****** -->\r
143<xsl:template match="PoolResource" mode="ResourceCal">\r
144 <Calendar>\r
145 <UID><xsl:value-of select="@sID+100"/></UID> <!-- Calendar UID is 100 + resource UID -->\r
146 <Name><xsl:value-of select="@fullName"/></Name> <!-- Calendarname is resource name -->\r
147 <IsBaseCalendar>0</IsBaseCalendar> <!-- not a baseCalendar --> \r
148 <BaseCalendarUID>\r
149 <xsl:value-of select='key("KeyBaseCalName", Calendar/@baseCalendar)/@sID'/>\r
150 </BaseCalendarUID>\r
151 <WeekDays>\r
152 <xsl:apply-templates select='Calendar/Days/Day[@start]' mode='startfinish'/> <!-- insert exceptions --> \r
153 </WeekDays>\r
154 </Calendar>\r
155</xsl:template>\r
156\r
157<!-- ****************************************************************** Task ************************************ -->\r
158<xsl:template match="Task">\r
159 <Task>\r
160 <UID><xsl:value-of select="@sID"/></UID> <!-- UID is sequential number -->\r
161 <ID><xsl:value-of select='position()'/></ID> <!-- ID is sequential number -->\r
162 <Name><xsl:value-of select="@name"/></Name>\r
163 <Type>0</Type> <!-- fixed units, necessary because OWB does not exp. dur.--> \r
164 <OutlineLevel><xsl:value-of select="@outlineLevel"/></OutlineLevel>\r
165 <Start><xsl:value-of select="@start"/></Start>\r
166 <Finish><xsl:value-of select="@finish"/></Finish>\r
167 <Milestone> \r
168 <xsl:choose>\r
169 <xsl:when test='@milestone="true"'>1</xsl:when>\r
170 <xsl:otherwise>0</xsl:otherwise>\r
171 </xsl:choose>\r
172 </Milestone> \r
173 <Summary> \r
174 <xsl:choose>\r
175 <xsl:when test='@summary="true"'>1</xsl:when>\r
176 <xsl:otherwise>0</xsl:otherwise>\r
177 </xsl:choose>\r
178 </Summary>\r
179 <Critical> \r
180 <xsl:choose>\r
181 <xsl:when test='@critical="true"'>1</xsl:when>\r
182 <xsl:otherwise>0</xsl:otherwise>\r
183 </xsl:choose>\r
184 </Critical>\r
185 <FixedCostAccrual>2</FixedCostAccrual> <!-- Prorated, costs accrue as work is scheduled/done -->\r
186 <PercentComplete><xsl:value-of select="@percComp*100"/></PercentComplete> <!-- OWB:0..1, MSP:0..100 -->\r
187\r
188 <xsl:if test='@percComp &gt; 0'> <!-- if started, set actual start date -->\r
189 <ActualStart><xsl:value-of select="@start"/></ActualStart>\r
190 </xsl:if> \r
191\r
192 <CalendarUID>-1</CalendarUID> <!-- no task calendar -->\r
193\r
194 <xsl:apply-templates select="Constraints/Constraint[1]"/> <!-- take only first constraint -->\r
195 <Notes> <!-- MSP only allows 1 note, OWB more -->\r
196 <xsl:for-each select='Notes/Note'>\r
197 <xsl:value-of select='@content'/>\r
198 <xsl:if test='position() != last()'><xsl:text>&#xA;</xsl:text></xsl:if>\r
199 </xsl:for-each>\r
200 </Notes>\r
201 <xsl:choose> <!-- dependencies with UID or taskID -->\r
202 <xsl:when test='count(@UID)>0'><xsl:apply-templates select='key("KeyDepUID",@UID)'/> </xsl:when> \r
203 <xsl:otherwise> <xsl:apply-templates select='key("KeyDepID",@taskID)'/></xsl:otherwise>\r
204 </xsl:choose>\r
205 </Task>\r
206</xsl:template>\r
207\r
208<!-- ****************************************************************** Task/Constraint ************************** -->\r
209<xsl:template match="Constraint">\r
210 <!-- type sequence OWB: mso, snet, snlt, mfo, fnet, fnlt; 0:none, 1:alap, 2:asap (not possible) -->\r
211 <ConstraintType>\r
212 <xsl:value-of select='translate(@type, "678534012", "245367010")'/>\r
213 </ConstraintType>\r
214
215 <xsl:if test='@type>"2"'> <!-- time only-if needed (not for none, asap, alap) -->\r
216 <ConstraintDate>\r
217 <xsl:value-of select="@time"/>\r
218 </ConstraintDate>\r
219 </xsl:if>\r
220</xsl:template>\r
221\r
222<!-- ****************************************************************** Task/Dependency ***************************** -->\r
223<!-- *** selected is that dependency, where the successorID is equal to the current taskID ************************** -->\r
224<xsl:template match="Dependency">\r
225 <PredecessorLink> <!-- take predID, find wID and output sID -->\r
226 <xsl:choose> <!-- can come from taskID or UID -->\r
227 <xsl:when test='count(@predecessorID)>0'>\r
228 <xsl:apply-templates select='key("KeyTaskwID",@predecessorID)' mode="Taskpredecessor"/>\r
229 </xsl:when> \r
230 <xsl:otherwise>\r
231 <xsl:apply-templates select='key("KeyTaskwID",@predecessorUID)' mode="Taskpredecessor"/>\r
232 </xsl:otherwise> \r
233 </xsl:choose>\r
234 <Type> \r
235 <xsl:value-of select='translate(@startFinishType, "0123", "1302")'/> <!-- FS, SS FF SF -->\r
236 </Type>\r
237 <CrossProject>0</CrossProject> <!-- no external project -->\r
238 <CrossProjectName/> <!-- empty string-->\r
239 <LinkLag>\r
240 <xsl:choose> <!-- 1 day has 4800 tenth of minute -->\r
241 <xsl:when test='@lagType="0"'><xsl:value-of select="@lag*4800"/></xsl:when> <!-- days -->\r
242 <xsl:when test='@lagType="1"'><xsl:value-of select="@lag"/></xsl:when> <!-- % -->\r
243 </xsl:choose>\r
244 </LinkLag> \r
245 <LagFormat>\r
246 <xsl:choose>\r
247 <xsl:when test='@lagType="0"'>7</xsl:when> <!-- days -->\r
248 <xsl:when test='@lagType="1"'>19</xsl:when> <!-- % -->\r
249 <xsl:otherwise>53</xsl:otherwise> <!-- null-->\r
250 </xsl:choose>\r
251 </LagFormat> \r
252 </PredecessorLink>\r
253</xsl:template>\r
254\r
255<!-- ****************************************************************** Task (Taskpredecessor) ********************** -->\r
256<!-- *** selected is that task whose PredecessorID is equal to the current sID ************************************** -->\r
257<xsl:template match="Task" mode="Taskpredecessor">\r
258 <PredecessorUID>\r
259 <xsl:value-of select="@sID"/>\r
260 </PredecessorUID>\r
261</xsl:template>\r
262\r
263<!-- ****************************************************************** PoolResource ******************************** -->\r
264<xsl:template match="PoolResources/PoolResource">\r
265 <Resource> <!-- Days exception to baseCalendar are not included -->\r
266 <UID><xsl:value-of select="@sID"/></UID>\r
267 <ID><xsl:value-of select="position()"/></ID>\r
268 <Name><xsl:value-of select="@fullName"/></Name>\r
269 <Type> <!-- Work/Equipment/Material/Expenses to Material/Work -->\r
270 <xsl:value-of select='translate(@resourceType, "0123", "1100")'/> \r
271 </Type>\r
272 <Initials><xsl:value-of select="@resourceId"/></Initials> <!-- OWB uses initials as UID when reading MSP XML -->\r
273 <CalendarUID> <!-- use resource calendar -->\r
274 <xsl:value-of select="@sId"/><xsl:value-of select="@sID+100"/>\r
275 </CalendarUID> \r
276 <Notes> <!-- MSP only allows 1 note, OWB more -->\r
277 <xsl:for-each select='Notes/Note'>\r
278 <xsl:value-of select='@content'/>\r
279 <xsl:if test='position() != last()'><xsl:text>&#xA;</xsl:text></xsl:if>\r
280 </xsl:for-each>\r
281 </Notes>\r
282 </Resource>\r
283</xsl:template>\r
284\r
285<!-- ****************************************************************** Assignment ********************************** -->\r
286<xsl:template match="Assignment">\r
287 <Assignment>\r
288 <UID><xsl:value-of select="position()"/></UID> \r
289 <TaskUID><xsl:value-of select="../../@sID"/></TaskUID>\r
290 <xsl:apply-templates select='key("KeyPoolRes",@resourceID)' mode='PoolResAss'/> <!-- ResourceID -->\r
291 <Finish><xsl:value-of select="../../@finish"/></Finish> \r
292 <Start><xsl:value-of select="../../@start"/></Start> \r
293 </Assignment>\r
294</xsl:template>\r
295\r
296<!-- ****************************************************************** PoolResource (Assignment) ******************* -->\r
297<xsl:template match="PoolResource" mode='PoolResAss'>\r
298 <ResourceUID>\r
299 <xsl:value-of select="@sID"/>\r
300 </ResourceUID>\r
301</xsl:template>\r
302\r
303</xsl:stylesheet>