RE: [xsl] node selection problem

Subject: RE: [xsl] node selection problem
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 10 Mar 2004 11:06:52 -0000
If you want to do this efficiently I would recommend using a processor that
offers "intersect", which is a built-in operator in XSLT 2.0 and available
as an extension in EXSLT for 1.0 processors.

Michael Kay

# -----Original Message-----
# From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-
# list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Jakob
# Sent: 10 March 2004 08:16
# To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
# Subject: [xsl] node selection problem
# 
# Hi,
# 
# I would like to retrieve all the nodes "X" inside one
# node, but before another node.  The second node is always
# a descendant of the first node.
# 
# book
# +-- chap
# +-- chap            <== inside this node
#     +-- X           <== select this node
#     +-- sect
#         +-- X       <== select this node
#         +-- sub     <== but before this node
#             +-- X   <== i.e. do not select this X node
#         +-- sub
#         ...
#     +-- sect
#     +-- sect
#     ...
# +-- chap
# ...
# 
# 
# This example is somewhat simplified, of course.
# Currently, my best bet is this:
# 
# <xsl:variable name="inside.this.node"
# select="/book/chap[2]"/>
# <xsl:variable name="before.this.node"
# select="$inside.this.node/sect[1]/sub[1]"/
# 
# <xsl:variable name="the.X.nodes"
#   select="$before.this.node/preceding::X[
#     ancestor::*[@ID=$inside.this.node/@ID]
#   ]"
# />
# 
# This method doesn't seem very efficient given that it must
# first select all preceding X nodes, and then filters this
# nodeset using the predicate that matches ID values.
# 
# As I have to do this many times over a big document, I
# would be interested in better ways.
# 
# Thank you,
# --
# Jakob.
# 
# PS: I am subscribed to the list digest, please cc: me.
# 
# 
# 
# 
#  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread