Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] for-each-group and result-document splitting to less files.

From: "Michael Kay" <mike@------------>
To:
Date: 9/10/2008 5:28:00 PM
> -- though makes me curious... how hard would it be to change 
> this so that the groupings were based on the count() of items 
> in the nodeset?
> i.e. make divisions that were basically equal regardless of the input?
>  So if there were almost no entries in the first half of the 
> alphabet, the first division would be a-r, then s-t (if a lot 
> there), then u-w (if few there), etc.  maybe passing how many 
> sets to split it into total?

If the sorted sequence is $in, and you want to split it roughly into $n
groups, then you can take the size of a group as ceiling(count($in) div $n).
Then the letters that form the starts of groups might have initial letters

$initialLetters := 
distinct-values('a', for $i in 1 to $n return
substring($in[ceiling(count($in) div $n)]/@title, 1, 1))

The next step is to construct the translation table such as
'aaaaaaffffffsssssvvvvv' by replacing each letter in a-z with the highest
letter from $initialLetters that is <= the letter in question, that is:

$alphabet :=
   for $i in 1 to 26 return substring('abcdefghijklmnopqrstuvwxyz', $i, 1)

$transTable :=
string-join(for $c in $alphabet return max($initialLetters[. le $c]), '')
           

Not tested, of course.

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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent