XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
George GeorgeSubject: XPath descendant question
Author: George George
Date: 11 May 2013 10:49 AM
Dear All,

I am confused as to why XStylus returns this results when running a query regarding the descendant axis.

I have the following XML file:

<?xml version=”1.0”?>
<!DOCTYPE BookStore System “BookStore.dtd”>
Name =”CheapBooks”
OwnerName =”Mr. Black”>
BookID =”BK111”
Title=”Introduction to reading”
Authors =”Ian Green”>

BookID =”BK112”
Title=”Introduction to Sleeping”
Authors =”Peter White”>
StaffID =”S333”
Name =”Ana Car” >
<Manager ManagerID=”MG444”
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?


Ivan PedruzziSubject: XPath descendant question
Author: Ivan Pedruzzi
Date: 12 May 2013 07:48 PM
In the XML sample there are few problems

in the DTD declaration system has to be all uppercase
<!DOCTYPE BookStore SYSTEM "booktore.dtd">

You also may have copy and paste the XML frmagment from Word or some other editor which turned " to ” amd made the XML not well formed

The shorthand expression you are looking for is the following, which returns Staff elements that has at least one direct child Manager with attribute ManagarID equal to MG444


Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.