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 June 13th, 2016, 12:58 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default

I have revised my question.
I would like to get the Status whose TimestampCreate matches the ControlPoint Timestamp.

My xml 1.0 code
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Integration>
	<ControlPoint Timestamp="5/9/2016 2:34:34 PM" UserID="Kuku">SAVE</ControlPoint>
	<ProtectionOrders>
		<ProtectionOrder Op="E" InternalProtectionOrderID="11831">
			<Statuses>
				<Status>
					<Current>true</Current>
					<Active>No</Active>
					<Date>05/09/2016</Date>
					<Type Word="DISMISSED">Dismissed</Type>
					<TimestampCreate Op="A">05/09/2016 14:34:48:633</TimestampCreate>
				</Status>
				<Status Op="A">
					<Current>false</Current>
					<Active>Yes</Active>
					<Date Op="A">05/09/2016</Date>
					<Type Op="A" Word="SBJO">Signed By Judicial Officer</Type>
					<TimestampCreate>05/09/2016 14:34:34:737</TimestampCreate>
				</Status>
				<Status>
					<Current>false</Current>
					<Active>No</Active>
					<Date>12/30/2014</Date>
					<Type Word="DRAFT">Draft</Type>
					<TimestampCreate>05/09/2016 14:34:14:987</TimestampCreate>
				</Status>
			</Statuses>
		</ProtectionOrder>
	</ProtectionOrders>
</Integration>
I am not sure how to change my xslt code

I am using a function to convert date time to a number. I am not sure how then to compare the Status TimestampCreate to ControlPoint Timestamp and select the Status TimestampCreate that matches ControlPoint Timestamp.

xslt 1.0 code
Code:
<ProtectionOrderStatus>
		<ProtectionOrderStatusDate>
			<xsl:value-of select="mscef:formatDate(string(Statuses/Status/Date))"/>
		</ProtectionOrderStatusDate>
</ProtectionOrderStatus>
Here is my function to convert Status TimestampCreate and ControlPoint Timestamp to numeric
Code:
<xsl:value-of select="mscef:formatDateTimeNumeric(mscef:fixOdysseyTimestamp(string(TimeStampCreate)))"/>

Last edited by winkimjr2; June 15th, 2016 at 12:11 PM.. Reason: Added complete path for status date which is what I want to change to use TimestampCreate instead
 
Old June 13th, 2016, 01:05 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Well, first we need to know whether 05/09/2016 is 9th May or 5th September. In most of the world it's 5th September, but the US has its own peculiar ideosyncracies.

Really you would be much better off switching to international standard date time representation, that is 2016-09-05T14:34:48.633. If you do that sorting becomes trivial. If you don't do that, then you need to write a lot of messy code using concat and substring to reformat the date before you can sort it.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old June 13th, 2016, 01:17 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by mhkay View Post
Well, first we need to know whether 05/09/2016 is 9th May or 5th September. In most of the world it's 5th September, but the US has its own peculiar ideosyncracies.

Really you would be much better off switching to international standard date time representation, that is 2016-09-05T14:34:48.633. If you do that sorting becomes trivial. If you don't do that, then you need to write a lot of messy code using concat and substring to reformat the date before you can sort it.
The date is May 9th 2016. How do I switch to international standard date time representation? I have a function I can use which will format date time to something like this 20160509143434

Here is the code using my function used in the following code
Code:
<xsl:variable name="vTimeStampCreate" select="/Integration/ProtectionOrder[@InternalProtectionOrderID=$pProtectionOrderID]/Statuses/Status[Current='true']/TimestampCreate"/>
				<ext:ProtectionOrderStatusDate>
xsl:value-of select="mscef:formatDateTimeNumeric(mscef:fixOdysseyTimestamp(string($vTimeStampCreate)))"/>
</ext:ProtectionOrderStatusDate>
			</ext:ProtectionOrderStatus>

Last edited by winkimjr2; June 13th, 2016 at 01:22 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving Second Latest Time eusanpe SQL Server 2005 1 September 20th, 2010 06:48 PM
Where can I download the latest version (2.1?) from Gabor66 BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 5 November 5th, 2009 02:14 PM
latest version crmpicco Beginning VB 6 8 March 24th, 2005 03:51 PM
What's the latest C# edition? Daemon BOOK: ASP.NET Website Programming Problem-Design-Solution 1 January 18th, 2004 05:53 PM





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