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

Grouping based on key result

Subject: Grouping based on key result
From: Ganesh Babu N <nbabuganesh@xxxxxxxxx>
Date: Tue, 3 Mar 2009 16:17:31 +0530
 Grouping based on key result
Hai All,

Here is my XML:

<author-group>
			<author>
				<given-name>JungKun</given-name>
				<surname>Park</surname>
				<cross-ref refid="aff1">
					<sup>a</sup>
				</cross-ref>
				<cross-ref refid="cor1">
					<sup>&#x204E;</sup>
				</cross-ref>
			</author>
			<author>
				<given-name>HoEun</given-name>
				<surname>Chung</surname>
				<cross-ref refid="aff1">
					<sup>a</sup>
				</cross-ref>
			</author>
			<author>
				<initials>W.S.</initials>
				<given-name>Weon Sang</given-name>
				<surname>Yoo</surname>
				<cross-ref refid="aff2">
					<sup>b</sup>
				</cross-ref>
			</author>
			<affiliation id="aff1">
				<label>a</label>
				<textfn>Department of Consumer Sciences and Retailing, Matthews
Hall, 812 W State Street, Purdue University, West Lafayette, IN
47907-2060, USA</textfn>
			</affiliation>
			<affiliation id="aff2">
				<label>b</label>
				<textfn>Department of Consumer Sciences and Retailing, Matthews
Hall, 812 W State Street, CA,  47907-2060, USA</textfn>
			</affiliation>
		</author-group>

The required output is :
<author>JungKun Park</author>, <author>HoEun Chung</author> and
<author>Weon Sang Yoo</author> (USA)

Means we need to group all the authors belongs to the same country and
also keeping them in the order of their appearance. We cannot group
based on the @id of affiliation, as it will display country for each
author.

Here is my XSL:

<xsl:key name="country" match="affiliation/textfn"
use="parent::affiliation/@id"/>
<xsl:template match="author-group">
     <xsl:variable name="aff" select="key('country' author/cross-ref/@refid)"/>
     <xsl:variable name="tokenizedSample" select="tokenize($aff,', ')"/>
     <xsl:variable name="count" select="$tokenizedSample[last()]"/>

     <xsl:for-each-group select="author" group-adjacent="$count">
        <xsl:apply-templates select="current-group()"/>
       (<xsl:value-of select="current-grouping-key()"/>)
     </xsl:for-each-group>

</xsl:template>

Which is showing error at tokenize () function as  "XPTY0004: A
sequence of more than one item is not allowed as the first argument of
  tokenize()". I can not use [1] after author as i need to process all
the countries of each author

Please help is solving this problem.

Regards,
Ganesh

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.