Hello,
I have to convert an xml file to another xml file that is very similar, but
some content are different, and the names of some nodes are different. In
fact it's a response to a message : while in the original file there is
<XXX>, the response file should contain <XXXResponse> with the same content
: It's quite easy to modify the InnerText of a node, but it's impossible to
rename the node : Is there a smart way to do this ? Thanks for help.
-------------------------------------------------------
Patrice Dargenton pa************* **@free.fr http://patrice.dargenton.free.fr/index.html
------------------------------------------------------- 5 1358
Patrice Dargenton wrote: I have to convert an xml file to another xml file that is very similar, but some content are different, and the names of some nodes are different. In fact it's a response to a message : while in the original file there is <XXX>, the response file should contain <XXXResponse> with the same content : It's quite easy to modify the InnerText of a node, but it's impossible to rename the node : Is there a smart way to do this ?
XSLT can do that e.g.
<xsl:template match="XXX">
<xsl:element name="{name()}R esponse">
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:element>
</xsl:template>
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
Thanks for the reply. Is it possible with this method to transform several
node names ? for example (XXX or YYY) to {name()}Respons e ?
-------------------------------------------------------
Patrice Dargenton pa************* **@free.fr http://patrice.dargenton.free.fr/index.html
-------------------------------------------------------
"Martin Honnen" <ma*******@yaho o.de> a écrit dans le message de news: ud************* @TK2MSFTNGP10.p hx.gbl...
Patrice Dargenton wrote:
I have to convert an xml file to another xml file that is very similar, but some content are different, and the names of some nodes are different. In fact it's a response to a message : while in the original file there is <XXX>, the response file should contain <XXXResponse> with the same content : It's quite easy to modify the InnerText of a node, but it's impossible to rename the node : Is there a smart way to do this ?
XSLT can do that e.g. <xsl:template match="XXX"> <xsl:element name="{name()}R esponse"> <xsl:copy-of select="@*" /> <xsl:apply-templates /> </xsl:element> </xsl:template>
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
Patrice Dargenton wrote: Is it possible with this method to transform several node names ? for example (XXX or YYY) to {name()}Respons e ? <xsl:template match="XXX">
You would simply write that template as
<xsl:template match="XXX | YYY">
then, the rest as before. XSLT is rather powerful when it comes to
transforming XML to XML. But as a declarative language with an XML
syntax it is not what some people are used to and can easily start with.
On the other hand XSLT 1.0 is well established and documented for years
now so you will find lots of tutorials, documentations, articles, bools
and archived posts that will help you if you want to learn it.
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
Thanks a lot, I will try this.
Patrice.
Martin Honnen a écrit : Patrice Dargenton wrote:
Is it possible with this method to transform several node names ? for example (XXX or YYY) to {name()}Respons e ?
<xsl:template match="XXX">
You would simply write that template as <xsl:template match="XXX | YYY"> then, the rest as before. XSLT is rather powerful when it comes to transforming XML to XML. But as a declarative language with an XML syntax it is not what some people are used to and can easily start with. On the other hand XSLT 1.0 is well established and documented for years now so you will find lots of tutorials, documentations, articles, bools and archived posts that will help you if you want to learn it. -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
I tried this transformation :
<?xml version="1.0" ?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template match="A1 | B1 | B2 | C1">
<xsl:element name="{name()}R esponse">
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
on this test file :
<?xml version="1.0" encoding="utf-8"?>
<A1 name="A1Name">
<B1 name="B1Name" />
<B2 name="B2Name">
<C1 name="C1Name" />
</B2>
</A1>
The result is :
<A1Response name="A1Name">
<B1Response name="B1Name">
</B1Response>
<B2Response name="B2Name">
<C1Response name="C1Name">
</C1Response>
</B2Response>
</A1Response>
I would like to avoid </B1Response> and </C1Response>, and to keep unchanged
the nodes that are not included in the match criteria : I think this is a
complex task, and I wonder whether I will not do better if I rewrite all
file node per node ...
-------------------------------------------------------
Patrice Dargenton pa************* **@free.fr http://patrice.dargenton.free.fr/index.html
-------------------------------------------------------
"Martin Honnen" <ma*******@yaho o.de> a écrit dans le message de news: ud************* @TK2MSFTNGP10.p hx.gbl...
Patrice Dargenton wrote:
I have to convert an xml file to another xml file that is very similar, but some content are different, and the names of some nodes are different. In fact it's a response to a message : while in the original file there is <XXX>, the response file should contain <XXXResponse> with the same content : It's quite easy to modify the InnerText of a node, but it's impossible to rename the node : Is there a smart way to do this ?
XSLT can do that e.g. <xsl:template match="XXX"> <xsl:element name="{name()}R esponse"> <xsl:copy-of select="@*" /> <xsl:apply-templates /> </xsl:element> </xsl:template>
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew V. Romero |
last post by:
At work we have an excel file that contains the list of medications and
their corresponding strengths. I would like to save the excel file as a
text list and paste this list into a javascript function and have JS put
this into an array. Then JS would use this array to create a selection
list which displays only the names of the drugs. When the user
selections one of the drugs, another selection list will be loaded with
the avaiable...
|
by: ET |
last post by:
I don't know whats the problem, but after I added functions
to first verify, then relink linked tables if not found,
now I can't convert that database to MDE format.
I can split the database, but can't convert
part of the database with forms, reports, queries to MDE format.
Can somebody advice on this?
References, in the order, from the top:
|
by: Scott Schluer |
last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG)
to a B&W photo?
Thanks,
Scott
|
by: Alan Silver |
last post by:
Hello,
I have installed the 2.0 framework, and am looking at converting some of
my 1.1 pages to use partial classes. I don't (yet) have VS2005, so I'm
doing this by hand, but am having problems.
I have a simple page that I made in the beta2 version of VWD. The code
behind looks like...
using System;
|
by: Wolfgang Kaml |
last post by:
Dear all,
I am using the following code to retrieve the size of a certain file and the
available (free) space on the disk. The problem is, that I get the size of
the file returned as a Long and the size of free disk space as UInt64.
Apparently, there are no function to convert a Long to a UInt64 or to
compare the two (I'm not expecting to convert the UInt64 to a Long
necessarily, but it should work the other way round, right?).
Short...
| |
by: nacho |
last post by:
Hello, I'm developing an application using C# as main language,
InfoPath as Input for a XML file and a Web Service in c# to deal with
the XML file generated by InfoPath and then convert it into another
different and customized XML file which I will used from a web
application in C#
The problem:
In InfoPath I have a field as "file attachment", I click on it, attach
the a video in "avi" format and submit it to a Web Service. XML file is...
|
by: xpcer |
last post by:
Please help me to convert database.
This is the problem,
i work at an IT company. i'm junior database engineer at there.
my task is converting database file from another format to mysql format.
for example : our client give me the DBF file or MDB file. So, i must to convert it to mysql format.
The problem will happen when i want to transfer the file from the old file to new file.
I mean like it :
|
by: GM |
last post by:
Dear all,
Could you all give me some guide on how to convert my big5 string to
unicode using python? I already knew that I might use cjkcodecs or
python 2.4 but I still don't have idea on what exactly I should do.
Please give me some sample code if you could. Thanks a lot
Regards,
Gary
|
by: shapper |
last post by:
Hello,
Could someone tell me how to convert a XML file into another XML file
using a XSL file with a parameter? I created the code to do it, and it
seems ok, but it is not working.
Could somebody, please, help me out? I am on this for days.
My code is as follows:
|
by: elliotng.ee |
last post by:
I have a text file that contains a header 32-bit binary. For example,
the text file could be:
%%This is the input text
%%test.txt
Date: Tue Dec 26 14:03:35 2006
00000000000000001111111111111111
11111111111111111111111111111111
00000000000000000000000000000000
11111111111111110000000000000000
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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,...
|
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...
|
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...
|
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();...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |