473,387 Members | 1,512 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,387 software developers and data experts.

Map XML data to another XML

Hi, I have 2 xml document the A and B, i want to to map some of the data from
A to B using XSLT, but without creating a new XML Document. How can i do that?

Thanks
Jan 11 '06 #1
7 1285
Hello!
Hi, I have 2 xml document the A and B, i want to to map some of the data from
A to B using XSLT, but without creating a new XML Document. How can i do that?


In .NET it is possible to redirect the XSLT output to an XmlReader, but
I can't find it now...

But you can also use a MemoryStream: write the output to the memory, set
the stream's position to 0 and read it again:
<http://www.xml.com/pub/a/2002/08/14/dotnetxslt.html?page=2>
--
Pascal Schmitt
Jan 11 '06 #2
Hi Pascal,

Thanks for the reply, actually my problem is i need to get values from a
source XML (A) and put it into another XML using XSL, i don't know if this
can be done and need some clue how to do it.

For example in A.XML
<proposal>
<givenname>Coco<givenname>
<familyname>Lua<familyname>
</proposal>

and i have B.XML
<plan>
<propeserdetail>
<givenname>Coco<givenname>
<familyname>Lua<familyname>
<propeserdetail>
</plan>
i want to use XSL to copy the value from A.xml to B.xml for example
proposal/givenname to map to plan/proposerdetail/givenname

"Pascal Schmitt" wrote:
Hello!
Hi, I have 2 xml document the A and B, i want to to map some of the data from
A to B using XSLT, but without creating a new XML Document. How can i do that?


In .NET it is possible to redirect the XSLT output to an XmlReader, but
I can't find it now...

But you can also use a MemoryStream: write the output to the memory, set
the stream's position to 0 and read it again:
<http://www.xml.com/pub/a/2002/08/14/dotnetxslt.html?page=2>
--
Pascal Schmitt

Jan 12 '06 #3
Appears you are asking to do an in-memory replace in XML B, using XSLT.
To the best of my knowledge, that isn't possible.

--
Naraendira Kumar R.R.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Coco" <Co**@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
Hi Pascal,

Thanks for the reply, actually my problem is i need to get values from a
source XML (A) and put it into another XML using XSL, i don't know if this
can be done and need some clue how to do it.

For example in A.XML
<proposal>
<givenname>Coco<givenname>
<familyname>Lua<familyname>
</proposal>

and i have B.XML
<plan>
<propeserdetail>
<givenname>Coco<givenname>
<familyname>Lua<familyname>
<propeserdetail>
</plan>
i want to use XSL to copy the value from A.xml to B.xml for example
proposal/givenname to map to plan/proposerdetail/givenname

"Pascal Schmitt" wrote:
Hello!
> Hi, I have 2 xml document the A and B, i want to to map some of the
> data from
> A to B using XSLT, but without creating a new XML Document. How can i
> do that?


In .NET it is possible to redirect the XSLT output to an XmlReader, but
I can't find it now...

But you can also use a MemoryStream: write the output to the memory, set
the stream's position to 0 and read it again:
<http://www.xml.com/pub/a/2002/08/14/dotnetxslt.html?page=2>
--
Pascal Schmitt

Jan 12 '06 #4
Appears you are asking to do an in-memory update of XML B document, via
XSLT.
To the best of my knowledge, that isn't possible.

--
Naraendira Kumar R.R.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Coco" <Co**@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
Hi Pascal,

Thanks for the reply, actually my problem is i need to get values from a
source XML (A) and put it into another XML using XSL, i don't know if this
can be done and need some clue how to do it.

For example in A.XML
<proposal>
<givenname>Coco<givenname>
<familyname>Lua<familyname>
</proposal>

and i have B.XML
<plan>
<propeserdetail>
<givenname>Coco<givenname>
<familyname>Lua<familyname>
<propeserdetail>
</plan>
i want to use XSL to copy the value from A.xml to B.xml for example
proposal/givenname to map to plan/proposerdetail/givenname

"Pascal Schmitt" wrote:
Hello!
> Hi, I have 2 xml document the A and B, i want to to map some of the
> data from
> A to B using XSLT, but without creating a new XML Document. How can i
> do that?


In .NET it is possible to redirect the XSLT output to an XmlReader, but
I can't find it now...

But you can also use a MemoryStream: write the output to the memory, set
the stream's position to 0 and read it again:
<http://www.xml.com/pub/a/2002/08/14/dotnetxslt.html?page=2>
--
Pascal Schmitt


Jan 12 '06 #5
Appears you are asking to do an in-memory update of XML B document, via
XSLT.
To the best of my knowledge, that isn't possible.

--
Naraendira Kumar R.R.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Coco" <Co**@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
Hi Pascal,

Thanks for the reply, actually my problem is i need to get values from a
source XML (A) and put it into another XML using XSL, i don't know if this
can be done and need some clue how to do it.

For example in A.XML
<proposal>
<givenname>Coco<givenname>
<familyname>Lua<familyname>
</proposal>

