This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: local-name of attribute values
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: Oliver Becker <obecker at informatik dot hu-berlin dot de>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Fri, 15 Feb 2002 09:51:53 +0000
- Subject: Re: [xsl] local-name of attribute values
- Organization: Jeni Tennison Consulting Ltd
- References: <200202150927.g1F9RIL29810@mail.informatik.hu-berlin.de>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Oliver,
> I have an attribute base="ns:type" and want to get the local name of
> the value, i.e. "type" in this case. Obviously this is the substring
> after ':'. If there is base="type" then it is the whole string.
>
> A single XPath expression for this could be
>
> concat(substring(substring-after(@base,':'),
> 1 div contains(@base,':')),
> substring(@base,
> 1 div not(contains(@base,':'))))
>
> Does anybody know a shorter XPath 1.0 solution? (I need this as an
> expression for xsl:key)
It's not much shorter, but you could use:
substring(@base,
string-length(substring-before(@base, ':')) + 1 +
contains(@base, ':'))
or:
substring(translate(@base, ':', ''),
string-length(substring-before(@base, ':')) + 1)
or, if you're using MSXML4:
msxsl:local-name(@base)
I'm sure that if David C. were around he'd come up with something...
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list