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 June 24th, 2010, 08:48 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default Select the first descendant that meets a condition

Hi,

I am trying to select the first descendant that meets a condition.

For example:

Code:
<data>
    <dmodule>
        <content>
            <descript/>
        </content>
    </dmodule>
    <dmodule>
        <content>
            <proced>
                <prelreqs/>
            </proced>
        </content>
    </dmodule>
    <dmodule>
        <content>
            <proced>
                <prelreqs/>
            </proced>
        </content>
    </dmodule>
</data>
if my context node is <data> and I want to process only the first <prelreqs> that is a descendant of data.

I have tried:

Code:
<xsl:apply-templates select="dmodule[descendant::prelreqs[1]]/content/proced/prelreqs"/>
but this processes all the first prelreqs that are descendants of dmodule.

Thanks for the help.
 
Old June 24th, 2010, 08:53 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Why not simply
Code:
<xsl:apply-templates select="descendant::prelreqs[1]"/>
? That seems to be the direct "translatation" of your English description into an XPath.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old June 24th, 2010, 09:54 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Thank you the help. I was over thinking it.





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT descendant axis problem sarcanon BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 4 November 14th, 2009 10:20 PM
Using the If Condition bex ASP.NET 3.5 Basics 2 June 30th, 2009 02:34 AM
or condition kgoldvas XSLT 1 July 31st, 2007 03:44 AM
preceding-sibling descendant xaun XSLT 3 February 28th, 2006 02:48 PM
Supress record when running total in group meets c ldejesuspr Crystal Reports 1 July 28th, 2004 11:10 PM





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