xsl-list
[Top] [All Lists]

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

2009-02-05 05:46:26


Just move the if test up before you create the outer element.
ehile I was there I simplified mist of the other code which seemed to be
more verbose than needed,


<?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[(_at_)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">
      <xsl:variable name="t" 
select="langSet[(_at_)lang='spa-es']/ntig/termGrp/term
                                     [generate-id(.) = 
generate-id(key('spa-term',  .)[1])]"/>
      <xsl:if test="$t">
       <termEntry id="{(_at_)id}">
        <langSet lang="spa-es"><ntig><termGrp>
         <xsl:for-each  select="$t">
          <xsl:copy-of select="."/>
          <xsl:copy-of select="../termNote"/>>
          <xsl:copy-of select="../date"/>>
         </xsl:for-each>
        </termGrp>
       </ntig>
        </langSet>  
       </termEntry>
      </xsl:if>
     </xsl:for-each>
     
    </body>
   </text>
  </martif>
 </xsl:template>
</xsl:stylesheet>

David

________________________________________________________________________
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>
--~--