xml - My output shows semi colon between two parties but also with one party -
my xml code can have 1 or more parties in status text. when there more 1 parties, semi colon inserted between 2 party names. if there 1 party, there no need of semi colon @ end of name. xslt working fine when xml document has 2 parties still adding semi colon when there 1 party. how display semi colon when xml document has more 1 party , not display semi colon when xml document has 1 party?
here output 2 parties want semi colon between names (party): addresses out of order. each party name should followed address semi colon , other name address , period @ end.
<ext:protectionordercondition> <ext:conditiontext>respondent must not phone call or come in place of employment of next party(ies). includes land, parking lots, , buildings of next addresses: petitioner, richard s; dickens, little; 3 petitioner st, town, mn, 55555; foreign address, fa line 2, fa line 3, fa line 4</ext:conditiontext> <ext:conditioncode>04</ext:conditioncode> </ext:protectionordercondition>
here output when xml document has 1 party. notice there semi colon @ end should not there:
<ext:protectionordercondition> <ext:conditiontext>petitioner awarded sole physical , legal custody of next child(ren): brown, rayne; </ext:conditiontext> <ext:conditioncode>09</ext:conditioncode> </ext:protectionordercondition>
my xml code 1 party
<protectionorder op="e" internalprotectionorderid="2563"> <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> <mnprotectionorderpartyadditional xmlns:fn="http://www.w3.org/2005/xpath-functions"> <doesresidewithrespondent>false</doesresidewithrespondent> <protectedaddresses> <address internaladdressid="1618211259" type="standard"> <location word="home">home</location> <confidential>false</confidential> <addressline2>1048 regions rd</addressline2> <addressline4>st paul, mn, 55101</addressline4> <block>1048</block> <street>regions</street> <addrsfxky word="rd">road</addrsfxky> <city>st paul</city> <state>mn</state> <zip>55101</zip> <foreign>false</foreign> <timestampcreate>12/29/2014 08:14:22:787</timestampcreate> </address> </protectedaddresses> </mnprotectionorderpartyadditional> </protectionorderparty> </protectionorderparties> <mnprotectionorderadditional internalid="2559" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <conditions> <condition> <code word="04aoahc">04.a respondent shall not call/enter place of employment</code> <description>respondent shall not phone call or come in petitioner's place of employment includes land, parking lots, , buildings at:</description> <addresses> <address internaladdressid="1618211259"/> </addresses> </condition> <condition> <code word="05oahc">05 petitioner awarded sole physical , legal custody</code> <description>petitioner awarded sole physical , legal custody of next child(ren):</description> <parties> <party internalpartyid="1614450754"/> </parties> </condition> </conditions> </mnprotectionorderadditional> </protectionorder>
my xml document 2 parties:
<protectionorder op="e" internalprotectionorderid="2571" xmlns:user="http://tylertechnologies.com"> <protectionorderparties> <protectionorderparty internalpartyid="1614451562"> <protectionorderpartynames> <protectionorderpartyname current="true" internalnameid="1615263003" formattedname="petitioner, richard s"/> </protectionorderpartynames> <added>12/29/2014</added> <protectionorderconnection> <petitioner>true</petitioner> <filingparty>false</filingparty> <protectedparty>true</protectedparty> <minor>false</minor> </protectionorderconnection> <mnprotectionorderpartyadditional xmlns:fn="http://www.w3.org/2005/xpath-functions"> <doesresidewithrespondent>false</doesresidewithrespondent> <protectedaddresses> <address internaladdressid="1618211271" type="standard"> <location word="home">home</location> <confidential>false</confidential> <addressline2>3 petitioner st</addressline2> <addressline4>my town, mn, 55555</addressline4> <block>3</block> <street>back petitioner</street> <addrsfxky word="st">street</addrsfxky> <city>my town</city> <state>mn</state> <zip>55555</zip> <foreign>false</foreign> <timestampcreate>12/29/2014 10:11:36:903</timestampcreate> </address> </protectedaddresses> </mnprotectionorderpartyadditional> </protectionorderparty> <protectionorderparty internalpartyid="1614451515"> <protectionorderpartynames> <protectionorderpartyname current="true" internalnameid="1615262953" formattedname="dickens, little"/> </protectionorderpartynames> <added>12/29/2014</added> <protectionorderconnection> <petitioner>false</petitioner> <filingparty>false</filingparty> <protectedparty>true</protectedparty> <minor>true</minor> </protectionorderconnection> <mnprotectionorderpartyadditional xmlns:fn="http://www.w3.org/2005/xpath-functions"> <doesresidewithrespondent>false</doesresidewithrespondent> <protectedaddresses> <address internaladdressid="1618211278" type="foreign"> <location word="daycare">daycare</location> <confidential>false</confidential> <addressline1>foreign address</addressline1> <addressline2>fa line 2</addressline2> <addressline3>fa line 3</addressline3> <addressline4>fa line 4</addressline4> <foreign>true</foreign> <timestampcreate>12/29/2014 11:49:37:020</timestampcreate> </address> </protectedaddresses> </mnprotectionorderpartyadditional> </protectionorderparty> </protectionorderparties> <mnprotectionorderadditional internalid="2567" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <conditions> <condition> <code word="03aexpc">03.a respondent must not commit domestic abuse</code> <description>respondent must not commit acts of domestic abuse against protected person(s). means respondent may not harm or cause fear of harm protected person(s), , respondent may not use, effort use, or threaten utilize physical forcefulness reasonably expected cause bodily injury protected person(s).</description> </condition> <condition> <code word="03f1expc">03.f.1 respondent must not call/enter place of employment</code> <description>respondent must not phone call or come in place of employment of next party(ies). includes land, parking lots, , buildings of next addresses:</description> <parties> <party internalpartyid="1614451562"/> <party internalpartyid="1614451515"/> </parties> <addresses> <address internaladdressid="1618211271"/> <address internaladdressid="1618211278"/> </addresses> </condition> </conditions> </mnprotectionorderadditional> </protectionorder>
my xslt 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>
what need alter in xslt semi colon inserted when there more 1 name , not inserted when there 1 name?
the standard idiom instead of
<xsl:text>; </xsl:text>
use:
<xsl:if test="position() != last()"> <xsl:text>; </xsl:text> </xsl:if>
xml xslt
No comments:
Post a Comment