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

Re: looping, moving through elements??

Subject: Re: looping, moving through elements??
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 24 Oct 2003 11:32:22 +0100
xsl loop through elements
".|following-sibling::ve"

.                     selects the current node
following-sibling::ve selects the following ve nodes.
|                     is the union of these selections.

as the current node is a ve this is just
following-sibling-or-self::ve
except that there is no such axis.


<vss>
<ve pos="1">content1</ve>
<ve pos="1.1">content1.1</ve>
  ^^^ so if you are here
      then .|follwing-sibling::ve selects this node and all the
      ve nodes below.

     This node will be indexed by teh key as it matches match="ve"

   <xsl:key name="x" match="ve"
   use="(.|folowing-sibling::ve)
     [string-length(@pos)=3+string-length(translate(@pos,'.',''))][1]/@pos"/>

   and its key will be the value of the use expression which is
   (once you spell check folowing:-)
   the pos attribute (/@pos) of the first ([1]) ve element thathas three
   "." ([string-length(@pos)=3+string-length(translate(@pos,'.',''))])
   so that is  pos="1.1.1.1"

   so key('x','1.1.1.1') would retrun this node and any other nodes with
   the same key, which is
     <ve pos="1"><ve pos="1.1"><ve pos="1.1.1"><ve pos="1.1.1.1">
   
   so all you have to do is loop through all the 3-dot ones, making a
   row for each, then look up in the key and that will return all the
   nodes to go in that row, hence the inner for-each.

   

<ve pos="1.1.1">content1.1.1</ve>
<ve pos="1.1.1.1">content1.1.1.1</ve>
<ve pos="1.1.2">content1.1.2</ve>
<ve pos="1.1.2.1">content1.1.2.1</ve>
<ve pos="1.1.2.2">content1.1.2.2</ve>
<ve pos="1.2">content1.2</ve>
<ve pos="1.2.1">content1.2.1</ve>
<ve pos="1.2.1.1">content1.2.1.1</ve>
<ve pos="1.2.1.2">content1.2.1.2</ve>
<ve pos="1.2.1.3">content1.2.1.3</ve>
<ve pos="1.2.2">content1.2.2</ve>
<ve pos="1.2.2.1">content1.2.2.1</ve>
<ve pos="1.3">content1.3</ve>
<ve pos="1.3.1">content1.3.1</ve>
<ve pos="1.3.1.1">content1.3.1.1</ve>
<ve pos="2">content2</ve>
<ve pos="2.1">content2.1</ve>
<ve pos="2.1.1">content2.1.1</ve>
<ve pos="2.1.1.1">content2.1.1.1</ve>
</vss>


David

(where's the list auto-documentation daemon gone when you need it:-)


-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 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.