xsl-list
[Top] [All Lists]

[xsl] Select unique xsl:key

2008-12-24 01:44:40
Hi List,

How to avoid duplicate key value in XSLT, it should select only unique
values. Here I am moving affiliation to referenced authors. "AF3-7" coming
three times, it should select only one very first referenced.

Please provide solution.

XML:
=====
<?xml version="1.0" encoding="UTF-8"?>
<ARTICLE DOCTOPIC="Original Articles" DOCSUBJ="NA" DATE="November 2008"
VID="24" ISS="9" PPF="793" PPL="801" PDF-SOURCE="JP240907"
DOI="10.1097/AJP.0b013e31817bcb65">
        <DEPARTMENT.TITLE>Original Articles</DEPARTMENT.TITLE>
        <ARTICLE-TITLE>Biopsychosocial Influence on Exercise-induced Delayed
Onset Muscle Soreness at the Shoulder: Pain Catastrophizing and
Catechol-O-Methyltransferase (<EMPHASIS EMPH-TYPE="ITALIC">COMT</EMPHASIS>)
Diplotype Predict Pain Ratings</ARTICLE-TITLE>
        <BYLINE>
 
<AUTHOR><GIVEN-NAME>Steven</GIVEN-NAME><INITIAL-MIDDLE>Z.</INITIAL-MIDDLE><S
URNAME>George</SURNAME><DEGREES>PT, PhD</DEGREES><AFFILIATION.CLINK
LINKENDS="AF1-7"><!--&ast;--></AFFILIATION.CLINK></AUTHOR>
 
<AUTHOR><GIVEN-NAME>Geoffrey</GIVEN-NAME><INITIAL-MIDDLE>C.</INITIAL-MIDDLE>
<SURNAME>Dover</SURNAME><DEGREES>PhD, ATC</DEGREES><AFFILIATION.CLINK
LINKENDS="AF2-7"><!--&dagger;--></AFFILIATION.CLINK></AUTHOR>
 
<AUTHOR><GIVEN-NAME>Margaret</GIVEN-NAME><INITIAL-MIDDLE>R.</INITIAL-MIDDLE>
<SURNAME>Wallace</SURNAME><DEGREES>PhD</DEGREES><AFFILIATION.CLINK
LINKENDS="AF3-7"><!--&Dagger;--></AFFILIATION.CLINK></AUTHOR>
 
<AUTHOR><GIVEN-NAME>Brandon</GIVEN-NAME><INITIAL-MIDDLE>K.</INITIAL-MIDDLE><
SURNAME>Sack</SURNAME><DEGREES>BS</DEGREES><AFFILIATION.CLINK
LINKENDS="AF3-7"><!--&Dagger;--></AFFILIATION.CLINK></AUTHOR>
 
<AUTHOR><GIVEN-NAME>Deborah</GIVEN-NAME><INITIAL-MIDDLE>M.</INITIAL-MIDDLE><
SURNAME>Herbstman</SURNAME><DEGREES>BA</DEGREES><AFFILIATION.CLINK
LINKENDS="AF3-7"><!--&Dagger;--></AFFILIATION.CLINK></AUTHOR>
 
<AUTHOR><GIVEN-NAME>Ece</GIVEN-NAME><SURNAME>Aydog</SURNAME><DEGREES>MD</DEG
REES><AFFILIATION.CLINK
LINKENDS="AF4-7"><!--&sect;--></AFFILIATION.CLINK></AUTHOR>
 
<AUTHOR><GIVEN-NAME>Roger</GIVEN-NAME><INITIAL-MIDDLE>B.</INITIAL-MIDDLE><SU
RNAME>Fillingim</SURNAME><DEGREES>PhD</DEGREES><AFFILIATION.CLINK
LINKENDS="AF5-7"><!--&par;--></AFFILIATION.CLINK></AUTHOR>
        </BYLINE>
        <FOOTNOTE>
                <AFFILIATIONS ID="AF1-7">
                    <PARAGRAPH><!--&ast;-->Department of Physical Therapy,
Brooks Center for Rehabilitation Studies</PARAGRAPH></AFFILIATIONS>
                <AFFILIATIONS ID="AF2-7">
                    <PARAGRAPH><!--&dagger;-->Department of Applied
Physiology and Kinesiology</PARAGRAPH></AFFILIATIONS>
                <AFFILIATIONS ID="AF3-7">
                    <PARAGRAPH><!--&Dagger;-->Department of Molecular
Genetics and Microbiology, Center for Mammalian
Genetics</PARAGRAPH></AFFILIATIONS>
                <AFFILIATIONS ID="AF5-7">
                    <PARAGRAPH><!--&par;-->Department of Community Dentistry
and Behavioral Science, University of Florida, Gainesville
FL</PARAGRAPH></AFFILIATIONS>
                <AFFILIATIONS ID="AF4-7">
                    <PARAGRAPH><!--&sect;-->Department of Physical Medicine
and Rehabilitation, Health Ministry, Ankara Diskapi, Education and Research
Hospital, Hosdere Caddesi, Ankara, Turkey</PARAGRAPH></AFFILIATIONS>
                <FUNDS-ACKNOWLEDGMENT>
                    <PARAGRAPH>Funded by the University of Florida, Research
