如何从xml文档中获取TicketDate?

时间:2015-05-07 17:57:44

标签: xml xslt xslt-2.0

我想获得TicketDate,其中ChargeID与CitationCharge / ChargeID相同。可能有几个带有几个CitationID的ChargeID。 xml中的 TicketDate 与xsl代码中的xsl元素<nc:Date>相同 因此,我需要检查ChargeID与CitationCharge / ChargeID的匹配位置,以便获得正确的TicketDate。

*所需的输出应该如下**

<ext:Charge>
    <ext:Citation>
        <nc:ActivityDate>2014-03-26</nc:ActivityDate>
    </ext:Citation>
</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="67084253" xmlns="">
<Case Op="E" InternalID="1617090499" ID="12125626" xmlns:user="http://tylertechnologies.com">
    <Charge ID="10906090" PartyID="16765959" InternalChargeID="1616713754" InternalPartyID="1614667066" xmlns:reslib="urn:reslib">
        <ChargeOffenseDate>04/13/2015</ChargeOffenseDate>
            <ChargeHistory ChargeHistoryID="42933438" Stage="Case Filing" FilingSequence="1" CurrentCharge="true" InternalOffenseHistoryID="1637029057">
            <ChargeNumber>1</ChargeNumber>
        </ChargeHistory>
        <ChargeHistory ChargeHistoryID="42933437" Stage="Citation Issued" CitationEventSequence="1" InternalOffenseHistoryID="1637029056">
            <ChargeNumber>1</ChargeNumber>
        </ChargeHistory>
        <Deleted>false</Deleted>
    </Charge>
    <Charge ID="10906091" PartyID="16765959" InternalChargeID="1616713755" InternalPartyID="1614667066" xmlns:reslib="urn:reslib">
        <ChargeOffenseDate>04/13/2015</ChargeOffenseDate>
        <ChargeHistory ChargeHistoryID="42933440" Stage="Case Filing" FilingSequence="1" CurrentCharge="true" InternalOffenseHistoryID="1637029059">
            <ChargeNumber>2</ChargeNumber>
        </ChargeHistory>
        <ChargeHistory ChargeHistoryID="42933439" Stage="Citation Issued" CitationEventSequence="1" InternalOffenseHistoryID="1637029058">
            <ChargeNumber>2</ChargeNumber>
        </ChargeHistory>
    </Charge>
</Case>
<Citation ID="5385330" xmlns:user="http://tylertechnologies.com">
    <CitationNumber>12345</CitationNumber>
    <OffenseDate>04/13/2015</OffenseDate>
    <TicketDate>04/13/2015</TicketDate>
    <CitationCharge>
        <ChargeID>10906090</ChargeID>
        <ChargeHistoryID>42933437</ChargeHistoryID>
        <ChargeNumber>1</ChargeNumber>
        <SequenceNumber>1</SequenceNumber>
    </CitationCharge>
</Citation>
<Citation ID="5385331" xmlns:user="http://tylertechnologies.com">
    <CitationNumber>54321</CitationNumber>
    <OffenseDate>04/13/2015</OffenseDate>
    <TicketDate>04/13/2015</TicketDate>
    <CitationCharge>
        <ChargeID>10906091</ChargeID>
        <ChargeHistoryID>42933439</ChargeHistoryID>
        <ChargeNumber>2</ChargeNumber>
        <SequenceNumber>1</SequenceNumber>
    </CitationCharge>
</Citation>

XSLT

    <xsl:template name="ChargeDetails">
<ext:Citation>
    <nc:AvtivityDate> 
        <xsl:if test="Charge[@ID=current()/../CitationCharge/ChargeID]">
        <nc:Date>
            <xsl:value-of select="mscef:formatDate(string(/Integration/Citation/TicketDate))"/>
        </nc:Date>
    </xsl:if>
    </nc:AvtivityDate>
</ext:Citation>
</xsl:template>  

0 个答案:

没有答案