xsl-list
[Top] [All Lists]

RE: [xsl] Removing nodes with text content ?

2011-08-03 10:15:20
Hi Martin.
This one is easier for me to use :)
Seems to be doing the expected work
        <para><phrase role="rtf">
      norepinephrine
    
      transporter<subscript/>
                        <emphasis>(h) </emphasis>
                     
      (antagonist radioligand)
    </phrase></para>

Thank you for giving me the complete answer :)
Regards,
Fabien


-----Message d'origine-----
De : Martin Honnen [mailto:Martin(_dot_)Honnen(_at_)gmx(_dot_)de] 
Envoyé : mercredi 3 août 2011 17:12
À : xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Objet : Re: [xsl] Removing nodes with text content ?

Fabien Tillier wrote:
Hi Andrew.
Hum... should I say I can't have it work ?
<xsl:for-each-group select="para/phrase" group-adjacent="@role">
      <xsl:copy-of select="."/>                                       
</xsl:for-each-group>

Gives
<?xml version="1.0" encoding="UTF-8"?>
<phrase role="rtf">
       norepinephrine
</phrase>

Try along these lines

   <xsl:template match="para">
     <xsl:copy>
       <xsl:for-each-group select="*" 
group-adjacent="boolean(self::phrase[@role = 'rtf'])">
          <xsl:choose>
            <xsl:when test="current-grouping-key()">
              <phrase role="rtf">
                <xsl:apply-templates select="current-group()/node()"/>
              </phrase>
            </xsl:when>
            <xsl:otherwise>
              <xsl:apply-templates select="current-group()"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:for-each-group>
      </xsl:copy>
   </xsl:template>

Might need an identity transformation template for all nodes you want to 
copy by the apply-templates in the otherwise branch.



-- 

        Martin Honnen --- MVP Data Platform Development
        http://msmvps.com/blogs/martin_honnen/

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

<Prev in Thread] Current Thread [Next in Thread>