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

Re: how to avoid generating an < empty element />

Subject: Re: how to avoid generating an < empty element />
From: Manuel Souto Pico <manuel.souto@xxxxxxxxxxxxxx>
Date: Thu, 05 Feb 2009 10:59:38 +0100
Re:  how to avoid generating an < empty element />
ERRATA:

Where it says 'the part in red' it should say 'the term entry 5383'. I've just realized I can't use colours in my mails ;)

Thanks, Manuel

Manuel Souto Pico escribis:
Hi,

I'm not experienced at all with XSLT and I've got one question relative to a <xsl:if test... > element which tests whether the element is a duplicate or not. Looking at my output you could get an idea of what I've managed to do:

<?xml version="1.0" encoding="UTF-8"?>
<martif type="TBX" xml:lang="en">
<martifHeader>
<fileDesc>
<sourceDesc>
<p/>
</sourceDesc>
</fileDesc>
</martifHeader>
<text>
<body>
<termEntry id="2107">
<langSet lang="spa-es">
<ntig>
<termGrp>
<term>Calibracisn</term>
<termNote type="termType">full form</termNote>
<termNote type="TS_CreateId">Alexandra M|tzel</termNote>
<termNote type="TS_UpdateId">Alexandra M|tzel</termNote>
<date type="origination">20070420T093242Z</date>
<date type="modification">20070420T093242Z</date>
<term>Calibramiento</term>
<termNote type="termType">full form</termNote>
<termNote type="TS_CreateId">Alexandra M|tzel</termNote>
<termNote type="TS_UpdateId">Alexandra M|tzel</termNote>
<date type="origination">20070420T093242Z</date>
<date type="modification">20070420T093242Z</date>
</termGrp>
</ntig>
</langSet>
</termEntry>
<termEntry id="5383">
<langSet lang="spa-es">
<ntig>
<termGrp/>
</ntig>
</langSet>
</termEntry>
</body>
</text>
</martif>


Within the <termGrp> element, the xsl:if tests whether it is the first time that the content of the tag <element> is processed or not. If it's the first one, it outputs the whole contents of the <termGrp> element, as in the termEntry 2107. Else, it doesn't output them (like in entry 5383). I think I'm using what is called Muenchian method. So far so good.

This would be good enough for me but I need to do something else, which is: if the term is not new (i.e. it has been processed and output before), I would like the whole entry to not appear in the oupput, meaning that the part in red shouldn't exist in my output. I can do this with some postediting of my output but I thought that, if possible, it would ideal to do it also with the same xsl template. Do you know how to do this?

This is my code, in case you want to check, and my input data (sorry for making the email so long):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:key name="spa-term" match="text/body/termEntry/langSet[@lang='spa-es']/ntig/termGrp/term" use="."/>
<xsl:template match="/">
<martif type="TBX" xml:lang="en">
<martifHeader>
<fileDesc>
<sourceDesc>
<p></p>
</sourceDesc>
</fileDesc>
</martifHeader>
<text>
<body>
<xsl:for-each select="martif/text/body/termEntry">
<termEntry>
<xsl:attribute name="id">
<xsl:value-of select="@id"/>
</xsl:attribute>
<!-- <xsl:value-of select="current()"/> -->
<langSet lang="spa-es"><ntig><termGrp>
<xsl:for-each select="langSet[@lang='spa-es']/ntig/termGrp/term">
<xsl:if test="generate-id(.) =
generate-id(key('spa-term', .)[1]) ">
<term>
<xsl:value-of select="." />
</term>
<xsl:for-each select="../termNote">
<termNote>
<xsl:attribute name="type">
<xsl:value-of select="@type"/>
</xsl:attribute>
<xsl:value-of select="current()"/>
</termNote>
</xsl:for-each>
<xsl:for-each select="../date">
<date>
<xsl:attribute name="type">
<xsl:value-of select="@type"/>
</xsl:attribute>
<xsl:value-of select="current()"/>
</date>
</xsl:for-each> </xsl:if>
</xsl:for-each>
</termGrp></ntig></langSet> </termEntry>
</xsl:for-each> </body>
</text>
</martif>
</xsl:template>
</xsl:stylesheet>



__DATA:


<?xml version='1.0' encoding='UTF-8'?>

