Как мне получить правильные элементы?
Я добавил логику селектора xslt того, что я пытаюсь сделать и нуждаюсь в помощи.
Пожалуйста, помогите мне.
Вот что я пытаюсь добавить в селектор (преобразование XSLT)
Для каждого заряда с ChargeHistory Op="A" и Stage="Disposition Event" найдите, не равен ли тип транспортного средства, основанный на интеграции/цитировании/транспортном средстве/VehicleType/@Word =ATV или BOAT или SNOWMO, а также OffenseType @ Word = ST и OffenseStatute Статутному коду с первыми 3 символами 169 или 4 символами 8491 или первыми 6 символами 86B331.
Может ли кто - нибудь помочь мне с этим? Заранее спасибо.
Вот xml-документ
<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>[/код]
Что я уже пробовал:
Вот логика селектора xslt, где мне нужно добавить логику
<?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>
Gerry Schmitz
Были ли у вас какие-то конкретные "языки программирования" в виду для вашего решения?
RedDk
Пожалуйста, воздержитесь от удаления содержания вопросов при редактировании постов. Этот вопрос сейчас совершенно другой, начиная с "обновления". И это не нормально в отношении опубликованных решений ... пользователи приходят на страницы с помощью различных средств ... просмотр ответов в наборах возвратов из поиска, которые не имеют никакой связи с исходными записями ... может показаться бессмысленным без контекста (Нуби, прибывающие таким образом, понятия не имеют, где искать информацию о ревизии).
Итак, в следующий раз используйте [EDIT] ... [РЕДАКТИРОВАНИЕ] ... и сделать это проще для сообщества публикации решений.