[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Retrieve node-set based on position relative to identic

Subject: Retrieve node-set based on position relative to identical siblings
From: Martin Kupisch <Kupisch@xxxxxxxxxxxxxx>
Date: Wed, 13 Nov 2002 14:20:55 +0100
position relative expression
Hello everyone,

I would like to build a node-set assigned to a variable that is used
throughout the stylesheet several times. The structure of the input is
as follows: there are lot of 'productGroup'-elements that contain
'product'-elements that contain further children. Each product contains
an 'id'-attribute. Each 'productGroup' can contain several 'products'
with identical ids. What I need to do is to select all products with
certain ids with a position relative to all products with the same id. I
try to illustrate with an example.

Input:

<productGroup>
    <product id ="a">        <-
    <product id ="a">        <-
    <product id ="a">
    <product id ="b">        <-
    <product id ="b">
    <product id ="c">
<productGroup>
<productGroup>
    <product id ="d">
    <product id ="e">        <-
    <product id ="e">        <-
<productGroup>

products with the same id are always siblings in the same productGroup.
The positons to choose are only known to my application so I provide
them as a parameter through my Java API to the stylesheet named
'positions' with a value like this:
    ;a:,1,2,;b:,1,;e:,1,2,;
which means for example take products with id 'a' that have position 1
and 2 relative to all a's and so on, ie take all products marked in the
example above.I tried the following expression to get these nodes:
'//product[contains(substring-before(substring-after($positions,
concat(';', @id, ':')), ';'), concat(',',
count(preceding-sibling::product[@id=./@id])+1, ','))]'
                            <-
(1)                                                         ->
<-
(2)                                               ->

<-                    (3)
->                                   <-
(4)                           ->
, which means for each product: get the substring after the string
containing the id at (3), for example ;a: up to the next ';' (1), for
example ,1,2, which would be the positions and decide wether (2) is
contained in $positions, that would be something like ,1,. I guess the
approach does not work because in the predicate in (4) the context node
switched and the expression always evaluates to true.

Any comments on the overall approach or any other suggestions how to
handle this problem?
Thanks for any help, Martin.


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.