473,608 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is the fastest possible xsl style sheet to add another <box> node under <boxes> ?

DR
What is the fastest possible xsl style sheet to add another <boxnode under
<boxes?

<foo>
<car></car>
<boxes>
<box id="234" />
<box id="75" />
</boxes>
</foo>

here is what i want it to look like after the xsl adds another box node:

<foo>
<car></car>
<boxes>
<box id="89">
<bar id="1" />
<bar id="35" />
</box>
<box id="234" />
<box id="75" />
</boxes>
</foo>

notice that the node i want to insert under /foo/boxes is:

<box id="89">
<bar id="1" />
<bar id="35" />
</box>

and i want it to appear at the top of the list, befor the other two <box>
nodes
Nov 1 '07 #1
1 1963
DR wrote:
What is the fastest possible xsl style sheet to add another <boxnode under
<boxes?

<foo>
<car></car>
<boxes>
<box id="234" />
<box id="75" />
</boxes>
</foo>

here is what i want it to look like after the xsl adds another box node:

<foo>
<car></car>
<boxes>
<box id="89">
<bar id="1" />
<bar id="35" />
</box>
<box id="234" />
<box id="75" />
</boxes>
</foo>

notice that the node i want to insert under /foo/boxes is:

<box id="89">
<bar id="1" />
<bar id="35" />
</box>

and i want it to appear at the top of the list, befor the other two <box>
nodes

<xsl:styleshe et ...>
<!-- copy all as is -->
<xsl:template match="@*|node( )">
<xsl:copy>
<xsl:apply-templates select="@*|node ()"/>
</xsl:copy>
</xsl:template>

<!-- boxes element is special -->
<xsl:template match="boxes">
<!-- copy boxes element and its attributes -->
<xsl:copy>
<xsl:apply-templates select=@*/>
<!-- append new content -->
<box id="89">
<bar id="1" />
<bar id="35" />
</box>
<!-- process (copy actually) the rest children -->
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

--
Oleg Tkachenko [XML MVP, MCPD]
http://www.tkachenko.com/blog | http://www.XmlLab.Net
Nov 1 '07 #2

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

Similar topics

4
11909
by: bengee | last post by:
Hi First off - by the word "anchor" i DON'T mean a link, i.e. <a></a> tags I'm trying to position a <select> box inside a <div>. I can use relative positioning to set where the box should appear using "left: ?px; top: ?px;". What i'd like to do though, is set the box so that it's dead horizontally center inside the <div> (don't forget that the width of the select box can change depending on what options i have listed in it).
6
19591
by: joseph.lindley | last post by:
Forgive me for I am a bit of a web-dev novice - but I'm not doing too bad. I'm currently working with a bit of javascript to dynamically add <option>s into a select box. My code currently works fine in Internet Explorer, however in Firefox the dropdown only displays the first option in the list, and when clicked the other values aren't displayed. Here is the code;
14
3621
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good readibility on browsers w/o css-support. For important notes, warnings etc I use the <pre> tag, which shows in a neat bordered box when viewed with css, and depending on its class a clarifying background-image is shown. I would like the...
1
2395
by: OwlHoot | last post by:
I am using Thomas Fuchs's amazing drag-and-drop JavaScript library available at: http://wiki.script.aculo.us/scriptaculous/show/DragAndDrop to allow the user to select a subset of items listed in one box by dragging them to another and sort them in the latter, and it works a treat. However, I'd now like to add a couple of buttons, "<<" and ">>" between
0
8087
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
8493
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
8179
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
8365
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
5499
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
4053
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2493
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
1620
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1363
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.