and i have B.XML
<plan>
<propeserdetail>
<givenname>Coco<givenname>
<familyname>Lua<familyname>
<propeserdetail>
</plan>
i want to use XSL to copy the value from A.xml to B.xml for example
proposal/givenname to map to plan/proposerdetail/givenname

"Pascal Schmitt" wrote:
Hello!
> Hi, I have 2 xml document the A and B, i want to to map some of the
> data from
> A to B using XSLT, but without creating a new XML Document. How can i
> do that?


In .NET it is possible to redirect the XSLT output to an XmlReader, but
I can't find it now...

But you can also use a MemoryStream: write the output to the memory, set
the stream's position to 0 and read it again:
<http://www.xml.com/pub/a/2002/08/14/dotnetxslt.html?page=2>
--
Pascal Schmitt

Jan 12 '06 #6
Appears you are asking to do an in-memory update of XML B document, via
XSLT.
To the best of my knowledge, that isn't possible.

--
Naraendira Kumar R.R.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Coco" <Co**@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
Hi Pascal,

Thanks for the reply, actually my problem is i need to get values from a
source XML (A) and put it into another XML using XSL, i don't know if this
can be done and need some clue how to do it.

For example in A.XML
<proposal>
<givenname>Coco<givenname>
<familyname>Lua<familyname>
</proposal>

and i have B.XML
<plan>
<propeserdetail>
<givenname>Coco<givenname>
<familyname>Lua<familyname>
<propeserdetail>
</plan>
i want to use XSL to copy the value from A.xml to B.xml for example
proposal/givenname to map to plan/proposerdetail/givenname

"Pascal Schmitt" wrote:
Hello!
> Hi, I have 2 xml document the A and B, i want to to map some of the
> data from
> A to B using XSLT, but without creating a new XML Document. How can i
> do that?


In .NET it is possible to redirect the XSLT output to an XmlReader, but
I can't find it now...

But you can also use a MemoryStream: write the output to the memory, set
the stream's position to 0 and read it again:
<http://www.xml.com/pub/a/2002/08/14/dotnetxslt.html?page=2>
--
Pascal Schmitt



Jan 12 '06 #7
Hello!

The easiest (but not the fastest) way to do this could be the following
(untested, never did this...)

Transform A using the stylesheet into a MemoryStream. Reset the stream
to its initial position. Create a new XmlDocument, load B. Create
another XmlDocument, load the transformation's output from the MemoryStream.

XmlDocument bDoc...; XmlDocument xslOutput...;

XmlNode sel = xslOutput.SelectSingleNode("/some/xpath");
sel = bDoc.ImportNode(sel, true);

XmlElement target = bDoc.SelectSingleNode("/target/path") as XmlElement;
target.AppendChild( sel );
But you can also combine two documents using XSLT: use an
XslArgumentList, and add new XPathDocument("b.xml").Select("/") as a
param. In you stylesheet you can then use the contents of a.xml and b.xml:

<stylesheet ...>
<param name="b" />
<template match="/">
<value-of select="count(//*)" /> Nodes in a.
<value-of select="count($b//*)" /> Nodes in b.
</template>
</stylesheet>

Your example could look like:

<stylesheet ...>
<param name="b" />
<template match="/">
<o:plan>
<for-each select="$b/proposal">
<o:proposerdetail>
<copy-of select="node()" />
</o:proposerdetail>
</for-each>
</o:plan>
</template>
</stylesheet>
You then just have to Transform from A.xml to temp.xml, then delete
B.xml and rename [eg. move] temp.xml to B.xml
--
Pascal Schmitt
Jan 12 '06 #8

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

Similar topics

10
by: Randell D. | last post by:
Folks, Perhaps someone can figure this out - this is 'the process of my script' I have a form whereby I can add multiple contacts to a single address. There is only one...
2
by: ben moretti | last post by:
hi i'm learning python, and one area i'd use it for is data management in scientific computing. in the case i've tried i want to reformat a data file from a normalised list to a matrix with some...
2
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser ...
10
by: mattmerc | last post by:
Hi all, I posted this about a week back with no response so I want to try again. I have a weird questions in regards to working with sql image data types. I know how to take the image type and...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
4
by: Cerebral Believer | last post by:
Hi I need help! Forgive me I am a PHP newbie. I have a small script that enables me to send a form from an HTML page. I want to use the HTML formatted form because the design of my website is...
0
by: pintu | last post by:
Hi..I posted my message earlier but it was not properly described..so am posting again. I am working in an application in which i hav to send the contents of an xml file(from my local machine)...
4
by: Dave | last post by:
I have a global.asax file with Application_Start defined and create some static data there and in another module used in the asp.net application and I realize that static data is shared amongst...
3
by: Sin Jeong-hun | last post by:
It seems like the Protect() uses the Windows accout information to encrypt data. If I know the user name and the password, can I decrypt it on another PC? If it is not, how about the exported key?...
10
by: nflacco | last post by:
I'm tinkering around with a data collection system, and have come up with a very hackish way to store my data- for reference, I'm anticipating collecting at least 100 million different dataId...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...

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.