Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 31st, 2014, 02:40 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default How do I remove semi colon?

I would like to remove the trailing semi colon.
How do I do that? A semi colon is only needed when there is something after the name.

Output with a semi colon that I need to remove.
Code:
<ext:ProtectionOrderCondition>
	<ext:ConditionText>Petitioner is awarded sole physical and legal custody of the following child(ren): Brown, Rayne;  </ext:ConditionText>
	<ext:ConditionCode>09</ext:ConditionCode>
</ext:ProtectionOrderCondition>

My xml code
Code:
<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>
My xslt code
Code:
<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>
 
Old January 2nd, 2015, 12:25 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default

I resolved this. Here is the code.

Code:
<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>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Separation based on semi-colon justinferns Excel VBA 1 February 27th, 2012 01:44 PM
Looking for a good example of a Semi-Bound Form howardb1 Access VBA 0 April 24th, 2006 04:27 PM
Create a semi-colon delimited value rshano XSLT 1 January 14th, 2004 05:36 AM
(Semi) Automating Mail merge to Word Cryolith Access VBA 0 July 6th, 2003 10:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.