Xml 如何在文本片段之间添加分号,而不是在文本片段的末尾添加分号?

Xml 如何在文本片段之间添加分号,而不是在文本片段的末尾添加分号?,xml,xslt,Xml,Xslt,当我的xml代码取消了条件节点地址和参与方元素时,在参与方名称后添加分号。 我不想在名字后面加分号,因为后面没有别的东西。 以下是输出: <Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" Pac

当我的xml代码取消了条件节点地址和参与方元素时,在参与方名称后添加分号。 我不想在名字后面加分号,因为后面没有别的东西。 以下是输出:

        <Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" PackageID="BCA PO Notification" MessageID="57832809" xmlns="">
        <ProtectionOrder Op="E" InternalProtectionOrderID="2563" xmlns:user="http://tylertechnologies.com">
            <ProtectionOrderParties>
                <ProtectionOrderParty InternalPartyID="1614450754">
                    <ProtectionOrderPartyNames>
                        <ProtectionOrderPartyName Current="true" InternalNameID="1615262152" FormattedName="Brown, Rayne"/>
                    </ProtectionOrderPartyNames>
                    <Added>12/29/2014</Added>
                    <ProtectionOrderConnection>
                        <Petitioner>true</Petitioner>
                        <FilingParty>false</FilingParty>
                        <ProtectedParty>true</ProtectedParty>
                        <Minor>false</Minor>
                    </ProtectionOrderConnection>
                    <MNProtectionOrderAdditional InternalID="2604" xmlns:fn="http://www.w3.org/2005/xpath-functions">
            <Conditions>
                <Condition>
                    <Code Word="03F1EXPC">03.F.1 Respondent must not call/enter place of employment</Code>
                    <Description>Respondent must not call or enter the place of employment of the following party(ies). This includes all land, parking lots, and buildings of the following addresses:</Description>
                    <Parties>
                        <Party InternalPartyID="1614450754"/>
                    </Parties>
                    <Addresses>
                        <Address InternalAddressID="1618211350"/>
                    </Addresses>
                </Condition>
                <Condition>
                    <Code Word="03F2EXPC">03.F.2 Respondent's access at place of employment</Code>
                    <Description>Respondent's access to the following party(ies) at the following place(s) of employment is limited as follows: </Description>
                    <Parties>
                        <Party InternalPartyID="1614450754"/>
                    </Parties>
                    <Addresses>
                        <Address InternalAddressID="1618211350"/>
                    </Addresses>
                </Condition>
            </Conditions>
        </MNProtectionOrderAdditional>
                </ProtectionOrderParty>
            </ProtectionOrderParties>
            <MNProtectionOrderAdditional InternalID="2559" xmlns:fn="http://www.w3.org/2005/xpath-functions">
                </xsl:if>           
</MNProtectionOrderAdditional>
        </ProtectionOrder>
</Integration>
被申请人在以下工作地点与以下一方的接触受到以下限制:布朗,雷恩**;**明尼苏达州圣保罗地区路1048号,邮编55101 08

这里我的输出在条件文本元素的末尾显示分号,即使只有一个参与方名称。 如何更改xslt,以便在只有一个参与方名称时不显示此分号?

申请人被授予以下儿童(ren)的唯一实际和法律监护权:Brown,Rayne; 09

我的xml代码:

        <Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" PackageID="BCA PO Notification" MessageID="57832809" xmlns="">
        <ProtectionOrder Op="E" InternalProtectionOrderID="2563" xmlns:user="http://tylertechnologies.com">
            <ProtectionOrderParties>
                <ProtectionOrderParty InternalPartyID="1614450754">
                    <ProtectionOrderPartyNames>
                        <ProtectionOrderPartyName Current="true" InternalNameID="1615262152" FormattedName="Brown, Rayne"/>
                    </ProtectionOrderPartyNames>
                    <Added>12/29/2014</Added>
                    <ProtectionOrderConnection>
                        <Petitioner>true</Petitioner>
                        <FilingParty>false</FilingParty>
                        <ProtectedParty>true</ProtectedParty>
                        <Minor>false</Minor>
                    </ProtectionOrderConnection>
                    <MNProtectionOrderAdditional InternalID="2604" xmlns:fn="http://www.w3.org/2005/xpath-functions">
            <Conditions>
                <Condition>
                    <Code Word="03F1EXPC">03.F.1 Respondent must not call/enter place of employment</Code>
                    <Description>Respondent must not call or enter the place of employment of the following party(ies). This includes all land, parking lots, and buildings of the following addresses:</Description>
                    <Parties>
                        <Party InternalPartyID="1614450754"/>
                    </Parties>
                    <Addresses>
                        <Address InternalAddressID="1618211350"/>
                    </Addresses>
                </Condition>
                <Condition>
                    <Code Word="03F2EXPC">03.F.2 Respondent's access at place of employment</Code>
                    <Description>Respondent's access to the following party(ies) at the following place(s) of employment is limited as follows: </Description>
                    <Parties>
                        <Party InternalPartyID="1614450754"/>
                    </Parties>
                    <Addresses>
                        <Address InternalAddressID="1618211350"/>
                    </Addresses>
                </Condition>
            </Conditions>
        </MNProtectionOrderAdditional>
                </ProtectionOrderParty>
            </ProtectionOrderParties>
            <MNProtectionOrderAdditional InternalID="2559" xmlns:fn="http://www.w3.org/2005/xpath-functions">
                </xsl:if>           
