How do I get XSLT to get the attributes within the name of my tag item, only if it is true?

0

<bloco>

   <item nome="imagem">true</item>
    <item nome="imagem">false</item>

</bloco>

    
asked by anonymous 02.10.2017 / 15:00

1 answer

0

Use a template to select all elements item , test content value (using . or node() or text() ) and print the value of the nome attribute if the content is equal to the string 'true' .

Here is an example style sheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    version="1.0">

    <xsl:output method="text"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="item">
        <xsl:if test=". = 'true'">
            <xsl:value-of select="@nome" />
        </xsl:if>
    </xsl:template>

</xsl:stylesheet>
    
04.12.2017 / 21:45