473,597 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Removing following sibling same element name

samueln12
28 New Member
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 3960
Dormilich
8,658 Recognized Expert Moderator Expert
do you want to use XSLT or any programming language?
Feb 4 '09 #2
samueln12
28 New Member
I want to use XSLT, thanks for your help in advance
Feb 4 '09 #3
jkmyoung
2,057 Recognized Expert Top Contributor
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
samueln12
28 New Member
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
11295
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: --------------------------- <xsl:for-each select="headdata/extension/person">
2
5882
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
3748
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> <automobile> <style>pickup</style> <make>chevy</make> <year>2002</year> </automobile>
0
1228
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 follows and uses the same xmlDocument. It works if the result is not Nothing. I've used similar xpath expressions (but never with the following-sibling reference) and the If Nothing works ok. Spent hours on this, but I need another set of eyes and a...
1
1378
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 :-) Any ideas why? cheers,
12
3654
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
2584
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
6157
by: tgow | last post by:
Hi Everyone, I have the following XML: <input type ="Data"> <parameter name ="Name"> <variable type="Static"> <!]> </variable> </parameter>
2
2408
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> transform to <text><i>Hello world</i>... <i>Here</i> we <i>go</i>... <i>This</i> <i>is</i> for sample</text>
0
7971
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8259
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6698
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3889
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3932
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2408
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1495
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1243
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.