Subject:XPath descendant question Author:George George Date:11 May 2013 10:49 AM
I am confused as to why XStylus returns this results when running a query regarding the descendant axis.
I have the following XML file:
<!DOCTYPE BookStore System “BookStore.dtd”>
OwnerName =”Mr. Black”>
Title=”Introduction to reading”
Authors =”Ian Green”>
Title=”Introduction to Sleeping”
Authors =”Peter White”>
Name =”Ana Car” >
Name = “Mrs White”
Address = “150 Wide Road, London SW10”>
The document is well-formed and validates fine according to the tool. Now, I want to find the member of staff managed by the manager with ManagerID equal to MG444.
I use the following query:
/child::BookStore/descendant:Staff[@ManageID='MG444']; my rationale been that I am looking for the child element of BookStore that has a Staff descendant which has a ManagerID attribute with the specific value. Stylus Studio returns nothing. If I run /child::BookStore/descendant:Staff, I get the whole Staff element, not just Manager. Why is that - is descendant not supposed to only look at descendants, not the current node and ignore attributes? Likewise, why does the first query does not work?