469,360 Members | 1,608 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

Removing following sibling same element name

samueln12
Hi All,

I want to remove the immediate following sibling element name

For e.g.

Expand|Select|Wrap|Line Numbers
  1. <def-item>
  2.   <term id="G1">CGRP</term>
  3.   <abr-rel-sym style="inline">&#x02009;</abr-rel-sym>
  4.   <abr-rel-sym style="inline">=</abr-rel-sym>
  5.   <abr-rel-sym style="inline">&#x02009;</abr-rel-sym>
  6.   <def>
  7.     <p>Calcitonin gene-related peptide</p>
  8.   </def>
  9. </def-item>
to

Expand|Select|Wrap|Line Numbers
  1. <def-item>
  2.   <term id="G1">CGRP</term>
  3.   <abr-rel-sym style="inline">&#x02009;=&#x02009;</abr-rel-sym>
  4.   <def>
  5.     <p>Calcitonin gene-related peptide</p>
  6.   </def>
  7. </def-item>
Can any one help me how to do this

Thanks
Sam
Feb 4 '09 #1
4 3511
Dormilich
8,652 Expert Mod 8TB
do you want to use XSLT or any programming language?
Feb 4 '09 #2
I want to use XSLT, thanks for your help in advance
Feb 4 '09 #3
jkmyoung
2,057 Expert 2GB
Something like:
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="*">
  2.   <xsl:if test="name() != name(preceding-sibling::*[1])">
  3.     <xsl:copy>
  4.       <xsl:copy-of select="@*">
  5.       <xsl:value-of select="."/>
  6.       <xsl:if test="name() = name(following-sibling::*[1])">
  7.         <xsl:apply-templates select="following-sibling::*[1]" mode="merge"/>
  8.       </xsl:if>
  9.     </xsl:copy>
  10.   </xsl:if>
  11. </xsl:template>
  12. <xsl:template match="*" mode="merge"><!-- don't copy element, only it's contents. -->
  13.   <xsl:apply-templates/>
  14. </xsl:template>
  15.  
Feb 4 '09 #4
Wait i will test and let you know
Feb 5 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Michael K?nig | last post: by
1 post views Thread by Petterson Mikael | last post: by
12 posts views Thread by apicard | last post: by
8 posts views Thread by arunmt07 | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.