xsl-list
[Top] [All Lists]

XPath without using variable ?

2004-07-03 04:36:41
Hello xsl-list,


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]"/>

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?

[Code]
<xsl:for-each select="./control">

  Example of in context element, its looping through:

  <control type="asp:DropDownList">
         <name>Prefix</name>
         <description>A person's formal prefix e.g. Mr, Mrs.</description>
  </control>

  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 element it found i.e. assigned to $path (it is correct).
<identifier name="asp:DropDownList" prefix="ddl" suffix="DropDownList" 
type="DropDownList"/>




...
</xsl:for-each>

-- 
Best regards,
 Arthur                          mailto:ArthurM(_at_)seipas(_dot_)com



<Prev in Thread] Current Thread [Next in Thread>