RE: [xsl] Looping through attributes..

Subject: RE: [xsl] Looping through attributes..
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Thu, 20 Mar 2003 17:12:50 -0500
[Karl Stubsjoen]
> 
> 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>
> 

How you might wanat to do this could depend on what you really awnt to
accomplish and whether those attribute names might change from time to
time, or might be contained somewhere in the source xml document.

I would look at selecting just the attributes that you want.  If you
want to look for several different strings, and perhaps you would want
to pass these strings in as parameters in the future,  it could go like
this -

<xsl:variable name='att1' select='"S"'/>
<xsl:variable name='att2' select='ID'/>

<xsl:for-each select='@*[starts-with(name(.),$att1)]
   | @*[starts-with(name(.),$att2)]'>
   ...
</xsl:for-each>

Cheers,

Tom P

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


Current Thread