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

Re: one key or a whole bunch?

Subject: Re: one key or a whole bunch?
From: "paul morgan" <pmorg@xxxxxxxxx>
Date: Wed, 22 May 2002 05:58:21 -0700
one key set
Saxon has its own "node-set" extension built-in, so you don't need to use the "exsl" version.

Following is the description of Saxon's "node-set" function from Michael Kay's book:

"This function is a hangover from XSLT 1.0, which does not allow conversion of a tree to a node-set.  It performs the conversion explicitly.  This function is no longer needed because Saxon (following the draft XSLT 1.1 specification) will do the conversion automatically when required."

So if I read this correctly, you may not actually need to explicitly invoke "node-set".

Hope this helps,

Paul


--

On Wed, 22 May 2002 03:30:31  
 Marina Sorreta wrote:
>Hi Jenni,
>
>Many thanks for your help, indeed I was looking for a
>one step
>solution and it was not possible. I have tried to
>implement the
>solution but am having problems with the declaration
>of the
>exsl node set. (I am using Saxon)
>
>I downloaded the exsl zip file and copied
>exsl.node-set.xsl into the
>same directory as the stylesheet. Then I declared it
>as below:-
>
>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>xmlns:exsl="http://www.exslt.org/common"
>extension-element-prefixes="exsl">
><xsl:import href="exsl.node-set.xsl" />  <--- line 5
>
>and I get the error message: -
>
>
>C:\saxon>saxon -o output.txt test.xml shelves.xsl
>Error at xsl:import on line 5 of
>file:/C:/saxon/shelves.xsl:
>  no more input
>Transformation failed: Failed to compile stylesheet. 1
>error detected.
>
>
>So it looks as though I've declared the exsl
>incorrectly. How should it be done?
>
>Thanks again,
>
>Marina
>
>
>--- Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> wrote:
>> Hi Marina,
>> 
>> > I need to get a count of all the groups of
>> <SHELF_NO>'s that are the
>> > same. I need the output to be in the form (with
>> the example above):-
>> >
>> > Shelf Groups   Number of Copies
>> > 0   0 <--i.e. no instance of no shelf number
>> > 1   1 <--i.e. 1 instance of just one unique shelf
>> number
>> > 2   0 <--i.e no instance of two shelf numbers the
>> same
>> > 3   1 <--i.e. 1 instance where three shelf numbers
>> were the same
>> > etc etc
>> 
>> If I understand you properly, that's quite a
>> difficult analysis to do,
>> especially in one step. The best thing to do would
>> be to break it down
>> into two steps:
>> 
>>   - create a list of the unique shelf numbers and
>> the number of
>>     occurrences of each of those shelf numbers
>> 
>>   - use a recursive template to go up through the
>> possible numbers of
>>     repeats, and count how many there are of each.
>> 
>> The first step involves your kShelf key:
>> 
>> <xsl:key name="kShelf" match="SPORTS | LEISURE |
>> CLOTHES | GIFTS"
>>          use="SHELF_NO"/>
>> 
>> To create the node set of unique SHELF_NO elements,
>> you need to use
>> the Muenchian method, as you'd started doing:
>> 
>>   <xsl:variable name="shelves-rtf">
>>     <xsl:for-each select="SHOP/*[generate-id() =
>>                                 
>> generate-id(key('kShelf',
>>                                                 
>> SHELF_NO)[1])]">
>>       <SHELF_NO count="count(key('kShelf',
>> SHELF_NO))">
>>         <xsl:value-of select="SHELF_NO" />
>>       </SHELF_NO>
>>     </xsl:for-each>
>>   </xsl:variable>
>>   <xsl:variable name="shelves"
>> select="exsl:node-set($shelves-rtf)" />
>> 
>> That will give you $shelves, as a node set
>> containing something like:
>> 
>>   <SHELF_NO count="1">4567</SHELF_NO>
>>   <SHELF_NO count="3">3344</SHELF_NO>
>> 
>> You can then pass this node set to a recursive
>> template that steps up
>> from 0 through to however many is required, counting
>> how many SHELF_NO
>> elements have a particular value for their count
>> attribute. The
>> recursive call adds one to the count, and only
>> passes on those
>> SHELF_NO elements that don't have the particular
>> count (gradually
>> working through the list of SHELF_NO elements).
>> Something like:
>> 
>> <xsl:template name="frequency-table">
>>   <xsl:param name="count" select="0" />
>>   <xsl:param name="shelves" select="/.." />
>>   <xsl:if test="$shelves">
>>     <xsl:variable name="shelves-with-count"
>>                   select="$shelves[@count = $count]"
>> />
>>     <xsl:variable name="nshelves-with-count"
>>                  
>> select="count($shelves-with-count)" />
>>     <xsl:value-of select="$count" />
>>     <xsl:text> </xsl:text>
>>     <xsl:value-of select="$nshelves-with-count" />
>>     <xsl:call-template name="frequency-table">
>>       <xsl:with-param name="count" select="$count +
>> 1" />
>>       <xsl:with-param name="shelves"
>>                      
>> select="$shelves[count(.|$shelves-with-count) !=
>>                                       
>> $nshelves-with-count]" />
>>     </xsl:call-template>
>>   </xsl:if>
>> </xsl:template>
>> 
>> Once you'd created the $shelves variable (as above),
>> you could call
>> this template with:
>> 
>>   <xsl:call-template name="frequency-table">
>>     <xsl:with-param name="shelves" select="$shelves"
>> />
>>   </xsl:call-template>
>> 
>> Cheers,
>> 
>> Jeni
>> 
>> ---
>> Jeni Tennison
>> http://www.jenitennison.com/
>> 
>
>
>__________________________________________________
>Do You Yahoo!?
>LAUNCH - Your Yahoo! Music Experience
>http://launch.yahoo.com
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


________________________________________________________
Outgrown your current e-mail service?
Get a 25MB Inbox, POP3 Access, No Ads and No Taglines with LYCOS MAIL PLUS.
http://login.mail.lycos.com/brandPage.shtml?pageId=plus

 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.