473,785 Members | 2,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSL - to insert a node

Hi,
I have an xml :

<DataRecords>
<Point Alias='A' Value='1' Status='0' />
<Point Alias='B' Value='2' Status='0' />
</DataRecords>
I have needed by an XSL to insert a node between <DataRecords> and <Point>

Example :

<DataRecords>
<Record>
<Point Alias='A' Value='1' Status='0' />
</Record>
<Record>
<Point Alias='B' Value='2' Status='0' />
</Record>
</DataRecords>

Can anyone help me?

Thanks

Beni

Nov 12 '05 #1
2 4920


Beniamin Tecar wrote:

I have an xml :

<DataRecords>
<Point Alias='A' Value='1' Status='0' />
<Point Alias='B' Value='2' Status='0' />
</DataRecords>
I have needed by an XSL to insert a node between <DataRecords> and <Point>

Example :

<DataRecords>
<Record>
<Point Alias='A' Value='1' Status='0' />
</Record>
<Record>
<Point Alias='B' Value='2' Status='0' />
</Record>
</DataRecords>


Simply use the identity transformation and add one template for <Point>
elements that wraps them into a <Record> element:

<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" encoding="UTF-8" />

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>

<xsl:template match="Point">
<Record>
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</Record>
</xsl:template>

</xsl:stylesheet>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
"Beniamin Tecar" <be************ *******@nivis.c om> wrote in message news:<uK******* *******@TK2MSFT NGP15.phx.gbl>. ..
<DataRecords>
<Point Alias='A' Value='1' Status='0' />
<Point Alias='B' Value='2' Status='0' />
</DataRecords> <DataRecords>
<Record>
<Point Alias='A' Value='1' Status='0' />
</Record>
<Record>
<Point Alias='B' Value='2' Status='0' />
</Record>
</DataRecords>


<xsl:for-each select="DataRec ords/Point">
<xsl:text disable-output-escaping="yes"> &lt;Record&g t;</xsl:text>
<Point>
<xsl:attribut e name="Alias"><x sl:value-of select="@Alias" /></xsl:attribute>
<xsl:attribut e name="Value"><x sl:value-of select="@Value" /></xsl:attribute>
<xsl:attribut e name="Status">< xsl:value-of select="@Status " /></xsl:attribute>
<xsl:text disable-output-escaping="yes"> &lt;/Record&gt;</xsl:text>
</xsl:for-each>

_Randal
Nov 12 '05 #3

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

Similar topics

5
13839
by: Tony B | last post by:
Hi I need to insert a new node into an exisiting XML file using VBScript. The file has the following structure: <TRANSACTION> <ORDER> <BILLING>... </BILLING> <ORDER_TOTALS>... </ORDER_TOTALS> <ITEMS>
4
12395
by: mike | last post by:
Hello. Let's say I have the following XML document: <ROOT><Element1>Some Text</Element1></ROOT> I want to add a new element after Element1. I tried the following but, naturally, it doesn't work: Dim oElem as XmlElement
10
5129
by: florian | last post by:
Hi, we have a contention problem because of an application which tries to insert a duplicate row in a table with primary key. This insert fails of course but the locks are not released within this transcation. Why DB2 does not release the X lock after a failed insert??? We use DB2 UDB EEE Version 7.2 Fixpak 9, but we also can reproduce the Problem on DB2 UDB ESE 8.1 Linux Fixpak 4.
3
22075
by: Andrew Clark | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** it's been a while since i have poseted to this newsgroup, but for a long time i was not programming at all. but now that i am out of college and facing the prospect of getting a real job, i need to get back into the game. anyway, i don't know if some of you know the stanford CS library. i took the problem set a while back and have recently rediscovered it adn have been trying...
2
1351
by: Patrick | last post by:
Hi, im trying to first insert a node in the xml file and save it. XmlDocument mDoc = new XmlDocument(); mDoc.Load("struct.xml"); XmlNode singleNode; XmlNode newNode = mDoc.CreateNode(XmlNodeType.Element, "page", ""); XmlAttribute mAttr = mDoc.CreateAttribute("id");
2
3683
by: wombat53 | last post by:
Hi Group Are there any DB2 UDB ESE DPF V8.2 users exploiting "buffered inserts" (BIND parm INSERT BUF) *and* "multi-row INSERTS" (many rows associated with the VALUES clause of the INSERT to minimize number of calls to the RDMBS engine) in an SQL PL Stored Procedure? I ask, as the latter would imply embedded DYNAMIC SQL due to potentially varying number of rows to be inserted (assume it's varying), and so, the SQL INSERT would have be...
4
3894
by: mathon | last post by:
Hello, im currently implementing a binary search tree means, that a greater number than root will be added as right child and a less number as left child. My insert function looks currently like this: template <class Item> void bag<Item>::insert(const Item& entry) // Header file used: bintree.h
6
20004
by: askmatlab | last post by:
Hello all: I would like to insert a number into a linked list in ascending order. Is the following function correct? void insert(Node **node, int v) { Node *tmp = (Node *)malloc(sizeof(Node)); while(*node && (*node)->value < v) node = &(*node)->next;
7
1484
by: E.F | last post by:
Hi everybody, I get lost trying to insert a node in my xml file with readfile, xpath, xpathnavigator, etc... 1/ my xml file looks like that : <PUPILL_CP_1> <YEAR_2006> <OCTOBRE EffectifDeLaClasse="28" Presents="25" Absents="3" Comment=""
10
10509
by: Aditya | last post by:
Hi All, I would like to know how it is possible to insert a node in a linked list without using a temp_pointer. If the element is the first element then there is no problem but if it is in between then what is the best solution.
0
9645
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
10330
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...
1
10093
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
9952
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
8976
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...
1
7500
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5381
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
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

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.