By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,797 Members | 1,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,797 IT Pros & Developers. It's quick & easy.

Merging/Linking XML files?

P: n/a
I have an XML document that is linked to other document and I can't figure out what the best way to try and merge them before query qith an XpathNavigator.

Simple example...a root xml document contains the root folder that can contain items and other folders. The other folders can either live in the root document or be in other xml files completely (to make it easier for multiple developers/processes to work on the data at the same time.)

I think the developer that was doing it before was using xlink or xpointer to see if the folder had an href attribute and then called some script to open the document and merge it with the parent creating one big tree (to query later).

Does anyone know what the best way to do this in .Net would be? I think i could do it running the intial file through XSLT and use the document() function but I'm wondering if there is a better way to do this.

Thanks,

Cy Huckaba
Austin, TX
rootFolder.xml ******************

<folder name="rootFolder">
<item name="a" />
<item name="b" />
<item name="c" />

<folder name="thingys">
<item name="ta" />
<item name="tb" />
</folder>

<folder name="widgets" href="widgets.xml"></folder>

<item name="d" />

</folder>

widgets.xml *****************************

<item name="wa" />
<item name="wb" />
<item name="wc" />

<folder name="widgets">
<item name="wwa" />
<item name="wwb" />
</folder>

<item name="wd" />
Nov 11 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Cy Huckaba wrote:
I have an XML document that is linked to other document and I can't
figure out what the best way to try and merge them before query qith an
XpathNavigator.

Simple example...a root xml document contains the root folder that can
contain items and other folders. The other folders can either live in
the root document or be in other xml files completely (to make it easier
for multiple developers/processes to work on the data at the same time.)

I think the developer that was doing it before was using xlink or
xpointer to see if the folder had an href attribute and then called some
script to open the document and merge it with the parent creating one
big tree (to query later).

Does anyone know what the best way to do this in .Net would be? I think
i could do it running the intial file through XSLT and use the
document() function but I'm wondering if there is a better way to do this.


There is standard way of doing that - XInclude [1]. Then you can have the
following in your document:
<xi:include href="widgets.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
This will include the whole widgets.xml, or
<xi:include href="widgets.xml#xpointer(//folder[@name='widgets'])"
xmlns:xi="http://www.w3.org/2001/XInclude"/>
to include only specified elements.
The plumbing to process it under .NET you can find at GotDotNet, in
XInclude.NET workspace [2]. It provides XIncludingReader class, which
implements XmlReader so can be used everywhere. Just read your XML via this
reader and don't care about underlying including and merging.

[1] http://www.w3.org/TR/xinclude
[2]
http://gotdotnet.com/Community/Works...9-6c42947b04a8
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2

P: n/a
Thanks Oleg, I'm looking into it now.

Also, I liked your Extreme XML article on MSDN. Nice to see that authors are
still helping with the newgroups.

Thanks again,

Cy

"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:#Y**************@tk2msftngp13.phx.gbl...
Cy Huckaba wrote:
I have an XML document that is linked to other document and I can't
figure out what the best way to try and merge them before query qith an
XpathNavigator.

Simple example...a root xml document contains the root folder that can
contain items and other folders. The other folders can either live in
the root document or be in other xml files completely (to make it easier
for multiple developers/processes to work on the data at the same time.)

I think the developer that was doing it before was using xlink or
xpointer to see if the folder had an href attribute and then called some
script to open the document and merge it with the parent creating one
big tree (to query later).

Does anyone know what the best way to do this in .Net would be? I think
i could do it running the intial file through XSLT and use the
document() function but I'm wondering if there is a better way to do this.
There is standard way of doing that - XInclude [1]. Then you can have the
following in your document:
<xi:include href="widgets.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
This will include the whole widgets.xml, or
<xi:include href="widgets.xml#xpointer(//folder[@name='widgets'])"
xmlns:xi="http://www.w3.org/2001/XInclude"/>
to include only specified elements.
The plumbing to process it under .NET you can find at GotDotNet, in
XInclude.NET workspace [2]. It provides XIncludingReader class, which
implements XmlReader so can be used everywhere. Just read your XML via this
reader and don't care about underlying including and merging.

[1] http://www.w3.org/TR/xinclude
[2]

http://gotdotnet.com/Community/Works...e8-cb4b-47c4-a
9d9-6c42947b04a8 --
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.