473,326 Members | 2,111 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,326 software developers and data experts.

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:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="copy.xsl"/>
<xsl:template match="//text()[.=following::text()]"/>
</xsl:stylesheet>

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

<xsl:stylesheet
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 1568
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:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="copy.xsl"/>
<xsl:template match="//text()[.=following::text()]"/>
</xsl:stylesheet>

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

<xsl:stylesheet
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:stylesheet
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::text()]"/>
</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.org>...
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:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="copy.xsl"/>
<xsl:template match="//text()[.=following::text()]"/>
</xsl:stylesheet>

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

<xsl:stylesheet
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:stylesheet
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::text()]"/>
</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.org>...
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:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="copy.xsl"/>
<xsl:template match="//text()[.=following::text()]"/>
</xsl:stylesheet>

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

<xsl:stylesheet
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:stylesheet
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::text()]"/>
</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
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">...
3
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
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...
5
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...
3
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...
10
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...
0
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...
4
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. ...
5
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.