This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: match on attribute anywhere


Here is another one, really the same process but substituting for-each
in place of the extra mode.  

In your existing templates, replace all occurences of
     <xsl:apply-templates />
by
     <xsl:call-template name="do-children" />

then:

<xsl:template name="do-children">
    <xsl:for-each select="node()">
        <xsl:choose>
             <xsl:when test="@mark='1'">
                 <span style="color:#FF0000">
  	<xsl:apply-templates select="." />
                 </span>
             </xsl:when>
             <xsl:otherwise>
                  <xsl:apply-templates select="." />
             </xsl:otherwise>
        </xsl:choose>
    </xsl:for-each>
</xsl:template>

I'm not sure I like this one as much: if you have anything except a
plain xsl:apply-templates (for example you want to select just some of
the children) you end up having to write another template like the one
above, because you cannot pass the select expression in as a parameter
(without using an extension function like 'evaluate').
                  
Let me know when you find a solution you like, then I will shut up ;-)

Regards,
Trevor Nash
--
Traditional training & distance learning,
Consultancy by email

Melvaig Software Engineering Limited
voice:     +44 (0) 1445 771 271 
email:     tcn@melvaig.co.uk

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]