[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xsl-list
Subject:    Re: [xsl] Many Key values question
From:       "Jean-Pierre Lamon gipi () ngscan ! com" <xsl-list-service () lists ! mulberrytech ! com>
Date:       2014-10-18 12:13:19
Message-ID: 20141018081233.50744 () lists ! mulberrytech ! com
[Download RAW message or body]

Thx for your help Dimitre.

These 2 keys must be concatenated because subfield code 5 is present only in
certain circumstances (only if the "real" value subfield t contains ä or ü
or ö -> swiss german sort with AE UE OE). If not, subfield 7 must be used.
I didn't succeed to sort with param lang="de-CH" on the subfield t (XSLT
1.0)
I presume there is a smarter way to solve that, but it's the only solution I
found.

Cheers
JP

-----Message d'origine-----
De : Dimitre Novatchev dnovatchev@gmail.com
[mailto:xsl-list-service@lists.mulberrytech.com] 
Envoyé : samedi 18 octobre 2014 08:51
À : xsl-list@lists.mulberrytech.com
Objet : Re: [xsl] Many Key values question

I don't see the usefulness of such key (if you can concatenate the
string value of the two elements, you certainly have them already.

But here is one way of constructing such key anyway:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes" indent="yes"/>
  <xsl:key name="kX"
           match="datafield[@tag='773']/subfield[@code='5' or @code='t']"
           use="concat(../subfield[@code='5'], .../subfield[@code='t'])"/>

 <xsl:template match="datafield[@tag='773']">
   <xsl:copy-of select="key('kX', concat(subfield[@code='5'],
subfield[@code='t']))"/>
 </xsl:template>
</xsl:stylesheet>

When this transformation is applied on the provided source XML document:

<collection>
 <record>
  <datafield tag="773" ind1="0" ind2=" ">
   <subfield code="5">BULLETIN / EIDGENOESSISCHE TECHNISCHE HOCHSCHULE
ZUERICH </subfield>
   <subfield code="t">Bulletin / Eidgenössische Technische Hochschule
Zürich </subfield>
   <subfield code="d">Zürich : Schulleitung der ETH Zürich, 1993-2005
</subfield>
   <subfield code="g">S. 27-33</subfield>
  </datafield>
 </record>
</collection>

the wanted, correct result is produced:

<subfield code="5">BULLETIN / EIDGENOESSISCHE TECHNISCHE HOCHSCHULE
ZUERICH </subfield>
<subfield code="t">Bulletin / Eidgenössische Technische Hochschule
Zürich </subfield>

Cheers,
Dimitre

On Fri, Oct 17, 2014 at 10:55 PM, Jean-Pierre Lamon gipi@ngscan.com
<xsl-list-service@lists.mulberrytech.com> wrote:
> Hi,
>
>
>
> Here is my XML
>
>
>
> <collection>
>
>   <record>
>
>     <datafield tag="773" ind1="0" ind2=" ">
>
>  <subfield code="5">BULLETIN / EIDGENOESSISCHE TECHNISCHE HOCHSCHULE
ZUERICH
> </subfield>
>
>  <subfield code="t">Bulletin / Eidgenössische Technische Hochschule Zürich
> </subfield>
>
>  <subfield code="d">Zürich : Schulleitung der ETH Zürich, 1993-2005
> </subfield>
>
>  <subfield code="g">S. 27-33</subfield>
>
>  </datafield>
>
>   </record>
>
> </collection>
>
>
>
> I want to index in the same key
>
> subfield[@code=’5’] and subfield[@code=’t’]
>
>
>
> I’ve tried this :
> <xsl:key name="idxrev" match="datafield[@tag=773]"
> use="concat(subfield[@code='5'],subfield[@code='t'])"/>
>
>
>
> To display the keys, I use this :
>
>
> <xsl:for-each select="record/datafield[@tag=773]">
>
>             <xsl:sort select="
> concat(subfield[@code='5'],subfield[@code='t'])"/>
>
>             <xsl:value-of select="key('idxrev',
> concat(subfield[@code='5'],subfield[@code='t']))"/>
>
>             <br/>
>
> </xsl:for-each>
>
>
>
> But all the subfields are in the key not only the subfields 5 and t.
>
> Returned key :
>
> BULLETIN / EIDGENOESSISCHE TECHNISCHE HOCHSCHULE ZUERICH Bulletin /
> Eidgenössische Technische Hochschule Zürich Zürich : Schulleitung der ETH
> Zürich, 1993-2005 S. 27-33
>
>
>
> Thx
> JP
>
> XSL-List info and archive
> EasyUnsubscribe (by email)

--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/651070
or by email: xsl-list-unsub@lists.mulberrytech.com
--~--
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic