如何获得正确的元素? [英] How do I get the correct elements?

查看:155
本文介绍了如何获得正确的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经添加了xslt选择器逻辑以进行尝试并需要帮助.
请帮助我.

这是我要添加到选择器(xslt)中的内容
对于每个带有ChargeHistory Op ="A"和Stage ="Disposition Event"的Charge,请确定是否基于Integration/Citation/Vehicle/VehicleType/@ Word = ATV或BOAT或SNOWMO的车辆类型以及OffenseType @ Word = ST和OffenseStatute不等于前3个字符为169的StatuteCode或8491的4个字符或86B331的前6个字符的StatuteCode.
有人可以帮我吗?提前谢谢.

这是xml文档

I have added xslt selector logic of what I am trying to do and need help with.
Kindly help me.

Here is what I am trying to add to the selector (xslt)
For each Charge with ChargeHistory Op="A" and Stage="Disposition Event", find if the vehicle type based on Integration/Citation/Vehicle/VehicleType/@Word =ATV or BOAT or SNOWMO AND the OffenseType @ Word = ST AND the OffenseStatute is not equal to a StatuteCode with first 3 characters of 169 OR the 4 characters of 8491 OR the first 6 characters of 86B331.
Could someone help me with this? Thanks in advance.

Here is the xml document

<Integration>
	<Case>
		<Charge Op="E" ID="13689714" InternalChargeID="1623159393" InternalPartyID="1617894767">
			<Vehicle>
				<VehicleType Word="BOAT">Motorboat</VehicleType>
			</Vehicle>
			<ChargeHistory Op="A" ChargeHistoryID="53525890" Stage="Disposition Event" CurrentCharge="true">
				<ChargeNumber Op="A">1</ChargeNumber>
				<Statute>
					<StatuteNumber Op="A">97C.401.2</StatuteNumber>
					<StatuteCode Op="A" Word="97C4012" InternalCodeID="110850">Fish and Game<CodeMapping>
						</CodeMapping>
					</StatuteCode>
					<OffenseType Word="ST">Statute</OffenseType>
				</Statute>
			</ChargeHistory>
		</Charge>
		<Charge Op="E" ID="13689715" InternalChargeID="1623159394" InternalPartyID="1617894767">
			<Vehicle>
				<VehicleType Word="BOAT">Motorboat</VehicleType>
			</Vehicle>
			<ChargeHistory Op="A" ChargeHistoryID="53525891" Stage="Disposition Event" CurrentCharge="true">
				<ChargeNumber Op="A">2</ChargeNumber>
				<Statute>
					<StatuteNumber Op="A">169.14.2(a)(4)</StatuteNumber>
					<StatuteCode Op="A" Word="169142a4">Traffic-speeding</StatuteCode>
					<OffenseType Word="ST">Statute</OffenseType>
				</Statute>
			</ChargeHistory>
		</Charge>
	</Case>
	<Citation>
		<Vehicle>
			<VehicleType Word="PASSVEH">Passenger Vehicle</VehicleType>
		</Vehicle>
		<CitationCharge>
			<ChargeID>13689714</ChargeID>
			<ChargeHistoryID>53525886</ChargeHistoryID>
			<ChargeNumber>1</ChargeNumber>
			<SequenceNumber>1</SequenceNumber>
			<OffenseStatute>97C.401.2</OffenseStatute>
		</CitationCharge>
		<CitationCharge>
			<ChargeID>13689715</ChargeID>
			<ChargeHistoryID>53525887</ChargeHistoryID>
			<ChargeNumber>2</ChargeNumber>
			<SequenceNumber>1</SequenceNumber>
			<OffenseStatute>169.14.2(a)(4)</OffenseStatute>
		</CitationCharge>
	</Citation>
</Integration>

[/code]

我尝试过的事情:

这里是我需要添加逻辑的xslt选择器逻辑

[/code]

What I have tried:

Here is xslt selector logic where I need to add logic

