none
How do I add a condition for notificationevents? RRS feed

  • Question

  • I need help to add a condition to my xslt. For all NotificationEvents, the HearingType/@Word='ACT' How do I do it? That is HearingType code must be ACT

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    	<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>
    	<xsl:template match="/">
    		<xsl:apply-templates select="Integration/Case/Hearing"/>
    	</xsl:template>
    	<xsl:template match="Hearing">
    		<!-- Set variable for Hearing ID -->
    		<xsl:variable name="vID">
    			<!--Get Hearing ID-->
    			<xsl:value-of select="@ID"/>
    		</xsl:variable>
    		<xsl:choose>
    			<xsl:when test="(@Op='A') and (HearingType/@Op='A')">
    				<NotificationEvent notificationType="PrepareHearingDocument">
    					<xsl:attribute name="elementState">New</xsl:attribute>
    					<xsl:attribute name="elementName">Hearing</xsl:attribute>
    					<xsl:attribute name="elementKey"><xsl:value-of select="$vID"/><!--Get ID equal to ID from Hearing--></xsl:attribute>
    					<xsl:text>HearingScheduled</xsl:text>
    				</NotificationEvent>
    			</xsl:when>
    			<xsl:when test="@Op='D' and count(Setting/CourtroomMinutes/HearingResult/@Word)=0">
    				<NotificationEvent notificationType="PrepareHearingDocument">
    					<xsl:attribute name="elementState">New</xsl:attribute>
    					<xsl:attribute name="elementName">Hearing</xsl:attribute>
    					<xsl:attribute name="elementKey"><xsl:value-of select="$vID"/></xsl:attribute>
    					<xsl:text>HearingDeleted</xsl:text>
    				</NotificationEvent>
    			</xsl:when>
    			<!--HearingDeleted-->
    			<xsl:when test="(@Op='E') and (string-length(CancelledReason)!=0) and (CancelledReason/@Op='E')">
    				<NotificationEvent notificationType="PrepareHearingDocument">
    					<xsl:attribute name="elementState">New</xsl:attribute>
    					<xsl:attribute name="elementName">Hearing</xsl:attribute>
    					<xsl:attribute name="elementKey"><xsl:value-of select="$vID"/></xsl:attribute>
    					<xsl:text>HearingCancelled</xsl:text>
    				</NotificationEvent>
    			</xsl:when>
    			<!--HearingCancelled-->
    			<xsl:otherwise>
    				<xsl:if test="(HearingType/@Op='E')">
    					<NotificationEvent notificationType="PrepareHearingDocument">
    						<xsl:attribute name="elementState">New</xsl:attribute>
    						<xsl:attribute name="elementName">Hearing</xsl:attribute>
    						<xsl:attribute name="elementKey"><xsl:value-of select="$vID"/></xsl:attribute>
    						<xsl:text>HearingModified</xsl:text>
    					</NotificationEvent>
    				</xsl:if>
    				<!--HearingModified-->
    				<xsl:for-each select="Setting[@Op='A']">
    					<NotificationEvent notificationType="PrepareHearingDocument">
    						<xsl:attribute name="elementState">New</xsl:attribute>
    						<xsl:attribute name="elementName">Setting</xsl:attribute>
    						<xsl:attribute name="elementKey"><xsl:value-of select="$vID"/></xsl:attribute>
    						<xsl:attribute name="subElementKey"><xsl:value-of select="@ID"/></xsl:attribute>
    						<xsl:text>SettingScheduled</xsl:text>
    					</NotificationEvent>
    				</xsl:for-each>
    				<!--SettingScheduled-->
    				<xsl:for-each select="Setting[@Op='E']">
    					<xsl:if test="string-length(RescheduledType)!=0">
    						<NotificationEvent notificationType="PrepareHearingDocument">
    							<xsl:attribute name="elementState">Existing</xsl:attribute>
    							<xsl:attribute name="elementName">Setting</xsl:attribute>
    							<xsl:attribute name="elementKey"><xsl:value-of select="$vID"/></xsl:attribute>
    							<xsl:attribute name="subElementKey"><xsl:value-of select="@ID"/></xsl:attribute>
    							<xsl:text>SettingRescheduled</xsl:text>
    						</NotificationEvent>
    					</xsl:if>
    					<!--SettingRescheduled-->
    					<xsl:choose>
    						<xsl:when test="(string-length(CancelledReason)!=0) and (CancelledReason/@Op='E')">
    							<NotificationEvent notificationType="PrepareHearingDocument">
    								<xsl:attribute name="elementState">Existing</xsl:attribute>
    								<xsl:attribute name="elementName">Setting</xsl:attribute>
    								<xsl:attribute name="elementKey"><xsl:value-of select="$vID"/></xsl:attribute>
    								<xsl:attribute name="subElementKey"><xsl:value-of select="@ID"/></xsl:attribute>
    								<xsl:text>SettingCancelled</xsl:text>
    							</NotificationEvent>
    						</xsl:when>
    						<!--SettingCancelled-->
    						<xsl:when test="(Cancelled='True') and (string-length(RescheduledReason)=0)">
    							<NotificationEvent notificationType="PrepareHearingDocument">
    								<xsl:attribute name="elementState">Existing</xsl:attribute>
    								<xsl:attribute name="elementName">Setting</xsl:attribute>
    								<xsl:attribute name="elementKey"><xsl:value-of select="$vID"/></xsl:attribute>
    								<xsl:attribute name="subElementKey"><xsl:value-of select="@ID"/></xsl:attribute>
    								<xsl:text>SettingCancelled</xsl:text>
    							</NotificationEvent>
    						</xsl:when>
    						<!--SettingCancelled-->
    						<xsl:when test="(StartTime/@Op='E') or (EndTime/@Op='E') or (InterpreterNeeded/@Op='E') or (Interpreter/@Op='E') or (CourtSessionBlock/StartTime/@Op='E') or (CourtSessionBlock/EndTime/@Op='E')">
    							<NotificationEvent notificationType="PrepareHearingDocument">
    								<xsl:attribute name="elementState">Existing</xsl:attribute>
    								<xsl:attribute name="elementName">Setting</xsl:attribute>
    								<xsl:attribute name="elementKey"><xsl:value-of select="$vID"/></xsl:attribute>
    								<xsl:attribute name="subElementKey"><xsl:value-of select="@ID"/></xsl:attribute>
    								<xsl:text>SettingModified</xsl:text>
    							</NotificationEvent>
    						</xsl:when>
    						<!--SettingModified-->
    					</xsl:choose>
    				</xsl:for-each>
    				<xsl:for-each select="Setting/CourtroomMinutes">
    					<xsl:if test="(@Op='E') and (count(*[name(.)!='HearingResult'][@Op='E'])!=0) and (string-length(HearingResult/@Op)=0)">
    						<NotificationEvent notificationType="PrepareHearingDocument">
    							<xsl:attribute name="elementState">Existing</xsl:attribute>
    							<xsl:attribute name="elementName">Setting</xsl:attribute>
    							<xsl:attribute name="elementKey"><xsl:value-of select="$vID"/></xsl:attribute>
    							<xsl:attribute name="subElementKey"><xsl:value-of select="../@ID"/></xsl:attribute>
    							<xsl:text>SettingHeldModified</xsl:text>
    						</NotificationEvent>
    					</xsl:if>
    					<!--SettingHeldModified-->
    					<!--Setting Held-->
    					<xsl:if test="((@Op='A') or (@Op='E')) and (HearingResult/@Op='E') and ((HearingResult='Held') or (HearingResult/@Word='CNVOCCUR'))">
    						<NotificationEvent notificationType="PrepareHearingDocument">
    							<xsl:attribute name="elementState">Existing</xsl:attribute>
    							<xsl:attribute name="elementName">Setting</xsl:attribute>
    							<xsl:attribute name="elementKey"><xsl:value-of select="$vID"/></xsl:attribute>
    							<xsl:attribute name="subElementKey"><xsl:value-of select="../@ID"/></xsl:attribute>
    							<!--Setting Held-->
    							<xsl:text>SettingHeld</xsl:text>
    						</NotificationEvent>
    					</xsl:if>
    					<!--SettingHeld-->
    					<xsl:if test="(@Op='D')">
    						<NotificationEvent notificationType="PrepareHearingDocument">
    							<xsl:attribute name="elementState">Existing</xsl:attribute>
    							<xsl:attribute name="elementName">Setting</xsl:attribute>
    							<xsl:attribute name="elementKey"><xsl:value-of select="$vID"/></xsl:attribute>
    							<xsl:attribute name="subElementKey"><xsl:value-of select="../@ID"/></xsl:attribute>
    							<xsl:text>SettingHeldReversed</xsl:text>
    						</NotificationEvent>
    					</xsl:if>
    					<!--SettingHeldReversed-->
    				</xsl:for-each>
    			</xsl:otherwise>
    		</xsl:choose>
    	</xsl:template>
    </xsl:stylesheet>


    • Edited by winkimjr2 Thursday, February 7, 2019 5:06 PM
    Thursday, February 7, 2019 5:02 PM

All replies

  • Hi winkimjr2,

    To help you, we need to know the HearingType/@Word='ACT' context.

    Please provide sample source XML to transform.

    Just guessing your source XML structure, you need to make the following single change to the main XSLT template:

    <xsl:template match="/">
    	<xsl:apply-templates select="Integration/Case/Hearing[HearingType/@Word='ACT']"/>
    </xsl:template>

    Thursday, February 7, 2019 10:15 PM
  • Hi winkimjr2,

    What's the latest?

    Did the proposed solution fix the issue?

    Please mark the post via 'Mark as answer' to let others know that it worked.

    Tuesday, February 12, 2019 9:20 PM
  • Sorry it took a while to respond. Your solution worked! Thanks
    Tuesday, March 12, 2019 12:59 PM
  • Hi winkimjr2,

    I am glad that the proposed solution is working for you.

    Please don't forget to "Mark as Answer".

    Tuesday, March 12, 2019 1:58 PM