At 2004-07-03 12:36 +0100, Arthur Maloney wrote:
How do specify an attribute in XPath?
@type is an attribute of an in-context element.
I've tried this, but it does not work.
<xsl:variable name="path" select="//hungarian/identifier[(_at_)name=@type]"/>
You are asking if the name attribute of identifier is equal to the type
attribute of identifier.
When I Hard code e.g. identifier[(_at_)name='asp:DropDownList'] it works.
Also using a variable, as below it works.
What is XPath grammar to avoid having to use a variable?
There isn't anything in XPath, but there is something in XSLT since it
looks like you are using XSLT.
I'm use this as a lookup (my problem: trying to avoid using variable
'test')
<xsl:variable name="test" select="@type"/>
<xsl:variable name="path" select="//hungarian/identifier[(_at_)name=$test]"/>
The current() function in XSLT returns the current node at the start of the
XPath expression.
So select="//hungarian/identifier[(_at_)name=current()/@type] will give you the
equivalent of the above, since in the above you are assigning to $test the
type attribute of the current node at the start of the following expression.
But your "//" syntax above could be very wasteful depending on how you use
it... if you have performance problems you should look into using keys.
I hope this helps.
..................... Ken
--
Public training 3 days XSLT & 2 days XSL-FO: Phoenix,AZ 2004-08-23
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal