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

Multiple conditions in single key statement

Subject: Multiple conditions in single key statement
From: "Ganesh Babu N" <nbabuganesh@xxxxxxxxx>
Date: Mon, 15 Sep 2008 21:32:18 +0530
 Multiple conditions in single key statement
Dear All,

Is it possible to define a key element with union of two different
conditions? My requirement is as follows:

XML: Two D structures are in the same file.

<D AN="0019053-200826080-00002" V="2000.3F" FILE="G0019053-200826080-00002">
<BB>
<BY>
<PN ILINK="1" ITYPE="sp">
    <FN>Joep</FN><SN>Damen</SN>
</PN>
<PN ILINK="2" ITYPE="sp">
<FN>Sue</FN><SN>Caleo</SN>
</PN>
<AF>
<P>
<SP>1</SP> Pharmerit BV, Rotterdam, the Netherlands</P>
<P>
<SP>2</SP> Janssen Pharmaceutica NV, Beerse, Belgium</P>
</AF>
</BY>
</BB>
</D>
<D AN="0019053-200826080-00004" V="2000.3F" FILE="G0019053-200826080-00004">
<BB>
<BY>
<PN ILINK="1" ITYPE="sp">
<FN>Emily</FN>
<SN>Lancsar</SN></PN>
<PN ILINK="2" ITYPE="sp">
<FN>Jordan</FN>
<SN>Louviere</SN></PN>
<AF>
<P>
<SP>1</SP> Business School (Economics) and Institute of Health and
Society, University of Newcastle upon Tyne, Newcastle upon Tyne,
UK</P>
<P>
<SP>2</SP> Centre for the Study of Choice, University of Technology,
Sydney, New South Wales, Australia</P></AF>
</BY>
</BB>
</D>

The desired output is:

Author-Name: Joep Damen
Author-Name-First: Joep
Author-Name-Last: Damen
Author-Workplace-Name: Pharmerit BV, Rotterdam, the Netherlands

Author-Name: Sue Caleo
Author-Name-First: Sue
Author-Name-Last: Caleo
Author-Workplace-Name: Janssen Pharmaceutica NV, Beerse, Belgium

Author-Name: Emily Lancsar
Author-Name-First: Emily
Author-Name-Last: Lancsar
Author-Workplace-Name: Business School (Economics) and Institute of
Health and Society, University of Newcastle upon Tyne, Newcastle upon
Tyne, UK

Author-Name: Jordan Louviere
Author-Name-First: Jordan
Author-Name-Last: Louviere
Author-Workplace-Name: Centre for the Study of Choice, University of
Technology, Sydney, New South Wales, Australia


My XSLT:

<xsl:key name="affid" match="D/BB/BY/AF/P" use="SP"/>
<xsl:template match="PN">
<xsl:choose>
<xsl:when test="@ILINK">
Author-Name: <xsl:value-of select="FN"/><xsl:text> </xsl:text><xsl:if
test="MN"><xsl:value-of select="MN"/>. </xsl:if><xsl:value-of
select="SN"/> <xsl:apply-templates/>
<xsl:variable name="affk" select="key('affid',@ILINK])"/>
<xsl:value-of select="$affk"/>
</xsl:when>
</xsl:chose>
</xsl:template>

But I am getting the output as follows:


Author-Name: Joep Damen
Author-Name-First: Joep
Author-Name-Last: Damen
Author-Workplace-Name: 1 Pharmerit BV, Rotterdam, the Netherlands
Author-Workplace-Name: 1 Business School (Economics) and Institute of
Health and Society, University of Newcastle upon Tyne, Newcastle upon
Tyne, UK

Author-Name: Sue Caleo
Author-Name-First: Sue
Author-Name-Last: Caleo
Author-Workplace-Name: 2 Janssen Pharmaceutica NV, Beerse, Belgium
Author-Workplace-Name: 2 Centre for the Study of Choice, University of
Technology, Sydney, New South Wales, Australia

Author-Name: Emily Lancsar
Author-Name-First: Emily
Author-Name-Last: Lancsar
Author-Workplace-Name: 1 Pharmerit BV, Rotterdam, the Netherlands
Author-Workplace-Name: 1 Business School (Economics) and Institute of
Health and Society, University of Newcastle upon Tyne, Newcastle upon
Tyne, UK

Author-Name: Jordan Louviere
Author-Name-First: Jordan
Author-Name-Last: Louviere
Author-Workplace-Name: 2 Janssen Pharmaceutica NV, Beerse, Belgium
Author-Workplace-Name: 2 Centre for the Study of Choice, University of
Technology, Sydney, New South Wales, Australia

As per the logic of the key element this output is correct. But it is
not my desired format. The only way of differentiation is @AN in the D
element.

So in the key element is it possible to include union of two
conditions such as use="concat(@AN, SP) " to check with key('affkey',
concat(@AN, @ILINK)).

Please suggest the above will give the result or any better solution
for this case.

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.