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: 53

How do I display timeServed in xsl transformation based on x

Fri Jun 27, 2014 5:13 pm

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: 2443

Re: How do I display timeServed in xsl transformation based

Fri Jun 27, 2014 6:05 pm

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: 53

Re: How do I display timeServed in xsl transformation based

Fri Jun 27, 2014 6:16 pm

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

Return to “General XML Questions”

Who is online

Users browsing this forum: No registered users and 2 guests