Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Grouping based on key result

From: Ganesh Babu N <nbabuganesh@--------->
To:
Date: 3/3/2009 12:55:00 PM
Thanks David,

I am new to function and sequence functions. However the code is
working fine for author which is having cross-ref tag with affiliation
ids.

But it is failing at the examples below:

<author-group>
    <author>
         <given-name>Shaked</given-name>
         <surname>Gilboa</surname>
    </author>
    <affiliation><textfn>Department of Business Administration, Ruppin
Academic Center, Emek Hefer 40250, Israel</textfn></affiliation>
</author-group>

In which there is no cross-ref and there is no id in affiliation as
this is the single occurrence in the file. This can also define as,
when there is a single affiliation without any id by default the
country should be displayed after the author name(s).

Another variation in the input is as follows:

<author-group>
  <author>
    <given-name>Arch G.</given-name>
    <surname>Woodside</surname>
    <cross-ref refid="aff1"><sup>a</sup></cross-ref>
    <cross-ref refid="cor1"><sup>&#x204E;</sup></cross-ref>
  </author>
  <author>
    <given-name>Timucin</given-name>
    <surname>Ozcan</surname>
  </author>
  <affiliation id="aff1"><label>a</label><textfn>Department of
Marketing, Boston College, Carroll School of Management, 140
Commonwealth Avenue, Chestnut Hill, MA 02467,
USA</textfn></affiliation>
  <affiliation id="aff2"><label>b</label><textfn>Department of
Management and Marketing, Southern Illinois University-Edwardsville,
Founders Hall 2120, Edwardsville, IL 62026, USA</textfn></affiliation>
</author-group>

For one there is cross-ref and for another there is no. In these cases
also it should do the grouping.

Please guide me further on this problem.

Regards,
Ganesh


On Tue, Mar 3, 2009 at 5:10 PM, David Carlisle <davidc@xxxxxxxxx> wrote:
>
>
>> 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()"
>
> you could avoid that by applying tokenize to each item separately ie not
> tokenize($aff,', ')
> but
> $aff/tokenize(.,', ')
> (by the way it's safer to use ',\s+' rather than ', ' unless you know
> your input is highly regular.)
>
> However this can not work as you intend.
>     <xsl:for-each-group select="author" group-adjacent="$count">
> variables hold values not expression fragments so $count (or any other
> variable)  would have the same value each time it is evaluated, so all
> items will appear in the same group.
>
> the group-aadjacent attribute needs to hold an expression that evaluates
> to different values at group boundaries It could be inlined into teh
> attribute, but here I suggest a function:
>
>
>
>
>
>
> <xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                xmlns:xs="http://www.w3.org/2001/XMLSchema"
>                xmlns:f="data:,f"
>                exclude-result-prefixes="xs f">
>
> <xsl:output indent="yes" encoding="US-ASCII"/>
> <xsl:strip-space elements="*"/>
>
> <xsl:key name="country" match="affiliation/textfn"
> use="parent::affiliation/@id"/>
> <xsl:template match="author-group">
>     <xsl:for-each-group select="author" group-adjacent="f:country(.)">
>        <xsl:apply-templates select="current-group()"/>
>       (<xsl:value-of select="current-grouping-key()"/>)
>     </xsl:for-each-group>
>
> </xsl:template>
>
> <xsl:template match="author">
> <author><xsl:value-of select="given-name,surname"/></author>
> </xsl:template>
>
> <xsl:function name="f:country" as="xs:string">
>  <xsl:param name="a" as="element()"/>
>  <xsl:sequence select="key('country',
$a/cross-ref/@refid,root($a))/tokenize(.,',\s+')[last()]"/>
> </xsl:function>
>
> </xsl:stylesheet>
>
>
> $ saxon9 ag.xml ag.xsl
> <?xml version="1.0" encoding="US-ASCII"?>
> <author>JungKun Park</author>
> <author>HoEun Chung</author>
> <author>Weon Sang Yoo</author>
>       (USA)
>
>
>
>
> ________________________________________________________________________
> The Numerical Algorithms Group Ltd is a company registered in England
> and Wales with company number 1249803. The registered office is:
> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
>
> This e-mail has been scanned for all viruses by Star. The service is
> powered by MessageLabs.
> ________________________________________________________________________


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