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

Re: normalize as part of a 'select-distinct' in a for-each?

Subject: Re: normalize as part of a 'select-distinct' in a for-each?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 4 Oct 1999 13:04:58 +0100 (BST)
select distinct replace
 

]   <xsl:for-each select="//c[not(normalize(text())
]                           =normalize(following::c/text()))]" >

You are making it hard for yourself by using for-each here, as then the
current node of the expression is the document root. You need to
get access to a c node and a following c node, and within a single
select expression the only way to do that is to arrange that one of them
is the current node.

This version uses apply-templates (and still works if you replace some
 <c>X</c> by <c> X   </c>, I just tried)

If this would clash with some other template for c then you could add
mode attributes to distinguish this processing.

David

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
                xmlns:xt="http://www.jclark.com/xt"
                extension-element-prefixes="xt">

  <xsl:template match="root">
     <xsl:apply-templates select="//c">
     <xsl:sort select="normalize(.)"/>
     </xsl:apply-templates>
  </xsl:template>


  <xsl:template match="c">
   <xsl:if test="not(following::c[normalize(.)=normalize(current())])">
   <xsl:value-of select="normalize(.)"/>
   </xsl:if>
  </xsl:template>

</xsl:stylesheet>


 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.