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 July 20th, 2016, 10:47 AM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default How do I use my variable to get ProtectionOrderNumber?

I am using a variable vPoID to determine the right ProtectionOrder. Then I am displaying that PO's @InternalProtectionOrderID.

I would also like to use the same variable to get that PO's ProtectionOrderNumber.

How can I use the same variable to also get ProtectionOrderNumber?

Expected output
Code:
<NotificationEvent notificationType="ProtectionOrderHearing" internalProtectionOrderID="2552" protectionOrderNumber="1600330"/>

xslt code
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:mscef="courts.state.mn.us/extfun" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<xsl:if test="Integration/Case/SecurityGroup[not(contains(@Word,'SEAL'))] or not(Integration/Case/SecurityGroup)">
			<xsl:call-template name="ProtectionOrderHearing"/>
		</xsl:if>
	</xsl:template>
	<!--  -->
	<xsl:template name="ProtectionOrderHearing">
		<!--<xsl:if test="Integration/ControlPoint='SAVE-FAM-HEARING'">-->
		<xsl:if test="Integration/ControlPoint=('SAVE-FAM-HEARING') or ('SAVE-FAM-HEAR-CTS')">
			<xsl:if test="Integration/Case/CaseType/@Word='DMA'">
				<xsl:for-each select="Integration/Case">
					<xsl:variable name="vFoundActivePO">
						<xsl:for-each select="/Integration/ProtectionOrder[Deleted='false']">
							<xsl:variable name="vControlPointTimestamp" select="mscef:formatDateTimeNumeric(string(/Integration/ControlPoint/@Timestamp))"/>
							<xsl:variable name="vCurrentPoStatus" select="Statuses/Status[mscef:formatDateTimeNumeric(mscef:fixOdysseyTimestamp(string(TimestampCreate))) &lt;=$vControlPointTimestamp][1]/Type/@Word"/>
							<xsl:if test="($vCurrentPoStatus ='SBJO') or ($vCurrentPoStatus='SBJOCOR')">HIT</xsl:if>
						</xsl:for-each>
					</xsl:variable>
					<xsl:variable name="vFoundHearingTrigger">
						<xsl:choose>
							<xsl:when test="count(Hearing[@Op='A'])>0">HIT</xsl:when>
							<xsl:when test="count(Hearing[@Op='D'])>0">HIT</xsl:when>
							<xsl:when test="count(Hearing[(@Op='E') and (CancelledReason/@Op='E')])>0">HIT</xsl:when>
							<xsl:when test="count(Hearing[(@Op='E') and (Setting/HearingDate/@Op='E')])>0">HIT</xsl:when>
							<xsl:when test="count(Hearing[(@Op='E') and (Setting/CourtSessionBlock/StartTime/@Op='E')])>0">HIT</xsl:when>
							<xsl:when test="count(Hearing/Setting[@Op='A'])>0">HIT</xsl:when>
							<xsl:when test="count(Hearing[(@Op='E') and (Setting/RescheduledType/@Op='E')])>0">HIT</xsl:when>
							<xsl:when test="count(Hearing[(@Op='E') and (Setting/CancelledReason/@Op='E')])>0">HIT</xsl:when>
							<xsl:when test="count(Hearing[(@Op='E') and (Setting/CourtSessionBlock/StartTime/@Op='E')])>0">HIT</xsl:when>
						</xsl:choose>
					</xsl:variable>
					<xsl:if test="(contains($vFoundHearingTrigger,'HIT')) and (contains($vFoundActivePO,'HIT'))">
						<xsl:choose>
							<xsl:when test="count(Hearing/Setting[not(Cancelled)])>0">
								<xsl:for-each select="Hearing/Setting[not(Cancelled)]">
									<!-- WK 07/19/2016-->
									<xsl:variable name="vCurrentTimestamp">
										<xsl:value-of select="mscef:formatDateTimeNumeric(string(/Integration/ControlPoint/@Timestamp))"/>
									</xsl:variable>
									<xsl:variable name="vControlPointTimestamp" select="mscef:formatDateTimeNumeric(string(/Integration/ControlPoint/@Timestamp))"/>
									<!--WK 07/19/2016 variable to hold ProtectionOrders that have not been deleted-->
									<xsl:variable name="vPoID">
										<!--WK 07/19/2016 Select all ProtectionOrder elements from the document that are not deleted-->
										<xsl:for-each select="//Integration/ProtectionOrder[Deleted='false']">
											<xsl:variable name="vCurrentPoStatus" select="Statuses/Status[mscef:formatDateTimeNumeric(mscef:fixOdysseyTimestamp(string(TimestampCreate))) &lt;=$vCurrentTimestamp][1]/Type/@Word"/>
											<xsl:if test="($vCurrentPoStatus ='SBJO') or ($vCurrentPoStatus='SBJOCOR')">
												<xsl:value-of select="@InternalProtectionOrderID"/>
											</xsl:if>
										</xsl:for-each>
									</xsl:variable>
									<NotificationEvent notificationType="ProtectionOrderHearing">
										<!--WK 07/19/2016 variable vPoID to get the right PO's attribute @InternalProtectionOrderID>-->
										<xsl:attribute name="internalProtectionOrderID"><xsl:value-of select="$vPoID"/></xsl:attribute>
										<xsl:attribute name="protectionOrderNumber"><xsl:value-of select="ProtectionOrderNumber"/></xsl:attribute>
									</NotificationEvent>
								</xsl:for-each>
							</xsl:when>
							<xsl:otherwise>
								<NotificationEvent notificationType="ProtectionOrderHearing">
									<xsl:attribute name="internalProtectionOrderID"><xsl:value-of select="//Integration/ProtectionOrder[Deleted='false'][count(Statuses/Status[(Type/@Word='SBJO') or (Type/@Word='SBJOCOR')])>0]/@InternalProtectionOrderID"/></xsl:attribute>
									<xsl:attribute name="protectionOrderNumber"><xsl:value-of select="//Integration/ProtectionOrder[Deleted='false'][count(Statuses/Status[(Current='true') and ((Type/@Word='SBJO') or (Type/@Word='SBJOCOR'))])>0]/ProtectionOrderNumber"/><xsl:value-of select="//Integration/ProtectionOrder[Deleted='false'][count(Statuses/Status[(Type/@Word='SBJO') or (Type/@Word='SBJOCOR')])>0]/ProtectionOrderNumber"/></xsl:attribute>
									<xsl:text>NoHearings</xsl:text>
								</NotificationEvent>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:if>
				</xsl:for-each>
			</xsl:if>
		</xsl:if>
	</xsl:template>
	<!--  -->
	<msxsl:script language="JScript" implements-prefix="mscef"><![CDATA[
		function formatDateTimeNumeric(sDate){
			if(sDate.length==0){
				return "";
			}
			else{
				var oDate=new Date(sDate);
				var str = oDate.getSeconds();
				return "" + oDate.getFullYear().toString() + padZeroes(oDate.getMonth() + 1,2) + padZeroes(oDate.getDate(),2) + padZeroes(oDate.getHours().toString(),2) + padZeroes(oDate.getMinutes(),2) + padZeroes(oDate.getSeconds(),2);  			
			}
		}
		function currentDateTimeNumeric(){
				var oDate=new Date();
				var str = oDate.getSeconds();
				return "" + oDate.getFullYear().toString() + padZeroes(oDate.getMonth() + 1,2) + padZeroes(oDate.getDate(),2) + padZeroes(oDate.getHours().toString(),2) + padZeroes(oDate.getMinutes(),2) + padZeroes(oDate.getSeconds(),2);  			
		}	
		
		function fixOdysseyTimestamp(sDate){
		/* Replace the ":" between seconds and miliseconds */
			if(sDate.length==0){
				return "";
			}
			else{
				var strParts1 = sDate.split(" ");
				var strTime = strParts1[1];
				var strParts2 = strTime.split(":");
				return strParts1[0] + " " + strParts2[0] + ":" + strParts2[1] + ":" + strParts2[2];
			}
		}
]]></msxsl:script>
</xsl:stylesheet>

