2014-12-03 49 views
0

我只希望有<ext:PersonRaceCode>A</ext:PersonRaceCode>作爲申請者的受保護方,因爲他們的<ObservedRace Word="A">Asian</ObservedRace>在xml中可用。 但是,即使其他受保護方在xml中沒有可用的<ObservedRace>,我也會得到相同的<ext:PersonRaceCode>A</ext:PersonRaceCode>即使沒有可用的代碼,我也得到PersonRaceCode

預期輸出:

 <ext:ProtectedParty> 
     <ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="true">1969-10-14</ext:PersonBirthDate> 
     <nc:PersonName> 
      <nc:PersonGivenName>Jeann</nc:PersonGivenName> 
      <nc:PersonMiddleName>Kume</nc:PersonMiddleName> 
      <nc:PersonSurName>Dudu</nc:PersonSurName> 
      <nc:PersonNameSuffixText/> 
      <nc:PersonFullName>Dudu, Jeann Kume</nc:PersonFullName> 
     </nc:PersonName> 
     <ext:PersonRaceCode>A</ext:PersonRaceCode> 
     <nc:PersonSexCode>M</nc:PersonSexCode> 
     <ext:PetitionerIndicator>true</ext:PetitionerIndicator> 
    </ext:ProtectedParty> 
    <ext:ProtectedParty> 
     <ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="true">2001-03-15</ext:PersonBirthDate> 
     <nc:PersonName> 
      <nc:PersonGivenName>Brad</nc:PersonGivenName> 
      <nc:PersonMiddleName/> 
      <nc:PersonSurName>Mike</nc:PersonSurName> 
      <nc:PersonNameSuffixText/> 
      <nc:PersonFullName>Mike, Brad</nc:PersonFullName> 
     </nc:PersonName> 
     <ext:PersonRaceCode/> 
     <nc:PersonSexCode>M</nc:PersonSexCode> 
     <ext:PetitionerIndicator>false</ext:PetitionerIndicator> 
    </ext:ProtectedParty> 

電流輸出錯誤

 <ext:ProtectedParty> 
     <ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="true">1969-10-14</ext:PersonBirthDate> 
     <nc:PersonName> 
      <nc:PersonGivenName>Jeann</nc:PersonGivenName> 
      <nc:PersonMiddleName>Kume</nc:PersonMiddleName> 
      <nc:PersonSurName>Dudu</nc:PersonSurName> 
      <nc:PersonNameSuffixText/> 
      <nc:PersonFullName>Dudu, Jeann Kume</nc:PersonFullName> 
     </nc:PersonName> 
     <ext:PersonRaceCode>A</ext:PersonRaceCode> 
     <nc:PersonSexCode>M</nc:PersonSexCode> 
     <ext:PetitionerIndicator>true</ext:PetitionerIndicator> 
    </ext:ProtectedParty> 
    <ext:ProtectedParty> 
     <ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="true">2001-03-15</ext:PersonBirthDate> 
     <nc:PersonName> 
      <nc:PersonGivenName>Brad</nc:PersonGivenName> 
      <nc:PersonMiddleName/> 
      <nc:PersonSurName>Mike</nc:PersonSurName> 
      <nc:PersonNameSuffixText/> 
      <nc:PersonFullName>Mike, Brad</nc:PersonFullName> 
     </nc:PersonName> 
     <ext:PersonRaceCode>A</ext:PersonRaceCode> 
     <nc:PersonSexCode>M</nc:PersonSexCode> 
     <ext:PetitionerIndicator>false</ext:PetitionerIndicator> 
    </ext:ProtectedParty> 

我的XML代碼