<?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"/>
	</xsl:template>
	<xsl:template match="Case">
		<!-- -->
		<!-- Check for repass events -->
		<!-- -->
		<xsl:if test="count(CaseEvent[(@Op='A') and (count(EventGroups/EventGroup[@Word='DVSSPECIAL'])!=0)])!=0">
			<NotificationEvent notificationType="DVSDisposition">
				<xsl:attribute name="elementState">Existing</xsl:attribute>
				<xsl:attribute name="elementName">CaseEvent</xsl:attribute>
				<xsl:attribute name="elementKey"><xsl:value-of select="@ID"/></xsl:attribute>
				<xsl:text>REPASSEVENT</xsl:text>
			</NotificationEvent>
		</xsl:if>
		<!-- Check for charge certifications	 -->
		<xsl:if test="../ControlPoint!='SAVE-CR-EVENT'">
			<xsl:for-each select="Charge">
				<xsl:variable name="vChargeID">
					<xsl:value-of select="@ID"/>
				</xsl:variable>
				<xsl:variable name="vDispEventID">
					<xsl:call-template name="GetCurrentDispositionEventIDForCharge">
						<xsl:with-param name="pChargeID">
							<xsl:value-of select="$vChargeID"/>
						</xsl:with-param>
					</xsl:call-template>
				</xsl:variable>
				<xsl:for-each select="ancestor::Case//DispositionEvent[@ID = $vDispEventID]/Disposition[@ChargeID = $vChargeID]">
					<xsl:variable name="vDispChargeID">
						<xsl:value-of select="@ChargeID"/>
					</xsl:variable>
					<xsl:variable name="vDispChargeHistID">
						<xsl:value-of select="@ChargeHistoryID"/>
					</xsl:variable>
					<!-- was something updated for this dispo ? -->
					<xsl:if test="(string-length(@Op) != 0)  or (string-length(//ChargeHistory[@ChargeHistoryID=$vDispChargeHistID]/@Op) != 0) or (count(ancestor::Case/CaseEvent[(@Op='A') and (count(EventGroups/EventGroup[@Word='DVSSPECIAL'])!=0)])!=0)">
						<xsl:choose>
							<xsl:when test='@Op = "D"'>
							</xsl:when>
							<xsl:otherwise>
								<xsl:variable name="vIsTriggeringDisposition">
									<xsl:call-template name="IsTriggeringDisposition"/>
								</xsl:variable>
								<xsl:variable name="vWasTriggered">
									<xsl:choose>
										<!-- check triggered by case event -->
										<xsl:when test="(count(ancestor::Case/CaseEvent[(@Op='A') and (count(EventGroups/EventGroup[@Word='DVSSPECIAL'])!=0)])!=0) and ($vIsTriggeringDisposition = 'true')">
											<xsl:value-of select="true()"/>
										</xsl:when>
										<!-- check triggered by new disposition -->
										<xsl:when test="(@Op='A') and (count(../DispositionAmendmentReason)=0) and ($vIsTriggeringDisposition = 'true')">
											<xsl:value-of select='true()'/>
										</xsl:when>
										<!-- check triggered by amended disposition when earlier disposition didn't pass -->
										<xsl:when test="(@Op='A') and ($vIsTriggeringDisposition = 'true')">
											<xsl:variable name="vIsPriorDispositionTriggering">
												<xsl:for-each select="../DispositionEvent[count(Disposition[@ChargeID = $vChargeID])!=0][1]/Disposition[@ChargeID = $vChargeID]">
													<xsl:call-template name="IsTriggeringDisposition"/>
												</xsl:for-each>
											</xsl:variable>
											<xsl:choose>
												<xsl:when test="contains($vIsPriorDispositionTriggering,'false')">
													<xsl:value-of select="true()"/>
												</xsl:when>
												<xsl:otherwise>
													<xsl:value-of select="false()"/>
												</xsl:otherwise>
											</xsl:choose>
										</xsl:when>
										<xsl:otherwise>
											<xsl:value-of select='false()'/>
										</xsl:otherwise>
									</xsl:choose>
								</xsl:variable>
								<xsl:choose>
									<xsl:when test="$vWasTriggered='true'">
										<!-- determine vehicle type -->
										<xsl:variable name="vDWIVehicle">
											<xsl:call-template name="IsDwiVehicle"/>
										</xsl:variable>
										<xsl:variable name="vDvsCharge">
											<xsl:choose>
												<xsl:when test='(//ChargeHistory[@ChargeHistoryID=$vDispChargeHistID]/Additional/CertifyToDPS) and ($vDWIVehicle="false" or substring(//ChargeHistory[@ChargeHistoryID=$vDispChargeHistID]/Statute/StatuteNumber,1,4)="169A")'>
													<xsl:value-of select="true()"/>
												</xsl:when>
												<xsl:otherwise>
													<xsl:value-of select="false()"/>
												</xsl:otherwise>
											</xsl:choose>
										</xsl:variable>
										<xsl:choose>
											<!-- was there a conviction, that is certified, and with correct vehicle/statute combo ? -->
											<xsl:when test='$vDvsCharge="true"'>
												<xsl:variable name="vUpdate">
													<xsl:choose>
														<xsl:when test="(count(ancestor::Case/CaseEvent[(@Op='A') and (count(EventGroups/EventGroup[@Word='DVSSPECIAL'])!=0)])!=0)">resend</xsl:when>
														<xsl:when test='(count(//CaseEvent[EventType/@Word="IBDVSCONV"]/ChargeID[.=$vDispChargeID]) != 0) or (count(//CaseEvent[EventType/@Word="IBUPDDPS"]/ChargeID[.=$vDispChargeID]) != 0)'>update</xsl:when>
														<xsl:otherwise>initial</xsl:otherwise>
													</xsl:choose>
												</xsl:variable>
												<xsl:if test="$vUpdate != 'update'">
													<NotificationEvent notificationType="DVSDisposition">
														<xsl:attribute name="elementState"><xsl:value-of select="$vUpdate"/></xsl:attribute>
														<xsl:attribute name="elementName">DispositionEvent</xsl:attribute>
														<xsl:attribute name="elementKey"><xsl:value-of select="../@ID"/></xsl:attribute>
														<xsl:attribute name="chargeElementKey"><xsl:value-of select="$vDispChargeID"/></xsl:attribute>
														<xsl:attribute name="chargeHistoryElementKey"><xsl:value-of select="$vDispChargeHistID"/></xsl:attribute>
														<xsl:choose>
															<xsl:when test="$vUpdate = 'initial'">DispositionAdded</xsl:when>
															<xsl:when test="$vUpdate = 'resend2011'">DispositionRepass2011</xsl:when>
															<xsl:when test="$vUpdate = 'resend'">DispositionRepass</xsl:when>
															<xsl:otherwise>DispositionUpdated</xsl:otherwise>
														</xsl:choose>
													</NotificationEvent>
												</xsl:if>
											</xsl:when>
										</xsl:choose>
									</xsl:when>
								</xsl:choose>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:if>
				</xsl:for-each>
			</xsl:for-each>
		</xsl:if>
		<!-- Check for charge Re-Certifications -->
		<xsl:for-each select="CaseEvent[string-length(@Op)!=0 and EventType/@Word='RECERTDPS']/ChargeID">
			<xsl:variable name="vChrgID">
				<xsl:value-of select="."/>
			</xsl:variable>
			<xsl:variable name="vUpdate">
				<xsl:choose>
					<xsl:when test='count(//CaseEvent[EventType/@Word="IBUPDDPS"]/ChargeID[.=$vChrgID]) != 0'>update</xsl:when>
					<xsl:otherwise>initial</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<NotificationEvent notificationType="DVSDisposition">
				<xsl:attribute name="elementState"><xsl:value-of select="$vUpdate"/></xsl:attribute>
				<xsl:attribute name="elementName">Charge</xsl:attribute>
				<xsl:attribute name="elementKey"><xsl:value-of select="."/></xsl:attribute>
				<xsl:attribute name="chargeElementKey"><xsl:value-of select="."/></xsl:attribute>
				<xsl:text>ChargeRecertified</xsl:text>
			</NotificationEvent>
		</xsl:for-each>
	</xsl:template>
	<!--  -->
	<xsl:template name="IsDwiVehicle">
		<xsl:choose>
			<xsl:when test='//Citation/Vehicle/VehicleType/@Word="ATV"'>
				<xsl:value-of select="true()"/>
			</xsl:when>
			<xsl:when test='//Citation/Vehicle/VehicleType/@Word="BIKE"'>
				<xsl:value-of select="true()"/>
			</xsl:when>
			<xsl:when test='//Citation/Vehicle/VehicleType/@Word="BOAT"'>
				<xsl:value-of select="true()"/>
			</xsl:when>
			<xsl:when test='//Citation/Vehicle/VehicleType/@Word="CONSTEQUIP"'>
				<xsl:value-of select="true()"/>
			</xsl:when>
			<xsl:when test='//Citation/Vehicle/VehicleType/@Word="ORMOTORCY"'>
				<xsl:value-of select="true()"/>
			</xsl:when>
			<xsl:when test='//Citation/Vehicle/VehicleType/@Word="ORRV"'>
				<xsl:value-of select="true()"/>
			</xsl:when>
			<xsl:when test='//Citation/Vehicle/VehicleType/@Word="SNOWMO"'>
				<xsl:value-of select="true()"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="false()"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<!--  -->
	<xsl:template name="IsTriggeringDisposition">
		<xsl:choose>
			<xsl:when test='DispositionType/@Word="CONV"'>
				<xsl:value-of select="true()"/>
			</xsl:when>
			<xsl:when test='DispositionType/@Word="ADJDEL"'>
				<xsl:value-of select="true()"/>
			</xsl:when>
			<xsl:when test='DispositionType/@Word="ADJTO"'>
				<xsl:value-of select="true()"/>
			</xsl:when>
			<xsl:when test='DispositionType/@Word="ADJPO"'>
				<xsl:value-of select="true()"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="false()"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<!-- Get the event id for the disposition associated with the provided charge id -->
	<!-- -->
	<xsl:template name="GetCurrentDispositionEventIDForCharge">
		<xsl:param name="pChargeID"/>
		<xsl:variable name="vDisps">
			<xsl:for-each select="//DispositionEvent[(@Op !='D' or string-length(@Op)=0)][count(Disposition[@ChargeID = $pChargeID])!=0][1]">
				<xsl:sort select="count(ancestor::DispositionEvent)" order="ascending"/>
				<xsl:for-each select="Disposition[@ChargeID = $pChargeID]">
					<xsl:value-of select="../@ID"/>;
				</xsl:for-each>
			</xsl:for-each>
		</xsl:variable>
		<xsl:value-of select="substring-before($vDisps,';')"/>
	</xsl:template>
</xsl:stylesheet>

推荐答案

vChargeID"/> </xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:for-each select="ancestor::Case//DispositionEvent[@ID =
vChargeID"/> </xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:for-each select="ancestor::Case//DispositionEvent[@ID =


vDispEventID]/Disposition[@ChargeID =
vDispEventID]/Disposition[@ChargeID =


vChargeID]"> <xsl:variable name="vDispChargeID"> <xsl:value-of select="@ChargeID"/> </xsl:variable> <xsl:variable name="vDispChargeHistID"> <xsl:value-of select="@ChargeHistoryID"/> </xsl:variable> <!-- was something updated for this dispo ? --> <xsl:if test="(string-length(@Op) != 0) or (string-length(//ChargeHistory[@ChargeHistoryID=
vChargeID]"> <xsl:variable name="vDispChargeID"> <xsl:value-of select="@ChargeID"/> </xsl:variable> <xsl:variable name="vDispChargeHistID"> <xsl:value-of select="@ChargeHistoryID"/> </xsl:variable> <!-- was something updated for this dispo ? --> <xsl:if test="(string-length(@Op) != 0) or (string-length(//ChargeHistory[@ChargeHistoryID=


这篇关于如何获得正确的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