Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Grouping based on key result

From: Ganesh Babu N <nbabuganesh@--------->
To:
Date: 3/3/2009 10:48:00 AM
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


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