當我的xml代碼有聯繫人條件節點地址和派對元素時,在派對名稱後添加一個分號。 我不想在名稱後面輸入分號,因爲之後沒有任何其他內容。 這裏是輸出:如何在文本片段之間添加分號但不在文本片段的末尾?
答辯人在就業下列的地方(縣)以下方(IES)的訪問受到限制如下:布朗,萊恩**,** 1048區域RD,聖保羅,MN,55101
這裏我的輸出保持在條件文本元素的末尾顯示一個分號,即使只有一方的名字。 如何更改我的xslt,以便只有一個派對名稱時不會顯示此分號?
申請人被授予以下孩子的唯一身體和法定監護權:Brown,Rayne;
我的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>
我的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>
更新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>
「*我決定發佈一個新的職位,因爲它看起來像人們認爲前一個得到解決。*」請不要那樣做。 –
你有什麼建議?我應該刪除其中一個嗎? – user3781064
您是否注意到您近期收到的許多問題只會降低評論的質量並造成很多混淆?有時間回顧一下XSLT的基礎知識_並且[在SO上提出問題的基本知識](http://stackoverflow.com/help/how-to-ask)_and_ at [如何創建一個好的代碼示例]( http://stackoverflow.com/help/mcve)。 –