<martif type="Part2v1" lang="en">
<martifHeader>
<fileDesc>
<titleStmt>
<title>Transit XV TermStar export file</title>
</titleStmt>
<publicationStmt>
<p/>
</publicationStmt>
<sourceDesc>
<p>TermStar dictionary</p>
</sourceDesc>
</fileDesc>
<encodingDesc>
<p type="DatCatSetName">maxi-set</p>
<p type="DatCatSetVersion">1</p>
</encodingDesc>
<revisionDesc>
<change>
<p>20090203T115345Z</p>
</change>
</revisionDesc>
<databaseDesc>
<p type="TS_DictName">Leica_LAS-SW_DEU_REF</p>
<p type="TS_DataBase">Leica</p>
<p type="TS_DictImagePath" mode="AbsolutePaths"/>
<p type="TS_DictProperty" id="ExportedLangs" val="0">DEU,ESP</p>
<p type="TS_DictProperty" id="ExtractedDataBase" val="0">Leica_LAS_2007</p>
<p type="TS_DictProperty" id="ExtractedDictName" val="0">Software_LAS_new</p>
<p type="TS_DictProperty" id="ExtractTime" val="0">20080407T163925Z</p>
<p type="TS_DictProperty" id="GUID" val="0">{83666734-317B-4E46-B445-6E9901523869}</p>
<p type="TS_DictProperty" id="MainLang" val="0">deu-de</p>
<p type="TS_DictProperty" id="OriginalDatabaseGUID" val="0"
>{FBADCF63-B2A3-492F-9B32-B330A0D12477}</p>
</databaseDesc>
</martifHeader>
<text>
<body>
<termEntry id='2107'>
<note type='TS_Subject'>Terminologie</note>
<note type='TS_CreateId'>Alexandra M|tzel</note>
<date type='origination'>20070420T093242Z</date>
<note type='TS_UpdateId'>Alexandra M|tzel</note>
<date type='modification'>20070420T093242Z</date>
<langSet lang='deu-de'>
<ntig><termGrp>
<term>Kalibrierung</term>
<termNote type='termType'>full form</termNote>
<termNote type='TS_CreateId'>Alexandra M|tzel</termNote>
<date type='origination'>20070420T093242Z</date>
<termNote type='TS_UpdateId'>Alexandra M|tzel</termNote>
<date type='modification'>20070420T093242Z</date>
</termGrp></ntig>
</langSet>
<langSet lang='spa-es'>
<ntig><termGrp>
<term>Calibracisn</term>
<termNote type='termType'>full form</termNote>
<termNote type='TS_CreateId'>Alexandra M|tzel</termNote>
<date type='origination'>20070420T093242Z</date>
<termNote type='TS_UpdateId'>Alexandra M|tzel</termNote>
<date type='modification'>20070420T093242Z</date>
</termGrp></ntig>
<ntig><termGrp>
<term>Calibramiento</term>
<termNote type='termType'>full form</termNote>
<termNote type='TS_CreateId'>Alexandra M|tzel</termNote>
<date type='origination'>20070420T093242Z</date>
<termNote type='TS_UpdateId'>Alexandra M|tzel</termNote>
<date type='modification'>20070420T093242Z</date>
</termGrp></ntig>
</langSet>
</termEntry>
<termEntry id='5383'>
<note type='TS_Subject'>FW4000</note>
<note type='TS_CreateId'>Gerald Dennett</note>
<date type='origination'>20040319T092948Z</date>
<note type='TS_UpdateId'>susanne</note>
<date type='modification'>20040320T224024Z</date>
<langSet lang='eng-gb'>
<ntig><termGrp>
<term>Calibration</term>
<termNote type='termType'>full form</termNote>
<termNote type='TS_CreateId'>Gerald Dennett</termNote>
<date type='origination'>20040319T092948Z</date>
<termNote type='TS_UpdateId'>susanne</termNote>
<date type='modification'>20081117T123010Z</date>
<termNote type='TS_PartOfSpeech'>lblCalibration</termNote>
<descrip type='context'>Rainbow_frmEnterItems</descrip>
<termNote type='TS_Source'>September 2003</termNote>
</termGrp></ntig>
</langSet>
<langSet lang='spa-es'>
<ntig><termGrp>
<term>Calibracisn</term>
<termNote type='termType'>full form</termNote>
<termNote type='TS_CreateId'>Gerald Dennett</termNote>
<date type='origination'>20040319T092948Z</date>
<termNote type='TS_UpdateId'>susanne</termNote>
<date type='modification'>20081117T123010Z</date>
<termNote type='TS_PartOfSpeech'>lblCalibration</termNote>
<descrip type='context'>Rainbow_frmEnterItems</descrip>
<termNote type='TS_Source'>September 2003</termNote>
</termGrp></ntig>
</langSet>
</termEntry>
</body>
</text>
</martif>



Thank you so much for your potential help and your attention. Best regards,

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-2011 All Rights Reserved.