XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Romie BehuninSubject: Map field if source is not null
Author: Romie Behunin
Date: 18 Jun 2009 06:07 PM
Hey guys...
I'm pretty new to this tool so please forgive me for my ignorance. I'm using the XSLT mapper to map a field to a destination field IF the value of the field is not null. Otherwise I want to insert the current date and time in the destination field. I understand how to obtain the current date and time in my destination field by setting the text value but I'm having difficulty with the IF function as I guess I don't completely understand how to work it. Any direction is greatly appreciated! Thanks~!!

Romie

Postnext
(Deleted User) Subject: Map field if source is not null
Author: (Deleted User)
Date: 19 Jun 2009 10:45 AM
Hi Romie,
the IF function in XSLT doesn't have a "ELSE" statement, so it can only be used to generate an output if the source is not empty. If you want do perform a different operation when the condition is false you need to use the CHOOSE instruction.
For example,
- right click on the canvas and pick XSLT Instructions -> choose;
- drag a link from the element you want to test to the left port of the "choose" block
- drag a link from the top right port of th e"choose" block to the desired target element (this will be the path when the condition is true)
- drag a link from the bottom right (square) port of the "choose" port to the desired target element (this will be the "otherwise" condition, when all the tests of the "choose" fail)
- now drag links from the source tree to the two different target elements in order to fill them with values.

If the target element created by the "choose" block is the same, you will have to duplicate it by right clicking on it and choosing Duplicate Node

Hope this helps,
Alberto

Posttop
Romie BehuninSubject: Map field if source is not null
Author: Romie Behunin
Date: 19 Jun 2009 11:26 AM
Hey Alberto,
Thanks for the assistance. I've read a number of your posts and your experience is very helpful! After doing some trial and error work and testing on this I realized that the value would never be null... but rather possibly = ''. I gave up using the GUI to try this (because of my inexperience with it) and inserted my own code like this:

<OBR>
- <OBR.7>
- <xsl:if test="HL7/ORU_R01/OBR/OBR.7 != ''">
<xsl:value-of select="HL7/ORU_R01/OBR/OBR.7" />
</xsl:if>
- <xsl:if test="HL7/ORU_R01/OBR/OBR.7 = ''">
<xsl:value-of select="format-dateTime(current-dateTime(),'[Y0001][M01][D01][H02][M02]')" />
</xsl:if>
</OBR.7>
</OBR>

It seems to be working the way I intended so far. I was suprised to see how the GUI mapped this out but it gave me a better understanding what the flow port is for. I'm going to practice with the choose function as well per your suggestions.

Thanks again!!
Romie

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.