This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


> 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]