</MNProtectionOrderAdditional>
        </ProtectionOrder>
</Integration>

12/29/2014
符合事实的
错误的
符合事实的
错误的
03.F.1受访者不得致电/输入工作地点
被申请人不得致电或进入以下一方的工作地点。这包括以下地址的所有土地、停车场和建筑物:
03.F.2受访者在工作地点的访问权
被申请人在以下工作地点与以下一方的接触受到以下限制:
我的xslt代码

<xsl:for-each select="MNProtectionOrderAdditional/Conditions/Condition">
            <ext:ProtectionOrderCondition>
                <ext:ConditionText>
                    <xsl:variable name="vCondition">
                        <xsl:value-of select="normalize-space(Description)"/>
                        <xsl:text> </xsl:text>
                        <xsl:for-each select="Parties/Party">
                            <xsl:for-each select="ancestor::ProtectionOrder/ProtectionOrderParties/ProtectionOrderParty[@InternalPartyID=current()/@InternalPartyID]">
                                <xsl:value-of select="ProtectionOrderPartyNames/ProtectionOrderPartyName[@Current='true']/@FormattedName"/>
                                <!--<xsl:text>; </xsl:text>-->
                                <xsl:if test="position() = last()">
                                <xsl:text>; </xsl:text>
                                </xsl:if>
                            </xsl:for-each>
                        </xsl:for-each>
                        <xsl:text> </xsl:text>
                        <xsl:for-each select="Addresses/Address">
                            <xsl:for-each select="ancestor::ProtectionOrder/ProtectionOrderParties/ProtectionOrderParty/MNProtectionOrderPartyAdditional/ProtectedAddresses/Address[@InternalAddressID=current()/@InternalAddressID]">
                                <xsl:if test="AddressLine1">
                                    <xsl:value-of select="AddressLine1"/>
                                    <xsl:text>, </xsl:text>
                                </xsl:if>
                                <xsl:if test="AddressLine2">
                                    <xsl:value-of select="AddressLine2"/>
                                    <xsl:text>, </xsl:text>
                                </xsl:if>
                                <xsl:if test="AddressLine3">
                                    <xsl:value-of select="AddressLine3"/>
                                    <xsl:text>, </xsl:text>
                                </xsl:if>
                                <xsl:if test="AddressLine4">
                                    <xsl:value-of select="AddressLine4"/>
                                </xsl:if>
                                <xsl:text>; </xsl:text>
                            </xsl:for-each>
                        </xsl:for-each>
                    </xsl:variable>
                    <xsl:choose>
                        <xsl:when test="substring($vCondition,string-length($vCondition)-1,2)='; '">
                            <xsl:value-of select="substring($vCondition,1,string-length($vCondition)-2)"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$vCondition"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </ext:ConditionText>
                <ext:ConditionCode>
                    <xsl:value-of select="document(concat($gEnvPath,'\ConfigFiles\MNCISCodes\ProtectionOrderConditionCodeMapping.xml'))
/ProtectionOrderConditionCodeMapping/Mapping[MNCISCode=current()/Code/@Word]/BCACode"/>
                </ext:ConditionCode>
            </ext:ProtectionOrderCondition>
        </xsl:for-each>
<xsl:for-each select="Parties/Party">
   <xsl:for-each select="ancestor::ProtectionOrder/ProtectionOrderParties/ProtectionOrderParty[@InternalPartyID=current()/@InternalPartyID]">
   <xsl:value-of select="ProtectionOrderPartyNames/ProtectionOrderPartyName[@Current='true']/@FormattedName"/>
    <xsl:if test="position() = last()">
    <xsl:text>; </xsl:text>
    </xsl:if>
    </xsl:for-each>
</xsl:for-each>

; 
, 
, 
, 
; 
更新的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">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template name="ProtectionOrder">
        <ext:ProtectionOrder>
