Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML XSL formatting 1

Status
Not open for further replies.

mayamanako

Technical User
Aug 31, 2005
113
0
0
GB
Hi guys,

I have an XML code below

the XML code
Code:
.
.
.
<s:timesSessionType sessionType="surgery">
- <s:daysOfWeek>
- <s:dayOfWeek>
  <s:dayName>Sunday</s:dayName> 
- <s:timesSessions>
  <s:timesSession>Closed</s:timesSession> 
  </s:timesSessions>
  </s:dayOfWeek>
- <s:dayOfWeek>
  <s:dayName>Monday</s:dayName> 
- <s:timesSessions>
- <s:timesSession>
  <s:fromTime>08:00</s:fromTime> 
  <s:toTime>20:30</s:toTime> 
  </s:timesSession>
  </s:timesSessions>
  </s:dayOfWeek>
- <s:dayOfWeek>
  <s:dayName>Tuesday</s:dayName> 
- <s:timesSessions>
- <s:timesSession>
  <s:fromTime>08:00</s:fromTime> 
  <s:toTime>18:30</s:toTime> 
  </s:timesSession>
  </s:timesSessions>
  </s:dayOfWeek>
- <s:dayOfWeek>
  <s:dayName>Wednesday</s:dayName> 
- <s:timesSessions>
- <s:timesSession>
  <s:fromTime>08:00</s:fromTime> 
  <s:toTime>20:30</s:toTime> 
  </s:timesSession>
  </s:timesSessions>
  </s:dayOfWeek>
- <s:dayOfWeek>
  <s:dayName>Thursday</s:dayName> 
- <s:timesSessions>
- <s:timesSession>
  <s:fromTime>08:00</s:fromTime> 
  <s:toTime>18:30</s:toTime> 
  </s:timesSession>
  </s:timesSessions>
  </s:dayOfWeek>
- <s:dayOfWeek>
  <s:dayName>Friday</s:dayName> 
- <s:timesSessions>
- <s:timesSession>
  <s:fromTime>08:00</s:fromTime> 
  <s:toTime>18:30</s:toTime> 
  </s:timesSession>
  </s:timesSessions>
  </s:dayOfWeek>
- <s:dayOfWeek>
  <s:dayName>Saturday</s:dayName> 
- <s:timesSessions>
  <s:timesSession>Closed</s:timesSession> 
  </s:timesSessions>
  </s:dayOfWeek>
  </s:daysOfWeek>
  </s:timesSessionType>
.
.
.

how do I format it from

Code:
SundayClosed
Monday08:0020:30
Tuesday08:0018:30
Wednesday08:0020:30
Thursday08:0018:30
Friday08:0018:30
SaturdayClosed

to this? Thanks for any inputs.

Code:
Sunday: Closed
Monday: 08:00-20:30
Tuesday: 08:00-18:30
Wednesday: 08:00-20:30
Thursday: 08:00-18:30
Friday: 08:00-18:30
Saturday: Closed

my XSL is like this:
Code:
<xsl:for-each select="./a:content/s:overview/s:openingTimes/s:timesSessionTypes/s:timesSessionType[@sessionType='surgery']/s:daysOfWeek/s:dayOfWeek">
				<xsl:value-of select="."/><br/>
			</xsl:for-each>

 
Something along these lines:
Code:
<xsl:for-each ...>
[indent]<xsl:choose>
<xsl:when test="normalize-space(s:timesSessions/s:timesSession/text()[1]) = 'Closed'">
<xsl:value-of select="concat(s:dayName, ': Closed')"/><br/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(s:dayName, ': ', 
			     s:timesSessions/s:timesSession/s:fromTime,' - ',
			     s:timesSessions/s:timesSession/s:toTime)"/><br/>
	
</xsl:otherwise>
</xsl:choose>[/indent]
</xsl:for-each>

Tom Morrison
Hill Country Software
 
Hi K5tm,

That's AWESOME!

Thanks very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top