Opportunity Incentive Fund, no. 56577 (S.Z.G.) and by NS41670
(R.B.F.).</PARAGRAPH></FUNDS-ACKNOWLEDGMENT><CORRESPONDENCE>
                        <PARAGRAPH>Reprints: Steven Z. George, PT, PhD,
Department of Physical Therapy, Brooks Center for Rehabilitation Studies,
University of Florida, Health Science Center, PO Box 100154, Gainesville, FL
32610-0154 (e-mail: 
szgeorge(_at_)phhp(_dot_)ufl(_dot_)edu).</PARAGRAPH></CORRESPONDENCE>
                <RECEIVED>
                    <PARAGRAPH>Received for publication December 14, 2007;
revised April 1, 2008</PARAGRAPH></RECEIVED>
                <ACCEPTANCE>
                    <PARAGRAPH>accepted April 13,
2008</PARAGRAPH></ACCEPTANCE>
            </FOOTNOTE>
</ARTICLE>

XSL
=====
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    
    <xsl:preserve-space elements="*"/>
    
    <xsl:key name="kytblnote" match="TABLE/TABLE.NOTE" use="@ID"></xsl:key>
    <xsl:key name="kyaff" match="FOOTNOTE/AFFILIATIONS" use="@ID"></xsl:key>
    
    <xsl:output name="output-def" encoding="UTF-8" method="xml"
omit-xml-declaration="yes" />
    
    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="*">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>
    
    <!--Article - Root-->
    <xsl:template match="ARTICLE">
        <xsl:text>&#10;</xsl:text><article id="a0{(_at_)VID}" ppf="{(_at_)PPF}"
ppl="{(_at_)PPL}"><xsl:apply-templates/><xsl:text>&#10;</xsl:text></article>
    </xsl:template>
    
    <!--Front Matter-->
    <xsl:template
match="TITLE-PAGE"><front><xsl:apply-templates/></front></xsl:template>
    <xsl:template match="TITLE-PAGE/DEPARTMENT.TITLE"></xsl:template>
    
    <!--Article Title-->
    <xsl:template match="ARTICLE-TITLE">
        <arctitle>
            <xsl:apply-templates/>
            <xsl:if test="following-sibling::ARTICLE-SUBTITLE"><xsl:text>
</xsl:text><emphasis style="it"><xsl:copy-of
select="following-sibling::ARTICLE-SUBTITLE/text()"/></emphasis></xsl:if>
        </arctitle><xsl:text>&#10;</xsl:text>
    </xsl:template>
    
    <xsl:template match="ARTICLE-SUBTITLE"></xsl:template>
    
    <!--BYLINE-->
    <xsl:template
match="BYLINE"><contribs><xsl:apply-templates/><xsl:text>&#10;</xsl:text></c
ontribs><xsl:text>&#10;</xsl:text></xsl:template>
    
    <!--Author-->
    <xsl:template
match="AUTHOR"><authname><xsl:apply-templates/></authname></xsl:template>
    <xsl:template
match="AUTHOR/GIVEN-NAME|INITIAL-GIVEN"><fnm><xsl:apply-templates/></fnm></x
sl:template>
    <xsl:template match="AUTHOR/SURNAME"><snm
index="{lower-case(.)}"><xsl:apply-templates/></snm></xsl:template>
    <xsl:template
match="AUTHOR/INITIAL-MIDDLE|AUTHOR/MIDDLE-NAME"><mi><xsl:apply-templates/><
/mi></xsl:template>
    <xsl:template
match="AUTHOR/DEGREES"><roles><xsl:apply-templates/><xsl:apply-templates
select="key('kyaff',following-sibling::AFFILIATION.CLINK/@LINKENDS)[1]"
/></roles></xsl:template>
    <xsl:template match="AFFILIATION.CLINK"></xsl:template>
    <!--Affiliations-->
    <xsl:template
match="AFFILIATIONS"><pubinfo><xsl:apply-templates/><xsl:text>&#10;</xsl:tex
t></pubinfo></xsl:template>
    
    <!--Funds-Acknowledgment-->
    <xsl:template
match="FUNDS-ACKNOWLEDGMENT"><xsl:apply-templates/></xsl:template>
    <xsl:template
match="FUNDS-ACKNOWLEDGMENT/PARAGRAPH"><suppby><xsl:apply-templates/></suppb
y></xsl:template>
    
    <!--Pubinfo-->
    <xsl:template match="FOOTNOTE"><pubinfo><xsl:apply-templates
select="descendant::AFFILIATIONS, descendant::FUNDS-ACKNOWLEDGMENT,
descendant::RECEIVED, descendant::REVISED, descendant::ACCEPTANCE,
descendant::CORRESPONDENCE"/><copynote><para>Copyright &amp;copy; 2008 by
Lippincott Williams &amp;
Wilkins</para></copynote><xsl:text>&#10;</xsl:text></pubinfo></xsl:template>
    
    <!--Received-Revised-Accepted-->
    <xsl:template match="AFFILIATIONS"><xsl:apply-templates/></xsl:template>
    <xsl:template
