Hi Enric,
An attribute is not of type ID unless it is defined to be so in the
DTD. I.e., it does not suffice to name it "id" as in the example
below. However, you can solve this problem using xsl:key and key() as
follows:
1) Define a key in your stylesheet:
<xsl:key name="departments" match="Department" use="@id"/>
2) The following XPath should then evaluate to a nodeset with the
Department element in it:
key('departments', //Employee[Name='Jeff']/@DepartmentRef)
Hope this helps.
-- Santiago
On Feb 28, 2006, at 9:57 AM, Enric Jaen wrote:
Hi,
Could someone give me a clue about how to use the idref attribute
to select an element?
For example, in the following document:
<Company>
<Departments>
<Department id="d1">
<Name>Enterprise Development</Name>
</Department>
<Department id="d2">
<Name>Foundation Services</Name>
</Department>
</Departments>
<Employees>
<Employee DepartmentRef="d1">
<Name>Jeff</Name>
</Employee>
<Employee DepartmentRef="d1">
<Name>Mike</Name>
</Employee>
<Employee DepartmentRef="d2">
<Name>Sam</Name>
</Employee>
</Employees>
</Company>
I'd like to obtain the Department name of Employee Jeff. How can
this be done?
I guess I have to use the id() function, but I don't manage to
solve this.
Any help will be appreciated.
Regards,
-Enric