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 December 27th, 2006, 05:52 AM
Authorized User
 
Join Date: Jun 2005
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rajatake
Default Finding all elments in between two tags

Hi,

Is it possible to find the entire elements in between the two xml elements?

input file

<match1>name</match1>
  <date></date>
  <place></place>
  <country></country>
  <teams>
    <team1/>
    <team2/>
 </teams>
<match2>name</match2>


I have to select all the elements in between match1 and match2 for my xslt. Can we write xpath for this scenario. i tried. but i couldn't able to deliver.

Regards,
Raja


 
Old December 27th, 2006, 04:35 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In XPath 2.0,

match1/following-sibling::* intersect match2/preceding-sibling::*

There's no intersect operator in XPath 1.0, but you can express

$a intersect $b

as

$a[count(.|$b) = count($b)]

However in XSLT 1.0 this kind of problem is often best tackled with a recursive template that processes the elements from match1 one by one until match2 is reached. For examples, google for "XSLT positional grouping" or "XSLT sibling recursion".

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Names within tags ? tjclifford XSLT 3 June 10th, 2008 08:33 AM
meta tags ferlach HTML Code Clinic 5 June 5th, 2007 04:17 PM
Need help regarding Custom Tags yamijala Dreamweaver (all versions) 0 December 27th, 2004 01:51 AM
How to read tags? FathimaSagar ASP.NET 1.0 and 1.1 Professional 1 January 14th, 2004 02:07 PM
Junk tags kilika Forum and Wrox.com Feedback 2 June 30th, 2003 04:57 PM





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