I have not fully understood your example :(
I have tried a lot and I'm starting thinking I'm stupid :(.
I'm lucky I'm not a programmer and I'm doing this for personal interest :)
I'm working on a free Xml based 'European curriculum vitae'
If someone writes his data in the Xml file can obtain his CV both in Xhtml
than PDF format.
I hope this application will be useful also for you!
Now I'm working on Languages section Xslt for the Xhtml version.
What I want to obtain is
1. If in the Xml I have a single 'mother tongue' and a single 'other
tongue':
______________________________________________
mother tongue Italian
other tongue English speak: good
read: excellent
write: good
______________________________________________
2. If in the Xml I have more 'mother tongue's and 'other tongue's:
______________________________________________
mother tongues German
Italian
other tongues English speak: good
read: excellent
write: good
Français speak: basic
read: basic
write: basic
______________________________________________
Keep attention to the plural 's' in 'tongues' and to the absence of 'speak,
read and write' attributes in the mother tongues.
The Xml is:
(you can see the original file at
<http://biografica.tzone.it/cv/eucv_eng_prova.xml>)
____________________________________________________________________________
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="eucv_eng_prova.xsl"?>
<xCVP>
<PersonDetails>
<Languages>
<Language type="mother tongue" code="ger">German</Language>
<Language type="mother tongue" code="ita">Italiano</Language>
<Language type="other language" speak="good" read="excellent"
write="good" code="eng">English</Language>
<Language type="other language" speak="basic" read="basic" write="basic"
code="fr">Fran?ßais</Language>
</Languages>
</PersonDetails>
</xCVP>
____________________________________________________________________________
The (wrong) Xslt I have tried is:
(you can see the original file at
<http://biografica.tzone.it/cv/eucv_eng_prova.xsl>)
____________________________________________________________________________
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="Language-by-type" match="Language" use="@type"/>
<xsl:template match="xCVP/PersonDetails">
<html>
<body>
<section>
<h>languages</h>
<xsl:apply-templates select="Languages"/>
</section>
</body>
</html>
</xsl:template>
<xsl:template match="PersonInfo">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Languages">
<table>
<xsl:for-each select="Language[count(.|key('Language-by-type',
@type)[1]) = 1]"><!-- process a set consisting of the first 'Language'
element for each '@type' -->
<xsl:sort select="@type"/>
<tr>
<td><span class="label"><xsl:value-of
select="@type"/></span></td>
<td><xsl:value-of select="."/></td>
<td><span class="label">speak</span></td>
<td><xsl:value-of select="@speak"/></td>
</tr>
<xsl:for-each select="key('Language-by-type', @type)"><!--
process all 'Language' elements having the current 'Language''s '@type' -->
<xsl:if test="position()!=last()">
<tr>
<td/>
<td><xsl:value-of select="."/></td>
<td><span class="label">read</span></td>
<td><xsl:value-of select="@read"/></td>
</tr>
<tr>
<td/>
<td/>
<td><span class="label">write</span></td>
<td><xsl:value-of select="@write"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
____________________________________________________________________________
Thank you very much!
___________________________________________________________________________
Copyright 2003 by Lorenzo De Tomasi
- student of Information Architecture, Interface Design and Visual Design -
via Bellaria 6, 21018 Sesto Calende (Varese), Italia
phone: +39 (0)331 924649
mobile: +39 329 3941065; +39 333 8979304
e-mail: lorenzo(_dot_)detomasi(_at_)libero(_dot_)it;
lorenzo(_dot_)detomasi(_at_)email(_dot_)it
website: http://biografica.tzone.it
ICQ uin: 11313132
Yahoo! Instant Messenger id: tummait
Microsoft Messenger: lorenzo(_dot_)detomasi(_at_)libero(_dot_)it
This work is licensed under the Creative Commons Attribution-ShareAlike
License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-sa/1.0 or send a letter to Creative
Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list