Jump to content

How do I use variable in select statement to get a value?


winkimjr2

Recommended Posts

I would like to use variable vCurrentPoStatus in the select statement below. The following select is not returning anything.



<xsl:value-of select="Type/@Word"/>



I would like to use variable vCurrentPoStatus inside this statement to get the @Word (DISMISSED).

Desired output based on current xml document




<NotificationEvent notificationType="ProtectionOrderInactivation" internalProtectionOrderID="11271" protectionOrderNumber="1605935" protectionOrderStatusDate="07/21/2016" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">DISMISSED</NotificationEvent>




xslt 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="ProtectionOrderInactivation"/>
</xsl:if>
</xsl:template>
<!-- -->
<xsl:template name="ProtectionOrderInactivation">
<xsl:if test="Integration/ControlPoint='SAVE-PROTECTION-ORDER'">
<!-- Check for Dismissed -->
<xsl:if test="Integration/Case/CaseType/@Word='DMA'">
<xsl:variable name="vControlPointTimestamp" select="mscef:formatDateTimeNumeric(string(/Integration/ControlPoint/@Timestamp))"/>
<xsl:for-each select="Integration/ProtectionOrder[@Op='E']/Statuses/Status[((@Op='A') or (@Op='E')) and ((Type/@Word='DISMISSED'))]">
<xsl:variable name="vCurrentPoStatus" select="Statuses/Status[((@Op='A') or (@Op='E'))][mscef:formatDateTimeNumeric(mscef:fixOdysseyTimestamp(string(TimestampCreate))) <=$vControlPointTimestamp][1]/Type/@Word"/>
<xsl:if test="$vCurrentPoStatus ='DISMISSED'">
<NotificationEvent notificationType="ProtectionOrderInactivation">
<xsl:attribute name="internalProtectionOrderID"><xsl:value-of select="../../@InternalProtectionOrderID"/></xsl:attribute>
<xsl:attribute name="protectionOrderNumber"><xsl:value-of select="../../ProtectionOrderNumber"/></xsl:attribute>
<xsl:attribute name="protectionOrderStatusDate"><xsl:value-of select="Date"/></xsl:attribute>
<xsl:value-of select="Type/@Word"/>
</NotificationEvent>
</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 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 doc



<Integration MessageGUID="79e1bb27-0a4d-47ec-a554-3b59c2518b89" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" PackageID="IXML Case Notification Test" MessageID="96" xmlns="">
<ControlPoint Timestamp="7/21/2016 9:49:13 AM" UserID="tessing">SAVE-PROTECTION-ORDER</ControlPoint>
<Case InternalID="1623057636" ID="14870832" xmlns:user="http://tylertechnologies.com">
<FiledDate>07/21/2016</FiledDate>
<CaseCategory>FAM</CaseCategory>
<CaseType Word="DMA">Domestic Abuse</CaseType>
<SecurityGroup Word="CONFPOR">Conf - Protective Order</SecurityGroup>
<ProtectionOrders>
<ProtectionOrder Op="E" InternalProtectionOrderID="11271">
<Deleted>false</Deleted>
<ProtectionOrderNumber>1605935</ProtectionOrderNumber>
<Issued>07/21/2016</Issued>
<Expiration>10/29/2016</Expiration>
<Type Word="OFP">Order for Protection</Type>
<Statuses>
<Status Op="A">
<Current>true</Current>
<Active>No</Active>
<Date Op="A">07/21/2016</Date>
<Type Op="A" Word="DISMISSED">Dismissed</Type>
<TimestampCreate Op="A">07/21/2016 09:49:13:763</TimestampCreate>
</Status>
<Status>
<Current>false</Current>
<Active>Yes</Active>
<Date>07/21/2016</Date>
<Type Word="SBJOCOR">Corrected - Signed By Judicial Officer</Type>
<TimestampCreate>07/21/2016 09:48:58:313</TimestampCreate>
</Status>
</Statuses>
</ProtectionOrder>
</ProtectionOrders>
</Case>
<Fees xmlns:user="http://tylertechnologies.com"/>
<ProtectionOrder Op="E" InternalProtectionOrderID="11271" xmlns:user="http://tylertechnologies.com">
<Deleted>false</Deleted>
<ProtectionOrderNumber>1605935</ProtectionOrderNumber>
<Issued>07/21/2016</Issued>
<Expiration>10/29/2016</Expiration>
<Type Word="OFP">Order for Protection</Type>
<Statuses>
<Status Op="A">
<Current>true</Current>
<Active>No</Active>
<Date Op="A">07/21/2016</Date>
<Type Op="A" Word="DISMISSED">Dismissed</Type>
<TimestampCreate Op="A">07/21/2016 09:49:13:763</TimestampCreate>
</Status>
<Status>
<Current>false</Current>
<Active>Yes</Active>
<Date>07/21/2016</Date>
<Type Word="SBJOCOR">Corrected - Signed By Judicial Officer</Type>
<TimestampCreate>07/21/2016 09:48:58:313</TimestampCreate>
</Status>
</Statuses>
</ProtectionOrder>
</Integration>


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...