Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 12th, 2014, 01:02 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default How do I concatenate HearingDate and StartTime?

How do I get this result:
<ext:HearingDateTime>07/21/2014 8:30 AM</ext:HearingDateTime>
I have xml that have two StartTime and a HearingDate. The two StartTime are the same but one is near the top and the other one is a child of CourtSessionBlock.
The first StartTime is not always there which means sometimes the only available StartTime is the child of CourtSessionBlock.
For this reason, I need to first check if there is StartTime near the top of xml document. If it is there, I will use that StartTime concatenated with HearingDate. Otherwise if it's not there or when the only StartTime is the child of CourtSessionBlock, I will use that one. I have tried using <xsl:if> and <xsl:choose> but I am not getting anything displayed for the <ext:HearingDateTime/>. Please help.
Here is my xml code:
Code:
<Setting ID="21613643" InternalSettingID="1622304543" Date="07/21/2014">
	<HearingDate>07/21/2014</HearingDate>
	<StartTime>8:30 AM</StartTime>
	<EndTime>9:30 AM</EndTime>
	<CourtSessionBlock InternalCourtSessionBlockID="1614615037">
		<StartTime>8:30 AM</StartTime>
		<EndTime>9:30 AM</EndTime>
	</CourtSessionBlock>
	<TimestampCreate>07/15/2014 09:27:49:607</TimestampCreate>
</Setting>
I removed the xslt code. Based on this xml how can I check to see if the first StartTime is present and use it otherwise check to see if there is StartTime as a child of CourtSessionBlock?

Last edited by winkimjr2; August 13th, 2014 at 09:47 AM..
 
Old August 13th, 2014, 06:58 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your paths are wrong. It's hard to tell exactly how wrong, because they refer to elements Integration and Case which you haven't shown us, and also we can't see what the context item for your XSLT code fragment is, but at the very least I would expect the path in the first xsl:value of to be the same as the path in the first xsl:when. And there seems a disagreement between the two branches as to whether it is /Integration/Case/Setting or /Integration/Case/Hearing/Setting.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
winkimjr2 (August 13th, 2014)
 
Old August 13th, 2014, 09:50 AM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default

Thanks for pointing out the paths. I did for security reasons remove other elements from my xml before posting. My question to you now is based on the xml I have posted here, how can I check to see if the first StartTime is present and use it otherwise check to see if there is StartTime as a child of CourtSessionBlock?
If you can help me with this, I am sure I will be able to figure out the xpath.
 
Old August 13th, 2014, 10:01 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The simplest logic is to write

(path1 | path2) [1]

which will select the first item selected by either path1 or path2, in document order.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I check to see if StartTime exist before using it? winkimjr2 XSLT 0 August 11th, 2014 10:39 AM
Concatenate xsltstarter XSLT 3 March 28th, 2014 05:40 AM
Concatenate help lryckman Access VBA 3 October 12th, 2009 08:52 AM
concatenate records davehodges Access 5 November 1st, 2007 10:13 AM
Hyperlink (Concatenate) JEHalm Excel VBA 1 January 11th, 2006 01:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.