match="AFFILIATIONS/PARAGRAPH"><ftnote><xsl:apply-templates/></ftnote></xsl:
template>
    <xsl:template match="RECEIVED"><xsl:apply-templates/></xsl:template>
    <xsl:template
match="RECEIVED/PARAGRAPH"><recdate><xsl:apply-templates/></recdate></xsl:te
mplate>
    <xsl:template match="REVISED"><xsl:apply-templates/></xsl:template>
    <xsl:template
match="REVISED/PARAGRAPH"><revdate><xsl:apply-templates/></revdate></xsl:tem
plate>
    <xsl:template match="ACCEPTANCE"><xsl:apply-templates/></xsl:template>
    <xsl:template
match="ACCEPTANCE/PARAGRAPH"><accdate><xsl:apply-templates/></accdate><xsl:t
ext>&#10;</xsl:text></xsl:template>
    <xsl:template
match="CORRESPONDENCE"><xsl:apply-templates/></xsl:template>
    <xsl:template
match="CORRESPONDENCE/PARAGRAPH"><reprint><xsl:apply-templates/></reprint><x
sl:text>&#10;</xsl:text></xsl:template>
    
</xsl:stylesheet>

OUTPUT
========

<?xml version="1.0" encoding="UTF-8"?>
<article id="a024" ppf="793" ppl="801">
        <DEPARTMENT.TITLE>Original Articles</DEPARTMENT.TITLE>
        <arctitle>Biopsychosocial Influence on Exercise-induced Delayed
Onset Muscle Soreness at the Shoulder: Pain Catastrophizing and
Catechol-O-Methyltransferase (<EMPHASIS EMPH-TYPE="ITALIC">COMT</EMPHASIS>)
Diplotype Predict Pain Ratings</arctitle>

        <contribs>
            <authname><fnm>Steven</fnm><mi>Z.</mi><snm
index="george">George</snm><roles>PT, PhD
                    <ftnote>Department of Physical Therapy, Brooks Center
for Rehabilitation Studies</ftnote></roles></authname>
            <authname><fnm>Geoffrey</fnm><mi>C.</mi><snm
index="dover">Dover</snm><roles>PhD, ATC
                    <ftnote>Department of Applied Physiology and
Kinesiology</ftnote></roles></authname>
            <authname><fnm>Margaret</fnm><mi>R.</mi><snm
index="wallace">Wallace</snm><roles>PhD
                    <ftnote>Department of Molecular Genetics and
Microbiology, Center for Mammalian Genetics</ftnote></roles></authname>
            <authname><fnm>Brandon</fnm><mi>K.</mi><snm
index="sack">Sack</snm><roles>BS
                    <ftnref/></roles></authname>
            <authname><fnm>Deborah</fnm><mi>M.</mi><snm
index="herbstman">Herbstman</snm><roles>BA
                    <ftnref/></roles></authname>
            <authname><fnm>Ece</fnm><snm index="aydog">Aydog</snm><roles>MD
                    <ftnote>Department of Physical Medicine and
Rehabilitation, Health Ministry, Ankara Diskapi, Education and Research
Hospital, Hosdere Caddesi, Ankara, Turkey</ftnote></roles></authname>
            <authname><fnm>Roger</fnm><mi>B.</mi><snm
index="fillingim">Fillingim</snm><roles>PhD
                    <ftnote>Department of Community Dentistry and Behavioral
Science, University of Florida, Gainesville FL</ftnote></roles></authname>
        
</contribs>

        <pubinfo>
                    <ftnote>Department of Physical Therapy, Brooks Center
for Rehabilitation Studies</ftnote>
                    <ftnote>Department of Applied Physiology and
Kinesiology</ftnote>
                    <ftnote>Department of Molecular Genetics and
Microbiology, Center for Mammalian Genetics</ftnote>
                    <ftnote>Department of Community Dentistry and Behavioral
Science, University of Florida, Gainesville FL</ftnote>
                    <ftnote>Department of Physical Medicine and
Rehabilitation, Health Ministry, Ankara Diskapi, Education and Research
Hospital, Hosdere Caddesi, Ankara, Turkey</ftnote>
                    <suppby>Funded by the University of Florida, Research
Opportunity Incentive Fund, no. 56577 (S.Z.G.) and by NS41670
(R.B.F.).</suppby>
                    <recdate>Received for publication December 14, 2007;
revised April 1, 2008</recdate>
                    <accdate>accepted April 13, 2008</accdate>

                        <reprint>Reprints: Steven Z. George, PT, PhD,
Department of Physical Therapy, Brooks Center for Rehabilitation Studies,
University of Florida, Health Science Center, PO Box 100154, Gainesville, FL
32610-0154 (e-mail: szgeorge(_at_)phhp(_dot_)ufl(_dot_)edu).</reprint>
<copynote><para>Copyright &amp;copy; 2008 by Lippincott Williams &amp;
Wilkins</para></copynote>
</pubinfo>

</article>

Regards,
Ramkumar


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--