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

RE: Matching elements with a name specified by an attribute value


Subject: RE: Matching elements with a name specified by an attribute value
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Fri, 20 Oct 2000 16:10:34 +0100

> Is it possible to match on elements where the names of the 
> elements to look
> for are specified as the attribute values of other elements 
> ie. the element
> name to match is specified at processing time?
> 
> Consider the example source XML...
> 
> <layout>
>   <layout_item data_element="item1"/>
>   <layout_item data_element="item2"/>
>   <layout_item data_element="item3"/>
> </layout>
> 
> <item1>I am item 1</item1>
> <item2>I am item 2</item2>
> <item3>I am item 3</item3>
> 
You can do //*[name()=@data-element]

But this is not a nice document design. Element tags are intended for
identifying types, not instances. To identify instances, you should use an
id attribute: <item id="item1">

Mike Kay 


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



Current Thread