473,383 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 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 3947
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

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

Similar topics

3
by: Peter Rohleder | last post by:
Hi, I'm using a style-sheet where I make use of the XPATH-"following-sibling"-expression. The part which makes problems looks similar to the following code: --------------------------- ...
2
by: Michael K?nig | last post by:
Hello, I've an XML-file structured like this <table> <tr> <td>Nombre:</td> <td>Joseph</td> <td>Apellido:</td> <td>Ratzinger</td>
3
by: Mori | last post by:
I have the following xml. I need to use XPath to get the year when ever the style is pickup. Both year and style are siblings. <?xml version="1.0" encoding="UTF-8"?> <automobiles>...
0
by: Kathy Burke | last post by:
I'm providing the following syntax in hopes someone could tell me why I get an object reference error on the second one. The first one works, using an xmlDocument, the second one immediately...
1
by: Petterson Mikael | last post by:
Hi, If sibling # 2 is enumRef, in xsl, I will call enumNameString template. In my example, xml, it is an enumRef but still the call to enumNameString is not performed. The otherwise is performed...
12
by: apicard | last post by:
I have a simple document like this: <Accept> <XXXX/> <Token image="From"/> <Date value="2007-01-01"/> <Token image="To"/> <Date value="2007-01-01"/> </Accept>
8
by: arunmt07 | last post by:
Hi ALL, Can anyone suggest me how I can get the element name by knowing its attribute value. For eg: <Channel> <US> <C100345> <Article id="345">
9
by: tgow | last post by:
Hi Everyone, I have the following XML: <input type ="Data"> <parameter name ="Name"> <variable type="Static"> <!]> </variable> ...
2
samueln12
by: samueln12 | last post by:
Hello Guru's, I need a help from u guys, I am working on XSLT and my XML is like this <text><i>Hello</i><i> world</i>... <i>Here</i> we <i>go</i>... <i>This</i> <i>is</i> for sample</text> ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.