Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I add the word/boolean false to an empty string?

Status
Not open for further replies.

momo2000

Programmer
Jan 2, 2015
63
0
0
US
I would like to display the word false instead of an empty string "" for the
XML:
<ext:AddressReference ext:currentIndicator="">
How do I do this?

My output which is wrong
XML:
<ext:AddressReference ext:currentIndicator="true">
    <nc:LocationReference s:ref="INT10566286"/>
</ext:AddressReference>
<ext:AddressReference ext:currentIndicator="">
    <nc:LocationReference s:ref="INT4279606"/>
</ext:AddressReference>

Desired output adds the word false to the empty string
XML:
<ext:AddressReference ext:currentIndicator="true">
    <nc:LocationReference s:ref="INT10566286"/>
</ext:AddressReference>
<ext:AddressReference ext:currentIndicator="false">
    <nc:LocationReference s:ref="INT4279606"/>
</ext:AddressReference>

My xml code
XML:
<Address PartyCorrespondence="true" PartyCurrent="true" ID="10566286" Type="Standard">
    <AddressLine2>772 Minnesota AVE</AddressLine2>
    <AddressLine4>Big Lake, MN, 55309</AddressLine4>
    <Street>Minnesota</Street>
    <City>Big Lake</City>
    <State>MN</State>
    <Zip>55309</Zip>
</Address>
<Address ID="4279606" Type="Non Standard">
    <AddressLine1>8435 OAK LANE</AddressLine1>
    <AddressLine4>BECKER, MN, 55308</AddressLine4>
    <City>BECKER</City>
    <State>MN</State>
    <Zip>55308</Zip>
</Address>

My xslt code
Code:
<xsl:for-each select="Address">
    <ext:AddressReference>
        <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>
    </ext:AddressReference>
</xsl:for-each>
 
Hi there!

So, basically you need to apply "false" if there is no PartyCurrent attribute present in the xml?

Should work along the line of this (warning: untested):
Code:
<xsl:for-each select="Address">
    <ext:AddressReference>
        <xsl:attribute name="ext:currentIndicator">
          [COLOR=#EF2929]<xsl:choose>
             <xsl:when test="@PartyCurrent">
                <xsl:value-of select="@PartyCurrent"/>
             </xsl:when>
             <xsl:otherwise>
              false
             </xsl:otherwise>
          </xsl:choose>[/color]
       </xsl:attribute>
   <nc:LocationReference>
       <xsl:attribute name="s:ref"><xsl:text>INT</xsl:text><xsl:value-of select="@ID"/></xsl:attribute>
   </nc:LocationReference>
    </ext:AddressReference>
</xsl:for-each>

Good luck!

MakeItSo

ôKnowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.ö (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top