xslt, for-each exclusion

S

shaun

I'd like to do a for-each over a group of attributes except one specific
one.

e.g.

given an element like:

<gluteus_maximus snow_white="pert" queen="callipygous"
dwarf="dontGoThere"/>

I want to loop over both snow white and tinkerbell but not the dwarf.

I could do:

<xsl:for-each select="@*">
<xsl:if test="not(name()='dwarf')">
<!-- do stuff here -->
</xsl:if>
</xsl:for-each>

but is there a cleverer way of using the for-each selection criterion to
exclude only one element?

thanks

shaun
 
S

Steve Jorgensen

I'd like to do a for-each over a group of attributes except one specific
one.

e.g.

given an element like:

<gluteus_maximus snow_white="pert" queen="callipygous"
dwarf="dontGoThere"/>

I want to loop over both snow white and tinkerbell but not the dwarf.

I could do:

<xsl:for-each select="@*">
<xsl:if test="not(name()='dwarf')">
<!-- do stuff here -->
</xsl:if>
</xsl:for-each>

but is there a cleverer way of using the for-each selection criterion to
exclude only one element?

thanks

shaun

I think you should just be able to move the test into the predicate...

<xsl:for-each select="@*[not(name()='dwarf']">
<!-- do stuff here -->
</xsl:for-each>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top