Thank you so much, David!
Your example seems to work perfectly with the excerpts that I sent. Now
I need to apply to the whole file, and secondly try to break my back
understanding the 'key' and the 'generate-id' bits ;)
By the way, I guess I can use xslt 2 too. Feel free to send a solution
for that version if you think it's simpler and that it's worthy using
that one instead.
Regards, Manuel
David Carlisle escribió:
This is a grouping qn so always the syntax is a bit simpler in xslt 2,
but assuming that you are using xslt1, something like
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<!--<xsl:output type="xml"/>-->
<xsl:output indent="yes" encoding="US-ASCII"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<martif type="TBX" xml:lang="en">
<text>
<body>
<xsl:apply-templates select="dictionary/records/record">
</xsl:apply-templates>
</body>
</text>
</martif>
</xsl:template>
<!-- google for muenchian grouping-->
<xsl:key name="t" match="term" use="concat(../@num,'-',@lang)"/>
<xsl:template match="record">
<termEntry id="{(_at_)num}">
<xsl:for-each select="term[generate-id(.)=
generate-id(key('t',concat(../@num,'-',@lang))[1])]">
<langSet xml:lang="{(_at_)lang}">
<xsl:apply-templates select="key('t',concat(../@num,'-',@lang))"/>
</langSet>
</xsl:for-each>
</termEntry>
</xsl:template>
<xsl:template match="term">
<term id=""><xsl:apply-templates/></term>
</xsl:template>
</xsl:stylesheet>
$ saxon lang.xml lang.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<martif type="TBX" xml:lang="en">
<text>
<body>
<termEntry id="1">
<langSet xml:lang="ca">
<term id="">absenta</term>
</langSet>
<langSet xml:lang="es">
<term id="">absenta</term>
<term id="">ajenjo</term>
</langSet>
<langSet xml:lang="en">
<term id="">absinth</term>
<term id="">absinthe</term>
</langSet>
</termEntry>
<termEntry id="2">
<langSet xml:lang="ca">
<term id="">acetificació</term>
</langSet>
<langSet xml:lang="es">
<term id="">acetificación</term>
</langSet>
<langSet xml:lang="en">
<term id="">acetification</term>
</langSet>
</termEntry>
</body>
</text>
</martif>
________________________________________________________________________
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.
________________________________________________________________________
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--