<!--ext:ProtectionOrderCondition-->
            <xsl:for-each select="MNProtectionOrderAdditional/Conditions/Condition">
                <ext:ProtectionOrderCondition>
                    <ext:ConditionText>
                        <xsl:variable name="vCondition">
                            <xsl:value-of select="normalize-space(Description)"/>
                            <xsl:text> </xsl:text>
                            <xsl:for-each select="Parties/Party">
                                <xsl:for-each select="ancestor::ProtectionOrder/ProtectionOrderParties/ProtectionOrderParty[@InternalPartyID=current()/@InternalPartyID]">
                                    <xsl:value-of select="ProtectionOrderPartyNames/ProtectionOrderPartyName[@Current='true']/@FormattedName"/>
                                    </xsl:for-each>
                                    <xsl:if test="position() != last()">
                                    <xsl:text>; </xsl:text>
                                    </xsl:if>
                            </xsl:for-each>
                            <xsl:text> </xsl:text>
                            <xsl:for-each select="Addresses/Address">
                                <xsl:for-each select="ancestor::ProtectionOrder/ProtectionOrderParties/ProtectionOrderParty/MNProtectionOrderPartyAdditional/ProtectedAddresses/Address[@InternalAddressID=current()/@InternalAddressID]">
                                    <xsl:if test="AddressLine1">
                                        <xsl:value-of select="AddressLine1"/>
                                        <xsl:text>, </xsl:text>
                                    </xsl:if>
                                    <xsl:if test="AddressLine2">
                                        <xsl:value-of select="AddressLine2"/>
                                        <xsl:text>, </xsl:text>
                                    </xsl:if>
                                    <xsl:if test="AddressLine3">
                                        <xsl:value-of select="AddressLine3"/>
                                        <xsl:text>, </xsl:text>
                                    </xsl:if>
                                    <xsl:if test="AddressLine4">
                                        <xsl:value-of select="AddressLine4"/>
                                    </xsl:if>
                                    <xsl:text>; </xsl:text>
                                </xsl:for-each>
                            </xsl:for-each>
                        </xsl:variable>
                        <xsl:choose>
                            <xsl:when test="substring($vCondition,string-length($vCondition)-1,2)='; '">
                                <xsl:value-of select="substring($vCondition,1,string-length($vCondition)-2)"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$vCondition"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </ext:ConditionText>
                    <ext:ConditionCode>
                        <xsl:value-of select="document(concat($gEnvPath,'\ConfigFiles\MNCISCodes\ProtectionOrderConditionCodeMapping.xml'))
    /ProtectionOrderConditionCodeMapping/Mapping[MNCISCode=current()/Code/@Word]/BCACode"/>
                    </ext:ConditionCode>
                </ext:ProtectionOrderCondition>
            </xsl:for-each>
        </ext:ProtectionOrder>
    </xsl:template>
</xsl:stylesheet>

; 
, 
, 
, 
; 

可能是误解,但如果这样做,它不会像请求的那样工作吗

<xsl:for-each select="Parties/Party">
  <xsl:for-each select="ancestor::ProtectionOrder/ProtectionOrderParties
         /ProtectionOrderParty[@InternalPartyID=current()/@InternalPartyID]">
    <xsl:value-of select="ProtectionOrderPartyNames/
         ProtectionOrderPartyName[@Current='true']/@FormattedName"/>
      <xsl:if test="position() = last()">
        <xsl:text>; </xsl:text>
      </xsl:if>
  </xsl:for-each>
</xsl:for-each>
语句移动到
而不是内部循环应该写入
聚会
,则在每个
聚会之后进行code>

更新:有关评论中提到的问题的更新问题-我不知道我是否完全理解该问题。关于更新后的XSLT,应如下所示:如果有多个
参与方
,则为一个
position()!=拉斯维加斯
<xsl:variable name="addressCount" select="count(Addresses/Address)"/>
<xsl:for-each select="Parties/Party">
  <xsl:for-each select="ancestor::ProtectionOrder/ProtectionOrderParties
         /ProtectionOrderParty[@InternalPartyID=current()/@InternalPartyID]">
    <xsl:value-of select="ProtectionOrderPartyNames/
         ProtectionOrderPartyName[@Current='true']/@FormattedName"/>
  </xsl:for-each>
  <xsl:if test="position() != last() or (position() = last()
                and $addressCount &gt; 0)">
      <xsl:text>; </xsl:text>
  </xsl:if>
</xsl:for-each>
<xsl:if test="position() != last() or (position() = last() 
  and $addressCount &gt; 0)">
  <xsl:text>; </xsl:text>
</xsl:if>
<xsl:for-each select="Parties/Party">
   <xsl:for-each select="ancestor::ProtectionOrder/ProtectionOrderParties/ProtectionOrderParty[@InternalPartyID=current()/@InternalPartyID]">
   <xsl:value-of select="ProtectionOrderPartyNames/ProtectionOrderPartyName[@Current='true']/@FormattedName"/>
    <xsl:if test="position() = last()">
    <xsl:text>; </xsl:text>
    </xsl:if>
    </xsl:for-each>
</xsl:for-each>