[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] case insensitive attributes


Subject: RE: [xsl] case insensitive attributes
From: James Eberhardt <JEberhardt@xxxxxxxxxx>
Date: Thu, 5 Apr 2001 12:24:51 -0400

Since you should want to control your data, then what I would suggest is
translating your user input before putting in the XML.  That way UserId is
ALWAYS the same case.  Just my thought.  Otherwise I don't think you can
test for this in one XPath statement.  What you might try is do an
apply-templates, then within that template test the value of UserId.  Like
this:

<xsl:template match="/">
	<xsl:apply-templates select="//CamUsers" />
</xsl:template>

<xsl:template match="//CamUsers">
	<xsl:if test="translate(@UserId,'admin','ADMIN')='ADMIN'">
		<xsl:value-of select="." />
	</xsl:if>
</xsl:template>

The solution that Jeni was suggesting would check only if UserId was one or
the other.  (I think)



-----Original Message-----
From: Jay Gardner [mailto:jgardner@xxxxxxxxxxxxxxxxxxxxxx]
Sent: Thursday, April 05, 2001 12:09 PM
To: Jeni Tennison
Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] case insensitive attributes

Thanks Jeni

Actually, the all caps ADMIN was just for testing.

It could come in as Admin ADmin ADmiN or anything 
like that.  It comes from user input to a login form.

I ended up using this and it seems to be working, but
I am not sure how efficient it will be.

root/CamUsers[@UserId = translate(@UserId,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz') = 'Admin']

Regards,

Jay Gardner

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



Current Thread
Keywords