INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

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

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

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

(OP)
I would like to display the word false instead of an empty string "" for the

CODE --> xml

<ext:AddressReference ext:currentIndicator=""> 
How do I do this?

My output which is wrong

CODE --> 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

CODE --> 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

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 --> xslt

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

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

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">
          <xsl:choose>
             <xsl:when test="@PartyCurrent">
                <xsl:value-of select="@PartyCurrent"/>
             </xsl:when>
             <xsl:otherwise>
              false
             </xsl:otherwise>
          </xsl:choose>
       </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.

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

(OP)
Thanks MakeItSo. That fixed it.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close