<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com"> 
    <Case InternalID="1616758956" ID="11682320" xmlns:user="http://tylertechnologies.com"> 
     <CaseParty ID="14374736" InternalCasePartyID="1633583492" InternalPartyID="1612267260"> 
      <SendNotice>true</SendNotice> 
      <ObservedRace Word="A">Asian</ObservedRace> 
      <Connection Word="PET" BaseConnection="PL" ID="34643485" InternalCasePartyConnectionID="1635190996"> 
       <Description>Petitioner</Description> 
      </Connection> 
      <CasePartyName Current="true" ID="4990971" InternalNameID="1612653737"> 
       <NameType>Standard</NameType> 
       <NameFirst>Jeann</NameFirst> 
       <NameMiddle>Kume</NameMiddle> 
       <NameLast>Dudu</NameLast> 
       <FormattedName>Dudu, Jeann Kume</FormattedName> 
      </CasePartyName> 
     </CaseParty> 
     <CaseParty ID="16548387" InternalCasePartyID="1633583509" InternalPartyID="1614451524"> 
      <SendNotice>true</SendNotice> 
      <Connection Word="MNR" BaseConnection="O2" ID="34643502" InternalCasePartyConnectionID="1635191013"> 
       <Description>Minor</Description> 
      </Connection> 
      <CasePartyName Current="true" ID="9638900" InternalNameID="1615262962"> 
       <NameType>Standard</NameType> 
       <NameFirst>Brad</NameFirst> 
       <NameLast>Mike</NameLast> 
       <FormattedName>Mike, Brad</FormattedName> 
      </CasePartyName> 
     </CaseParty> 
     <ProtectionOrders> 
      <ProtectionOrder Op="E" InternalProtectionOrderID="1349"> 
       <Deleted>false</Deleted> 
       <RespondentPartyID InternalPartyID="1610253026">1610253026</RespondentPartyID> 
       <RespondentNameID InternalNameID="1610281862">1610281862</RespondentNameID> 
       <ProtectionOrderNumber>1400350</ProtectionOrderNumber> 
       <ProtectionOrderParties> 
        <ProtectionOrderParty InternalPartyID="1612267260"> 
         <ProtectionOrderPartyNames> 
          <ProtectionOrderPartyName Current="true" InternalNameID="1612653737" FormattedName="Dudu, Jeann Kume"/> 
         </ProtectionOrderPartyNames> 
         <ProtectionOrderConnection> 
          <Petitioner>true</Petitioner> 
          <ProtectedParty>true</ProtectedParty> 
          <Minor>false</Minor> 
         </ProtectionOrderConnection> 
        </ProtectionOrderParty> 
        <ProtectionOrderParty InternalPartyID="1614451524"> 
         <ProtectionOrderPartyNames> 
          <ProtectionOrderPartyName Current="true" InternalNameID="1615262962" FormattedName="Mike, Brad"/> 
         </ProtectionOrderPartyNames> 
         <ProtectionOrderConnection> 
          <Petitioner>false</Petitioner> 
          <ProtectedParty>true</ProtectedParty> 
          <Minor>true</Minor> 
         </ProtectionOrderConnection> 
        </ProtectionOrderParty> 
       </ProtectionOrderParties> 
      </ProtectionOrder> 
     </ProtectionOrders> 
    </Case> 
    <Party ID="14374736" InternalPartyID="1612267260"> 
     <Gender Word="M ">Male</Gender> 
     <Race Word="W">White</Race> 
     <DateOfBirth Current="true">10/14/1969</DateOfBirth> 
     <PartyName ID="4990971" Current="true" InternalNameID="1612653737"> 
      <NameType>Standard</NameType> 
      <NameFirst>Jeann</NameFirst> 
      <NameMiddle>Kume</NameMiddle> 
      <NameLast>Dudu</NameLast> 
      <FormattedName>Dudu, Jeann Kume</FormattedName> 
     </PartyName> 
    </Party> 
    <Party ID="16548387" InternalPartyID="1614451524"> 
     <Gender Word="M ">Male</Gender> 
     <DateOfBirth Current="true">03/15/2001</DateOfBirth> 
     <PartyName ID="9638900" Current="true" InternalNameID="1615262962"> 
      <NameType>Standard</NameType> 
      <NameFirst>Brad</NameFirst> 
      <NameLast>Mike</NameLast> 
      <FormattedName>Mike, Brad</FormattedName> 
     </PartyName> 
    </Party> 
    <IntegrationConditions> 
     <IntegrationCondition> 
      <NotificationEvent internalProtectionOrderID="1349" protectionOrderNumber="1400350" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">Signed</NotificationEvent> 
     </IntegrationCondition> 
    </IntegrationConditions> 
</Integration> 

我的XSLTÇ ode有受保護方請願人兩個模板。申請人也可以是受保護的當事人,這意味着並非所有申請人都是受保護的當事人,並非所有受保護的當事人都是上訪者。

XSLT代碼

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://www.courts.state.mn.us/ProtectionOrderExtension/1.0" xmlns:nc="http://niem.gov/niem/niem-core/2.0" exclude-result-prefixes="mscef msxsl exsl"> 
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 
    <xsl:template name="ProtectionOrder"> 
     <ext:ProtectionOrder> 
      <xsl:variable name="vProtectionOrderID"> 
       <xsl:value-of select="@InternalProtectionOrderID"/> 
      </xsl:variable> 
