Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 25th, 2007, 01:54 PM
Registered User
 
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Complex predicate question

Hi folks,

I am working with an xml document that has the form (obviously there is more to it, but this is the relevant bit):

<object>
   <hasOne>
      <relate from="xxx" />
   </hasOne>
</object>

I am trying to write an XPath (1.0) expression that selects all the <hasOne> nodes which have a <relate> node which have a specific 'from' attribute. I came up with:

"/object/hasOne[/descendant::relate/attribute::from='zzz']"

but it's not working for me. Any thoughts? Thanks in advance,

=dave=

 
Old February 25th, 2007, 02:04 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

/ means you want to start from the root. Assuming relate is always a child of hasOne and object is the document element then:
Code:
/object/hasOne[relate/@from = 'xxx']
should do it.

--

Joe (Microsoft MVP - XML)
 
Old February 25th, 2007, 02:16 PM
Registered User
 
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Joe;

That is what I thought too... no joy.

=dave=

 
Old February 25th, 2007, 02:20 PM
Registered User
 
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oops... my bad.

Joe, you are correct, I had tried: /object/hasOne[/relate...
not: /object/hasOne[relate...

What a difference a slash makes! Thanks for such a prompt and helpful response.

=dave=

 
Old February 25th, 2007, 02:21 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well if you have read the first post in this section regarding namespaces and that does not apply then you need to post the full XML and show the relevant XSLT too.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
A problem with predicate in XSLT1.0:( sureshk XSLT 1 March 8th, 2006 01:13 PM
SUM function with DISTINCT predicate saturdave SQL Server ASP 1 April 8th, 2004 10:44 PM
Predicate question pdamer XSLT 3 November 19th, 2003 11:30 AM
Predicate not being checked properly JeanFrancois XSLT 2 June 16th, 2003 09:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.