472,119 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

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 3689
Dormilich
8,658 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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.