我如何获得DispositionEventDate?

时间:2015-05-06 21:22:35

标签: xml xslt

我想在DispositionEvent中显示DispositionEventDate,DispositionType和@Word。要获取此信息,我将使用ChargeHistory中的ChargeHistoryID作为Charge的子项。然后使用该ID,我需要将它与DispositionEvent的子项DispositionEvent中的ChargeHistoryID进行比较。
预期输出应如下所示:

<ext:Charge>
        <nc:Disposition>
            <nc:DispositionDate>
                <nc:Date>05/08/2014</nc:Date>
            </nc:DispositionDate>
            <nc:DispositionDescriptionText>Convicted</nc:DispositionDescriptionText>
            <nc:DispositionText>CONV</nc:DispositionText>
        </nc:Disposition>
    </ext:Charge>

完成xml

<Integration 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="67078058" xmlns="">
<Case InternalID="1616807927" ID="11747370" xmlns:user="http://tylertechnologies.com">
    <DispositionEvent ID="155092097" Date="05/08/2014" InternalDispositionEventID="1717322912" xmlns:reslib="urn:reslib">
        <DispositionEventDate>05/08/2014</DispositionEventDate>
        <AgingClockActionKey Word="N">Does not affect aging clock</AgingClockActionKey>
        <Disposition ChargeID="10547226" ChargeHistoryID="41858685" InternalChargeID="1616447618" InternalOffenseHistoryID="1636250409">
            <DispositionType Word="CONV">Convicted</DispositionType>
        </Disposition>
    </DispositionEvent>
    <Charge ID="10547226" PartyID="16580814" CurrSentenceID="155092098" InternalChargeID="1616447618" InternalPartyID="1614482843" xmlns:reslib="urn:reslib">
        <ChargeOffenseDate>03/26/2014</ChargeOffenseDate>
        <ChargeHistory ChargeHistoryID="41858685" Stage="Disposition Event" DispositionEventSequence="2" CurrentCharge="true" InternalOffenseHistoryID="1636250409">
            <ChargeNumber>2</ChargeNumber>
        </ChargeHistory>
    </Charge>
</Case>

xslt 以下是用于显示DispositionEventDate,DispositionType和@Word(CONV)输出的模板。

<xsl:template name="ChargeDetails">
        <j:ChargeSequenceID>
            <xsl:value-of select="ChargeNumber"/>
        </j:ChargeSequenceID>
        <j:ChargeStatute>
            <j:StatuteDescriptionText>
                <xsl:value-of select="Statute/StatuteCode"/>
            </j:StatuteDescriptionText>
            <j:StatuteText>
                <xsl:value-of select="Statute/StatuteCode/@Word"/>
            </j:StatuteText>
        </j:ChargeStatute>
        <j:ChargeSeverityDescriptionText>
            <xsl:value-of select="Statute/Degree"/>
        </j:ChargeSeverityDescriptionText>
        <!--/Integration/Case/Charge/ChargeHistory[5]/@ChargeHistoryID-->
        <xsl:if test="@Stage='Disposition Event'">
            <!--<xsl:for-each select="following-sibling::DispositionEventDate[preceding-sibling::DispositionEvent/Disposition[@ChargeHistoryID=current()/@ChargeHistoryID]][1]">-->
            <xsl:for-each select="ancestor::Integration//DispositionEvent/Disposition[@ChargeHistoryID=current()/@ChargeHistoryID][1]">123
                <nc:Disposition>
                    <nc:DispositionDate>
                        <nc:Date>
                            <xsl:value-of select="mscef:formatDate(string(DispositionEventDate))"/>
                        </nc:Date>
                    </nc:DispositionDate>
                    <nc:DispositionDescriptionText>
                        <xsl:value-of select="DispositionType"/>
                    </nc:DispositionDescriptionText>
                    <nc:DispositionText>
                        <xsl:value-of select="@Word"/>
                    </nc:DispositionText>
                </nc:Disposition>
            </xsl:for-each>
        </xsl:if>
    </xsl:template>

1 个答案:

答案 0 :(得分:0)

假设您位于xsl:for-each元素上,可以将<xsl:for-each select="../../DispositionEvent[Disposition/@ChargeHistoryID=current()/@ChargeHistoryID][1]"> 更改为此

xsl:key

或者,您可以使用<xsl:key name="Event" match="DispositionEvent" use="Disposition/@ChargeHistoryID" /> 。像这样定义一个键:

xsl:for-each

然后您的<xsl:for-each select="key('Event', @ChargeHistoryID)[1]"> 简化为:

<li>