<!--Petitioner--> 
      <xsl:for-each select="ProtectionOrderParties/ProtectionOrderParty[(ProtectionOrderConnection/Petitioner='true') and (ProtectionOrderConnection/ProtectedParty='false')][1]"> 
       <xsl:for-each select="//Integration/Party[@InternalPartyID=current()/@InternalPartyID]"> 
        <xsl:call-template name="Petitioner"/> 
       </xsl:for-each> 
      </xsl:for-each> 
<!--Protected Party--> 
      <xsl:for-each select="ProtectionOrderParties/ProtectionOrderParty[ProtectionOrderConnection/ProtectedParty='true']"> 
       <xsl:variable name="vPetitionerIndicator"> 
        <xsl:value-of select="ProtectionOrderConnection/Petitioner"/> 
       </xsl:variable> 
       <xsl:for-each select="//CaseParty[(@InternalPartyID=current()/@InternalPartyID)]"> 
        <!--<xsl:for-each select="//Integration/Party[@InternalPartyID=current()/@InternalPartyID]">--> 
        <xsl:for-each select="//Integration/Party[@InternalPartyID=current()/@InternalPartyID]"> 
         <xsl:call-template name="ProtectedParty"> 
          <xsl:with-param name="pPetionerIndicator"> 
           <xsl:value-of select="$vPetitionerIndicator"/> 
          </xsl:with-param> 
         </xsl:call-template> 
        </xsl:for-each> 
       </xsl:for-each> 
      </xsl:for-each> 

<!--ext:ProtectionOrderID--> 
      <ext:ProtectionOrderID> 
       <xsl:value-of select="ProtectionOrderNumber"/> 
      </ext:ProtectionOrderID> 
<!--ext:ProtectionOrderTypeCode--> 
      <ext:ProtectionOrderTypeCode> 
       <xsl:value-of select="Type/@Word"/> 
      </ext:ProtectionOrderTypeCode> 
     </ext:ProtectionOrder> 
    </xsl:template> 
<!--Protection order template ends here--> 
<!--Petitioner Template--> 
    <xsl:template name="Petitioner"> 
     <ext:Petitioner> 
      <ext:AddressReference> 
       <xsl:for-each select="Address[@PartyCurrent='true']"> 
        <xsl:attribute name="ext:currentIndicator"><xsl:value-of select="@PartyCurrent"/></xsl:attribute> 
        <nc:LocationReference> 
         <xsl:attribute name="s:ref"><xsl:text>INT</xsl:text><xsl:value-of select="@ID"/></xsl:attribute> 
        </nc:LocationReference> 
       </xsl:for-each> 
      </ext:AddressReference> 
      <ext:PersonBirthDate> 
       <xsl:choose> 
        <xsl:when test="DateOfBirth[@Current='true']"> 
         <xsl:attribute name="ext:approximateDateIndicator">false</xsl:attribute> 
         <xsl:attribute name="ext:currentIndicator">true</xsl:attribute> 
         <xsl:value-of select="mscef:formatDate(string(DateOfBirth[@Current='true']))"/> 
        </xsl:when> 
        <xsl:when test="ApproximateDOB"> 
         <xsl:attribute name="ext:approximateDateIndicator">true</xsl:attribute> 
         <xsl:attribute name="ext:currentIndicator">true</xsl:attribute> 
         <xsl:value-of select="mscef:formatDate(string(ApproximateDOB))"/> 
        </xsl:when> 
       </xsl:choose> 
      </ext:PersonBirthDate> 
      <nc:PersonName> 
       <nc:PersonGivenName> 
        <xsl:value-of select="PartyName/NameFirst"/> 
       </nc:PersonGivenName> 
       <nc:PersonMiddleName> 
        <xsl:value-of select="PartyName/NameMiddle"/> 
       </nc:PersonMiddleName> 
       <nc:PersonSurName> 
        <xsl:value-of select="PartyName/NameLast"/> 
       </nc:PersonSurName> 
       <nc:PersonNameSuffixText> 
        <!--<xsl:value-of select="PartyName/NameSuffix/@Word"/>--> 
        <xsl:value-of select="PartyName/NameSuffix"/> 
       </nc:PersonNameSuffixText> 
       <nc:PersonFullName> 
        <xsl:value-of select="PartyName/FormattedName"/> 
       </nc:PersonFullName> 
      </nc:PersonName> 
      <ext:PersonRaceCode> 
       <!--<xsl:value-of select="/Integration/Case/CaseParty[1]/ObservedRace/@Word"/>--> 
       <xsl:value-of select="/Integration/Case/CaseParty/ObservedRace/@Word"/> 
      </ext:PersonRaceCode> 
      <nc:PersonSexCode> 
       <xsl:value-of select="Party/Gender/@Word"/> 
      </nc:PersonSexCode> 
     </ext:Petitioner> 
    </xsl:template> 
