xml - How do I display specific text when an element has true in it? -


i have following element in xml document

<liveswithindicator>true</liveswithindicator> 

i when liveswithindicator has true display following

<xsl:text>juvenile lives parent/guardian/custodian</xsl:text> 

**otherwise when ** <liveswithindicator>false/liveswithindicator>

display

<xsl:text>juvenile not live parent/guardian/custodian</xsl:text> 

my xsl code

<xsl:value-of select="liveswithindicator"/> 

displays

juvenile lives parent/guardian/custodian: true 

this not want

you use xsl:choose here

<xsl:choose>    <xsl:when test="liveswithindicator='true'">        <xsl:text>juvenile lives parent/guardian/custodian</xsl:text>    </xsl:when>    <xsl:otherwise>        <xsl:text>juvenile not live parent/guardian/custodian</xsl:text>    </xsl:otherwise> </xsl:choose> 

alternatively, template based approach. create 2 templates so:

<xsl:template match="liveswithindicator[. = 'true']">     <xsl:text>juvenile lives parent/guardian/custodian</xsl:text> </xsl:template>  <xsl:template match="liveswithindicator">     <xsl:text>juvenile not live parent/guardian/custodian</xsl:text> </xsl:template> 

then can output value

<xsl:apply-templates select="liveswithindicator" /> 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -