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
Post a Comment