Is it possible to use the command on attributes? I want this to be able to run without knowing the attribute names. Here's a quick (terrible) example:
<candy hard="true" soft="false" stripes="true" solid="false">
In my head (this doesn't work) it should look something like this:
<xsl:for-each select="candy/@[@='true']">
Is there a way around this to run through attributes without knowing their name, or do I need to write each attribute being looked at?
Edit
Heres an example of me trying to create a variable out of the attribute name where value='true'
<xsl:for-each select="candy/@*[. = 'true']">
<xsl:attribute name="candytype">
<xsl:value-of select="name()"/>
</xsl:attribute>
<xsl:text> </xsl:text>
<xsl:for-each>
OP's comment:
can I return each attribute name (not value) whose value='true'?
<xsl:for-each select="candy/@*[. = 'true']">
<xsl:value-of select="name()"/>
<xsl:text> </xsl:text>
<xsl:for-each>
In XSLT 2.0 simply evaluate this XPath (2.0) expression:
candy/@*[. = 'true']/concat(name(.), ' ')
What you want is
<xsl:for-each select="candy/@*">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With