473,772 Members | 3,672 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Removing duplicate text nodes

I would appreciate some guidance not just to the solution but why my
own solutions don't seem to work. Copy.xsl in the code below is an
imported identity template.

Non solution 1
<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="copy.xsl"/>
<xsl:template match="//text()[.=following::te xt()]"/>
</xsl:stylesheet>

Non Solution 2 (because I suspected there may be some issues about
what is the current node)

<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="copy.xsl"/>
<xsl:template match="text()">
<xsl:apply-templates select="text()[not(.=following ::text())]"/>
</xsl:template>
</xsl:stylesheet
Jul 20 '05 #1
3 1585
wo****@hotmail. com (wooks) writes:
I would appreciate some guidance not just to the solution but why my
own solutions don't seem to work. Copy.xsl in the code below is an
imported identity template.

Non solution 1
<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="copy.xsl"/>
<xsl:template match="//text()[.=following::te xt()]"/>
</xsl:stylesheet>

Non Solution 2 (because I suspected there may be some issues about
what is the current node)

<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="copy.xsl"/>
<xsl:template match="text()">
<xsl:apply-templates select="text()[not(.=following ::text())]"/>
</xsl:template>
</xsl:stylesheet


Perhaps you could show an example of what you hope to achieve.
Your first transformation seems to do exactly what you ask:
it removes a duplicated text node.

<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="@*|node( )">
<xsl:copy>
<xsl:apply-templates select="@*|node ()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//text()[.=following::te xt()]"/>
</xsl:stylesheet>

with
<foo>
<a>aaa</a>
<a>bbb</a>
<a>aaa</a>
</foo>

gives
<foo><a/><a>bbb</a>
<a>aaa</a>
</foo>

Ie. the first "aaa" text node is removed. Or were you
after something else?

Ben

--
Ben Edgington
Mail to the address above is discarded.
Mail to ben at that address might be read.
http://www.edginet.org/
Jul 20 '05 #2
Ben Edgington <us****@edginet .org> wrote in message news:<87******* *****@edginet.o rg>...
wo****@hotmail. com (wooks) writes:
I would appreciate some guidance not just to the solution but why my
own solutions don't seem to work. Copy.xsl in the code below is an
imported identity template.

Non solution 1
<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="copy.xsl"/>
<xsl:template match="//text()[.=following::te xt()]"/>
</xsl:stylesheet>

Non Solution 2 (because I suspected there may be some issues about
what is the current node)

<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="copy.xsl"/>
<xsl:template match="text()">
<xsl:apply-templates select="text()[not(.=following ::text())]"/>
</xsl:template>
</xsl:stylesheet


Perhaps you could show an example of what you hope to achieve.
Your first transformation seems to do exactly what you ask:
it removes a duplicated text node.

<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="@*|node( )">
<xsl:copy>
<xsl:apply-templates select="@*|node ()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//text()[.=following::te xt()]"/>
</xsl:stylesheet>

with
<foo>
<a>aaa</a>
<a>bbb</a>
<a>aaa</a>
</foo>

gives
<foo><a/><a>bbb</a>
<a>aaa</a>
</foo>

Ie. the first "aaa" text node is removed. Or were you
after something else?

Ben


No that is what I want and it does work.
There must have been something in the XML I was using. Will
investigate further. Thanks.
Jul 20 '05 #3
Ben Edgington <us****@edginet .org> wrote in message news:<87******* *****@edginet.o rg>...
wo****@hotmail. com (wooks) writes:
I would appreciate some guidance not just to the solution but why my
own solutions don't seem to work. Copy.xsl in the code below is an
imported identity template.

Non solution 1
<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="copy.xsl"/>
<xsl:template match="//text()[.=following::te xt()]"/>
</xsl:stylesheet>

Non Solution 2 (because I suspected there may be some issues about
what is the current node)

<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="copy.xsl"/>
<xsl:template match="text()">
<xsl:apply-templates select="text()[not(.=following ::text())]"/>
</xsl:template>
</xsl:stylesheet


Perhaps you could show an example of what you hope to achieve.
Your first transformation seems to do exactly what you ask:
it removes a duplicated text node.

<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="@*|node( )">
<xsl:copy>
<xsl:apply-templates select="@*|node ()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//text()[.=following::te xt()]"/>
</xsl:stylesheet>

with
<foo>
<a>aaa</a>
<a>bbb</a>
<a>aaa</a>
</foo>

gives
<foo><a/><a>bbb</a>
<a>aaa</a>
</foo>

Ie. the first "aaa" text node is removed. Or were you
after something else?

Ben


Realisation has just dawned... the xml was not well formed (was
generated from a program but had no parent node).
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
8305
by: Matt | last post by:
Hello, I have an XML document similar to the following: <DataItems> <Data xmlns="http://www.me.com"> <DataInformation xmlns:a="http://www.me.com/ASettings" xsi:type="a:Stuff1"> <a:Name>Matt</a:Name> <a:TN>555-5555</a:TN>
3
16040
by: e-mid | last post by:
Here is an xml structure. i want to remove <a> nodes that do not have any child. How can i do that in csharp? <root> <a> <b/> </a> <a/> <a/> <a> <c/>
2
10701
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this attribute and remove the containing node (and child nodes) if it has a certain value. I'm able to find the attributes using an XmlTextReader. Once found, can someone help me get the XPath at that point? I would then use this to remove the node from...
5
11457
by: Jani Yusef | last post by:
Based on an interview question I heard of but did not know the answer to....... How do you find and remove a loop from a singly linked list? In a google groups search I found the following code which will detect the loop but I am stumped how one would remove this loop. Any ideas? typedef enum { FALSE, TRUE } bool;
3
2611
by: dazzle | last post by:
I have an XML file and I would like to remove duplicate nodes within it but I can't get my head round on how to do this. Example XML file: <root> <plugin> <title>A9</title> <url>some url</url>
10
6806
by: Backwards | last post by:
Hello all, I'll start by explaining what my app does so not to confuss you when i ask my question. ☺ I have a VB.Net 2.0 app that starts a process (process.start ...) and passes a prameter through from a combo box. The combo box items are made up of IP address and computer host name. Anything a user places in this combo box it writes this to a txt file called history.txt
0
1454
by: Paulers | last post by:
Hello, I am trying to add sub items to a unique root node but it seems that it is duplicating the root node instead of placing subnode under it. Here is my code. Is ther anyone who can show me how to verify if the root node already exists and if it does add to the existing root node , else create a new one. Any help is GREATLY appreciated :)
4
2614
by: Dmitry Kulinich | last post by:
Guys! Is there are any possibility to create nodes with duplicate names and different types in XSD? I've read the whole specification and tried in a many different ways, but not successfull. -- Thank you for any help, Dmitry Kulinich, Ukrain,
5
2465
by: kosta.triantafillou | last post by:
Hi all, I have a form that contains a lot of values. On this form there are also alot of popups that can be brought up. One of them does the following: Takes 2 values (x and y), concatenates them together with an underscore in between and adds them to a select box in the same popup (z). Then, when a user clicks a save button located on the popup, it sends that information back to the main form and populates the same three values (x,...
0
9620
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
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10104
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...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8934
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
6715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2850
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.