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

Re: Split and Found unique values

Subject: Re: Split and Found unique values
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 7 Dec 2006 14:42:01 GMT
Re:  Split and Found unique values
your posted input doesn't match your code,  <target:row is in a target
namespace but
match='xml/target' use=
woul match an element target in no namespace.

I don't think you want to do this:
                  <xsl:for-each select='$Rowset[generate-id() = generate-id(key("Category", @Category))]'>
as that handles each complete category separately, you want to stick
them all togeter first and then split/sort. so

so something like

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

 <xsl:output indent="yes"/>

<xsl:key name='Category' match='t:row' use='@Category'/>
<xsl:variable name='seen' select="''"/>
 
  <xsl:template match="x">
              <select name="x" multiple="multiple">
                     <xsl:call-template name="Split">
                         <xsl:with-param name="strInput">
<xsl:for-each select="t:row/@Category">
  <xsl:value-of select="."/>
  <xsl:if test="position()!=last()">-</xsl:if>
</xsl:for-each>
			 </xsl:with-param>
                     </xsl:call-template>
              </select>
</xsl:template>

if x is the parent of your target:row elements.


In XSLT2 it's just

<x xmlns:target="t">

       <target:row Category='A-B-C-D'/>
       <target:row Category='A-B'/>
       <target:row Category='A-C-D'/>
       <target:row Category='C'/>
       <target:row Category='B-C-D'/>
       <target:row Category='A-t'/>
</x>




<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:target="t" >

<xsl:output indent="yes"/>

<xsl:template match="x">
  <xsl:for-each select="distinct-values(target:row/tokenize(@Category,'-'))">
   <option><xsl:value-of select="."/></option>
  </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

$ saxon8 spl.xml spl.xsl
<?xml version="1.0" encoding="UTF-8"?>
<option xmlns:target="t">A</option>
<option xmlns:target="t">B</option>
<option xmlns:target="t">C</option>
<option xmlns:target="t">D</option>
<option xmlns:target="t">t</option>

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.