RE: [xsl] Removing nodes with text content ?

Subject: RE: [xsl] Removing nodes with text content ?
From: "Fabien Tillier" <f.tillier@xxxxxxxx>
Date: Wed, 3 Aug 2011 17:15:09 +0200
Hi Martin.
This one is easier for me to use :)
Seems to be doing the expected work
	<para><phrase role="rtf">

                        <emphasis>(h) </emphasis>

      (antagonist radioligand)

Thank you for giving me the complete answer :)

-----Message d'origine-----
De : Martin Honnen [mailto:Martin.Honnen@xxxxxx]
Envoyi : mercredi 3 ao{t 2011 17:12
@ : xsl-list@xxxxxxxxxxxxxxxxxxxxxx
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:for-each-group select="*"
group-adjacent="boolean(self::phrase[@role = 'rtf'])">
            <xsl:when test="current-grouping-key()">
              <phrase role="rtf">
                <xsl:apply-templates select="current-group()/node()"/>
              <xsl:apply-templates select="current-group()"/>

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

Current Thread