ASP Error: 70
Description: Permission denied
Source: Microsoft VBScript runtime error

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

RE: Another Grouping question

Subject: RE: Another Grouping question
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 17 Feb 2005 12:32:45 -0000
xsl sibling next
$next-marker is a node, not a number, so comparing it with position() isn't
going to be useful.

You can use this approach in XSLT 2.0, where you would write

following-sibling::*[. << $next-marker]

but of course XPath 1.0 doesn't have the "<<" operator.

The usual way of tackling this in 1.0 is

<xsl:variable name="this" select="generate-id()"/>
<xsl:for-each
select="following-sibling::*[generate-id(preceding-sibling::marker[1])=$this
]">

that is, select all the following siblings whose first preceding marker is
the node you started at.

A recursive scan of the siblings is likely to be more efficient if there are
many of them.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Paul Clarke [mailto:pclarke@xxxxxxxxxxxxxxxx] 
> Sent: 17 February 2005 12:07
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Another Grouping question
> 
> Hello,
> 
> Thank you to those who responded to my previous question.
> 
> I now realise that the key to a lot of my current problems 
> are to create the
> correct groupings.
> 
> Before coming back to the list I spent a lot of time reading 
> Michael Kay's
> Programmer Reference but I'm still struggling with 
> constructing the correct
> predictate.
> 
> I have the following XML:
> 
> <frag>
> 	<p/>
> 	<p/>
> 	<table/>
> 	<list/>
> 	<marker/>
> 	<p/>
> 	<p/>
> 	<p/>
> 	<p/>
> 	<table/>
> 	<p/>
> 	<p/>
> 	<table/>
> 	<list/>
> 	<marker/>
> 	<p/>
> 	<p/>
> 	<table/>
> 	<list/>
> </frag>
> 
> I need to create a grouping that selects a marker element 
> followed by all
> its siblings up but not including to the next marker.
> 
> An attempted solution is shown below, but it didn't work. (No 
> chuckling
> please).
> 
> I've tried to do this by creating a template that matches a 
> marker and then
> calculating the position of the following-sibling::marker and 
> placing this
> in a variable. I then try to group all the required elements 
> by testing for
> the position of the context being less than the next marker.
> 
> <xsl:template match="marker">
> 	<xsl:variable name="next-marker"
> select="following-sibling::marker[1]"/>
> 	<xsl:variable name="chunk" select=". |
> following-sibling::*[position()&lt; $next-marker]"/>
> 	<div>
> 		<mblock><xsl:apply-templates select="$chunk"/></mblock>
> 	</div>
> </xsl:template>
> 
> Thanks
> 
> Paul Clarke 

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.