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

Node list operations

Subject: Node list operations
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 08 May 1999 16:28:47 -0400
list operations
Hi all,

XSLT 19990421 is considered "feature complete", yet I've come across what I
think may represent the need for a frequently-used facility I cannot find
in the working draft.

I'm hoping someone on the list can show me if the following problem can,
indeed, be solved with Working Draft 19990421, because I've tried a lot of
things and keep getting caught up in the prewired document order of the axes.

First, here is a problem that I think will be a frequent need that I was
able to solve in a straightforward fashion, that of suppressing redundant
entries in a table:


<?xml version="1.0"?>


 X   Y   Z
 1   1   a
     2   b
     3   c
 2   1   d
     2   e
 3   1   f

..... suppressing redundant values for X.

This was really straightforward because the document order is in sorted order:

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">

<xsl:template match="/">                    <!--root rule-->
> X   Y   Z
  <xsl:apply-templates mode="next" select="//w"/>

<xsl:template name="show-entry">
  <xsl:param-variable name="x-value" expr="' '"/>
  <xsl:text> </xsl:text><xsl:value-of select="$x-value"/>
  <xsl:text>   </xsl:text><xsl:value-of select="y"/>
  <xsl:text>   </xsl:text><xsl:value-of select="z"/><xsl:text>

<xsl:template mode="next" match="*">
  <xsl:variable name="this" expr="x"/>
    <xsl:when test="not(from-preceding-siblings(w[x=$this]))">
      <xsl:call-template name="show-entry">
        <xsl:param name="x-value" expr="$this"/>
      <xsl:call-template name="show-entry"/>


Now, consider the problem where I want the same output from an unsorted

<?xml version="1.0"?>

Given that all the axes are interpreted with candidate nodes in document
order, not node-set order, I cannot find a way to solve this problem with
the proposed XSLT 1.0.  Every time I try to "look back" to previous
siblings in the node set, the axes available to me constrain me to document
order, not to the node-set order.  Same thing when I try to "walk" through
a node list, since subsetting the node list using apply-templates again
interprets the axes in document order.  Going through the axes, each
non-attribute one explicitly states it orientation with respect to document

I think I could solve it if I had a more complete set of node list
operations along the lines of:

  (1) - either: assign context node list to a variable
            or: allow <xsl:sort> as a child of <xsl:variable> for use when
the exprssion is a NodeSetExpr
  (2) - node-list-first( nodeSetExpr ) (or a node set preceding axis)
  (3) - node-list-rest( nodeSetExpr ) (or a node set following axis)

and then use call-template with variables and "walk through" the sorted
node set.

.... but I recognize it is *not* in the spirit of the current review of the
working draft to be suggesting new features (unless absolutely necessary?),
so I'm trying to solve this problem using the current working draft.

I recognize this can be done in a two-pass fashion, sorting the information
first into a new XML file and then working with the various document-order
axes to get the desired result.

So, my question is, can this problem be solved with the proposed working
draft in a single pass, and if not, is it important enough a problem that
it should be solved with version 1.0?

Thanks for any ideas you may have.

.............. Ken

G. Ken Holman                  mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.           http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0  +1(613)489-0999  (Fax:-0995)
Website: XSL/XML/DSSSL/SGML services outline,  XSL/DSSSL shareware,
         stylesheet resource library, conference training schedule,
         commercial stylesheet training materials, on-line XSL CBT.
Next instructor-led XSLT Training:                  WWW8:1999-05-11

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

Current Thread


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.
First Name
Last Name
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.