473,508 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to recursively remove nodes from a set

1 New Member
The following code is meant to take a set of entry elements and while iterating through them using recursion, output a <spanspec> tag for each unique set of @namest and @nameend attributes found in the elements of the set. The output of this seems to be very unpredictable though creating duplicate spanspecs as well as stopping at unusual points. It seems to have numerous errors, but I would love to clean this up quickly to work appropriately.

-Robert Stone


<xsl:template name="add-missing-spanspecs">

<xsl:param name="entries" />
<xsl:variable name="first-bad-entry">
<xsl:copy-of select="$entries[1]" />
</xsl:variable>

<xsl:if test="count($entries) > 0">

<!-- output spanspec for $first-bad-entry -->

<xsl:variable name="remaining-entries"
select="$entries[ not( @namest = first-bad-entry/entry[1]/@namest and @nameend = first-bad-entry/entry[1]/@nameend ) ]" />

<xsl:call-template name="add-missing-spanspecs">
<xsl:with-param name="entries" select="$remaining-entries" />
</xsl:call-template>
</xsl:if>

</xsl:template>
Oct 24 '07 #1
1 1591
jkmyoung
2,057 Recognized Expert Top Contributor
Since you're taking unique attribute values, I suggest you use Muenchian grouping, instead of your template:
http://www.jenitennison.com/xslt/grouping/muenchian.html
Here is an altered version of this based on the concept
Expand|Select|Wrap|Line Numbers
  1. <xsl:for-each select="entry">
  2.   <xsl:if test="not(preceding-sibling::entry[@namest = current()/@namest][@nameend=current()/@nameend])">
  3.     <!-- output spansec here -->
  4.   </xsl:if>
  5. </xsl:for-each>
  6.  
Oct 25 '07 #2

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

Similar topics

0
2755
by: Dinesh | last post by:
Hi, I have two tables 'master' and 'child', the master is the master table for all nodes in all trees. To get children of any node, we need to go to the 'child' table to get the nodeid of the...
2
7939
by: Claudio Jolowicz | last post by:
How can XSLT stylesheets be used to edit, remove and add nodes specified by their position in the document tree? The XML document stores development tasks in a hierarchical way, i.e. tasks can...
6
3498
by: Nikhil Patel | last post by:
Hi all, Following is a portion of an XML document. I need to remove all nodes that belong to ns0 without deleting their child nodes. So in the following example , I want to delete "ns0:Proposal"...
1
1951
by: Lanny McDonald | last post by:
I have built a treeview that looks something like: Root .....FolderLevel1a .........FolderLevel2a
2
21987
by: Jack | last post by:
Hello, I am trying use a TreeView with checkboxes. I would like to check more than one node and allow all child nodes of selected nodes to be checked or unchecked with the parent is checked. ...
3
2640
by: Markus | last post by:
Hi! I wanted to select a subset of nodes (list = selectNodes("parent/child") from a XmlDocument, then remove all (parentNode.removeAll();) child-nodes and insert the previous selected nodes...
5
655
by: rbt | last post by:
What is the most efficient way to recursively remove files and directories? Currently, I'm using os.walk() to unlink any files present, then I call os.walk() again with the topdown=False option...
0
1402
by: thygremlin | last post by:
Hi everyone, I have come by a challenge.... I have the following XML file, which represents expressions with "+" and "*" artihmentic operands: <m value="10"> <i value="5"/> <m...
2
2330
by: graphicsxp | last post by:
Hi, I have the following records stored in the database : TableName: Folder { FolderID, FolderName, TopLevel} TableName: FolderRelationship { ParentID, ChildID} This describes a folder...
11
3296
by: David | last post by:
Hi All, I am working on a script that is theoreticaly simple but I can not get it to work completely. I am dealing with a page spit out by .NET that leaves empty tags in the markup. I need a...
0
7227
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,...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7391
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...
1
7054
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...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4713
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...
0
1564
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 ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
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...

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.