How do I display timeServed in xsl transformation based on x

Questions about XML that are not covered by the other forums should go here.
winkimjr2
Posts: 62
Joined: Thu Jun 26, 2014 9:00 pm

How do I display timeServed in xsl transformation based on x

Post by winkimjr2 »

How do I use when to display nothing if timeServed="8:25 AM" is not provided in xml document? Right now it is displaying time because there is time in xml. What do I do so when there is no timeServed nothing is displayed?
My xml

Code: Select all

<xsl:template match="NotificationEvent[@notificationType='ProtectionOrderService']">
<ext:ProtectionOrderService>
<ext:ProtectionOrderServiceTime>
<xsl:value-of select="mscef:formatTime(concat(@dateServed,' ',@timeServed))"/>
</ext:ProtectionOrderServiceTime>
</ext:ProtectionOrderService>
</xsl:template>
my xsl

Code: Select all

<NotificationEvent notificationType="ProtectionOrderService" timeServed="8:25 AM" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"></NotificationEvent>
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: How do I display timeServed in xsl transformation based

Post by adrian »

See here example 2:
http://www.w3schools.com/xsl/el_when.asp
So for your case:

Code: Select all

<xsl:when test="@timeServed">
...
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
winkimjr2
Posts: 62
Joined: Thu Jun 26, 2014 9:00 pm

Re: How do I display timeServed in xsl transformation based

Post by winkimjr2 »

adrian wrote:See here example 2:
http://www.w3schools.com/xsl/el_when.asp
So for your case:

Code: Select all

<xsl:when test="@timeServed">
...
Regards,
Adrian
It is now working but I used if instead. Thanks for your help
Post Reply