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 November 14th, 2011, 01:15 PM
Authorized User
 
Join Date: Oct 2011
Posts: 30
Thanks: 2
Thanked 0 Times in 0 Posts
Default next sibling

I have a similar xml document as below

<name>anthony</name>
<family>smith</family>
<name>steven</name>
<family>jones</family>
<name>peter</name>
<family>sales</family>
<name>laura</name>
<family>simpson</family>
<name>derek</name>
<family>trotter</family>

Trying to access each <name> <family> pair seperately to run a transfrom on each one.

However, each time my transform is accessing a <name> elelement and I call a following-sibling::family
it accesses all the following <family> siblings> when i just want the next one..
can anyone suggest how to do this.
thanks
 
Old November 14th, 2011, 01:19 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Use a positional predicate: following-sibling::family[1]
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old November 14th, 2011, 01:56 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

That should of course be following-sibling::family[1].

Alternatively, redesign the XML. Add a wrapper element around each (name, family) pair to better reflect the true structure.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
For each with following-sibling bonekrusher XSLT 2 July 15th, 2009 02:18 PM
Want to Pull multiple following-sibling data to preceding-sibling element sameer_kadam XSLT 4 May 9th, 2009 08:07 AM
How to use the following::sibling Nagaraj XSLT 4 April 30th, 2009 10:37 AM
following-sibling. hanzelko XSLT 1 February 2nd, 2007 04:11 PM
MDI Sibling calling Sibling... Nick.Net VB.NET 2002/2003 Basics 1 December 8th, 2003 09:23 PM





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