<!--Protected Party Template--> 
    <xsl:template name="ProtectedParty"> 
     <xsl:param name="pPetionerIndicator"/> 
     <ext:ProtectedParty> 
      <ext:PersonBirthDate> 
       <xsl:choose> 
        <xsl:when test="DateOfBirth[@Current='true']"> 
         <xsl:attribute name="ext:approximateDateIndicator">false</xsl:attribute> 
         <xsl:attribute name="ext:currentIndicator">true</xsl:attribute> 
         <xsl:value-of select="mscef:formatDate(string(DateOfBirth[@Current='true']))"/> 
        </xsl:when> 
        <xsl:when test="ApproximateDOB"> 
         <xsl:attribute name="ext:approximateDateIndicator">true</xsl:attribute> 
         <xsl:attribute name="ext:currentIndicator">true</xsl:attribute> 
         <xsl:value-of select="mscef:formatDate(string(ApproximateDOB))"/> 
        </xsl:when> 
       </xsl:choose> 
      </ext:PersonBirthDate> 
      <xsl:for-each select="PartyName[@Current='true']"> 
       <nc:PersonName> 
        <nc:PersonGivenName> 
         <xsl:value-of select="NameFirst"/> 
        </nc:PersonGivenName> 
        <nc:PersonMiddleName> 
         <xsl:value-of select="NameMiddle"/> 
        </nc:PersonMiddleName> 
        <nc:PersonSurName> 
         <xsl:value-of select="NameLast"/> 
        </nc:PersonSurName> 
        <nc:PersonNameSuffixText> 
         <xsl:value-of select="NameSuffix"/> 
        </nc:PersonNameSuffixText> 
        <nc:PersonFullName> 
         <xsl:value-of select="FormattedName"/> 
        </nc:PersonFullName> 
       </nc:PersonName> 
      </xsl:for-each> 
      <ext:PersonRaceCode> 
       <!--<xsl:value-of select="/Integration/Case/CaseParty/ObservedRace/@Word"/>--> 
       <xsl:value-of select="/Integration/Case/CaseParty/ObservedRace/@Word"/> 
      </ext:PersonRaceCode> 
      <nc:PersonSexCode> 
       <xsl:value-of select="normalize-space(Gender/@Word)"/> 
      </nc:PersonSexCode> 
      <ext:PetitionerIndicator> 
       <xsl:value-of select="$pPetionerIndicator"/> 
      </ext:PetitionerIndicator> 
     </ext:ProtectedParty> 
    </xsl:template> 
</xsl:stylesheet> 

回答

0

爲了尋找ObservedRace字= 'A',那麼你的情況應該是

<xsl:value-of select="/Integration/Case/CaseParty/ObservedRace/@Word[. = 'A']"/> 

它將打印屬性 '字' 值,這是A.

+0

但是,當ObservedRace Word ='H'或'W'時,它會起作用嗎?我在問,因爲觀察到的種族可以是除A之外的其他字母而我改變了我的代碼,但它仍然打印ObservedRace = A,沒有ObservedRace元素。 – user3781064 2014-12-03 19:19:47

+0

如果你有其他字母,它不會工作。在這種情況下 : \t \t :值的選擇=「/集成/案例/ CaseParty/ObservedRace/@字「/> \t \t 我測試了它,它只是只打印了亞洲。 – DroidDP 2014-12-03 20:07:28

+0

其實由於某種原因,這對我並不適用。我所做的就是確保我使用這樣的電流......' ',它現在可以用於任何代碼。 – user3781064 2014-12-03 20:22:05

0

這就是我所做的工作。包括當前的確保它將獲得每個CaseParty的PersonRaceCode。沒有目前的情況下,它只採取第一案件,並將其添加到任何其他案件可用。

<ext:PersonRaceCode> 
<xsl:value-of select="//Case/CaseParty[@InternalPartyID=current()/@InternalPartyID]/ObservedRa‌​ce/@Word"/> 
</ext:PersonRaceCode> 
相關問題