xml document
Code:
<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" PackageID="BCA PO Notification" MessageID="82119264" xmlns="">
	<ControlPoint Timestamp="7/14/2016 9:00:52 AM">SAVE-FAM-HEARING</ControlPoint>
	<Case>
		<FiledDate>07/14/2016</FiledDate>
		<CaseCategory>FAM</CaseCategory>
		<CaseType Word="DMA">Domestic Abuse</CaseType>
		<BaseCaseType>Civil Domestic Violence</BaseCaseType>
		<SecurityGroup Word="CONFPOR">Conf - Protective Order</SecurityGroup>
		<Active>true</Active>
		<Deleted>false</Deleted>
		<Assignment Current="true">
			<AssignmentDate>07/14/2016</AssignmentDate>
			<TimestampCreate>07/14/2016 08:56:32:707</TimestampCreate>
		</Assignment>
		<Hearing ID="175088126" InternalHearingEventID="1734552990">
			<HearingType Word="ADJ">Adjudicatory Hearing</HearingType>
			<HearingTypeBaseCaseCategory>Criminal</HearingTypeBaseCaseCategory>
			<HearingTypeBaseCaseCategory>Family</HearingTypeBaseCaseCategory>
			<TimestampCreate>07/14/2016 08:58:22:160</TimestampCreate>
			<Setting ID="25760837" InternalSettingID="1625564128" Date="07/14/2016">
				<HearingDate>07/14/2016</HearingDate>
				<StartTime>10:00 AM</StartTime>
				<EndTime>11:00 AM</EndTime>
				<CourtSessionName>Ad-Hoc_10-FA-16-40</CourtSessionName>
				<CourtSessionID ID="3862219" InternalCourtSessionID="1612936893"/>
				<Calendar Word="10GEN">New General Carver</Calendar>
				<CalendarBaseCaseCategory>Criminal</CalendarBaseCaseCategory>
				<CalendarBaseCaseCategory>Civil</CalendarBaseCaseCategory>
				<CalendarBaseCaseCategory>Family</CalendarBaseCaseCategory>
				<CalendarBaseCaseCategory>Probate or Mental Health</CalendarBaseCaseCategory>
				<CourtSessionBlock InternalCourtSessionBlockID="1615773709">
					<StartTime>10:00 AM</StartTime>
					<EndTime>11:00 AM</EndTime>
				</CourtSessionBlock>
				<TimestampCreate>07/14/2016 08:58:23:240</TimestampCreate>
			</Setting>
		</Hearing>
		<Hearing ID="175088128" InternalHearingEventID="1734552992" Op="A">
			<HearingType Op="A" Word="OFP">Order for Protection Hearing</HearingType>
			<HearingTypeBaseCaseCategory>Family</HearingTypeBaseCaseCategory>
			<TimestampCreate Op="A">07/14/2016 09:00:52:680</TimestampCreate>
			<Setting ID="25760838" InternalSettingID="1625564129" Date="07/14/2016" Op="A">
				<HearingDate Op="A">07/14/2016</HearingDate>
				<StartTime Op="A">2:00 PM</StartTime>
				<EndTime Op="A">3:00 PM</EndTime>
				<CourtSessionName>Ad-Hoc_10-FA-16-40</CourtSessionName>
				<CourtSessionID Op="A" ID="3862221" InternalCourtSessionID="1612936894"/>
				<Calendar Op="A" Word="10GEN">New General Carver</Calendar>
				<CalendarBaseCaseCategory>Criminal</CalendarBaseCaseCategory>
				<CalendarBaseCaseCategory>Civil</CalendarBaseCaseCategory>
				<CalendarBaseCaseCategory>Family</CalendarBaseCaseCategory>
				<CalendarBaseCaseCategory>Probate or Mental Health</CalendarBaseCaseCategory>
				<CourtSessionBlock InternalCourtSessionBlockID="1615773710">
					<StartTime Op="A">2:00 PM</StartTime>
					<EndTime Op="A">3:00 PM</EndTime>
				</CourtSessionBlock>
				<TimestampCreate Op="A">07/14/2016 09:00:52:767</TimestampCreate>
			</Setting>
		</Hearing>
		</Case>
	<ProtectionOrder InternalProtectionOrderID="2551" xmlns:user="http://tylertechnologies.com">
		<Deleted>false</Deleted>
		<ProtectionOrderNumber>1600329</ProtectionOrderNumber>
		<Type Word="EXPARTE">Ex Parte Order for Protection</Type>
		<Statuses>
			<Status>
				<Current>true</Current>
				<Active>No</Active>
				<Date>07/14/2016</Date>
				<Type Word="SUPERSEDED">Superseded</Type>
				<TimestampCreate>07/14/2016 09:00:25:510</TimestampCreate>
			</Status>
	</ProtectionOrder>
	<ProtectionOrder InternalProtectionOrderID="2552" xmlns:user="http://tylertechnologies.com">
		<Deleted>false</Deleted>
		<ProtectionOrderNumber>1600330</ProtectionOrderNumber>
		<Type Word="EXPARTE">Ex Parte Order for Protection</Type>
		<Statuses>
			<Status>
				<Current>true</Current>
				<Active>Yes</Active>
				<Date>07/14/2016</Date>
				<Type Word="SBJO">Signed By Judicial Officer</Type>
				<TimestampCreate>07/14/2016 09:00:25:547</TimestampCreate>
			</Status>
		</Statuses>
	</ProtectionOrder>
</Integration>
 
Old July 20th, 2016, 03:32 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default This is done

I have resolved this





Similar Threads
Thread Thread Starter Forum Replies Last Post
Object variable or With block variable not set I_Chappers ASP.NET 2.0 Basics 3 June 26th, 2008 04:15 PM
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
assign javascript variable to asp variable manjunath_c_k Classic ASP Basics 1 September 14th, 2006 07:35 AM
Object variable or with block variable not set netfresher VS.NET 2002/2003 0 July 10th, 2006 02:44 AM





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