[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Looping through attributes..

Subject: Re: Looping through attributes..
From: "Joe Meree" <jmeree1@xxxxxxxxxxx>
Date: Fri, 21 Mar 2003 08:21:45 -0500
select case startswith
I've spent a lot of time trying to avoid xsl:if and for-each by using apply-templates for everything. Is there a way to "apply-templates" to the attributes of an element? I'm thinking of something like this: <xsl:apply-templates select="./@*">. If this can be done, I could get rid if a lot of xsl:if statements that check for the presence of attributes.
Joe



From: David N Bertoni/Cambridge/IBM <david_n_bertoni@xxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Looping through attributes..
Date: Thu, 20 Mar 2003 14:34:31 -0800





> > > Okay, I'm looping through attributes. Now I need to determine if the
> > name
> > > of an attribute starts with a particular text expression. I have the
> > > following (and it doesn't work):
> > >
> > > <xsl:for-each select="@*">
> > > <xsl:if test="starts-with(@,'S')">
> > > ...
> > > </xsl:if>
> > > </xsl:for-each>
> > >
> > > Am I close???
> >
> > Yes:
> >
> > <xsl:for-each select="@*">
> > <xsl:if test="starts-with(.,'S')">
> > ...
> > </xsl:if>
> > </xsl:for-each>
> >
> > or even:
> >
> > <xsl:for-each select="@*[starts-with(.,'S')]">
> > ...
> > </xsl:for-each>
>
> whoa -- i just noticed that the original poster asked to select
> those attributes whose *names* started with 'S', not whose values
> started with 'S'.
>
> in case that's what he wanted, just use "starts-with(name(.), 'S')"
> instead. i think ...


Yes, you're right -- I replied without reading closely enough.  Glad to see
someone else did the same thing! ;-)

And since that's the case, local-name() might be more appropriate than
name().

What's that about great minds thinking alike...

Dave


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




_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail



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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.