all groups > dotnet xml > july 2003 >
You're in the

dotnet xml

group:

Merging/Linking XML files?


Merging/Linking XML files? Cy Huckaba
7/31/2003 3:23:45 PM
dotnet xml:
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=3D"rootFolder">
<item name=3D"a" />
<item name=3D"b" />
<item name=3D"c" />

<folder name=3D"thingys">
<item name=3D"ta" />
<item name=3D"tb" />
</folder>
=20
<folder name=3D"widgets" href=3D"widgets.xml"></folder>
=20
<item name=3D"d" />

</folder>

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

<item name=3D"wa" />
<item name=3D"wb" />
<item name=3D"wc" />
=20
<folder name=3D"widgets">
<item name=3D"wwa" />
<item name=3D"wwb" />
</folder>
=20
Re: Merging/Linking XML files? Oleg Tkachenko
8/3/2003 11:31:55 AM
[quoted text, click to view]

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/Workspaces/Workspace.aspx?id=cab253e8-cb4b-47c4-a9d9-6c42947b04a8
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
Re: Merging/Linking XML files? Cy Huckaba
8/4/2003 5:50:19 PM
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



[quoted text, click to view]
http://gotdotnet.com/Community/Workspaces/Workspace.aspx?id=cab253e8-cb4b-47c4-a
9d9-6c42947b04a8
[quoted text, click to view]

AddThis Social Bookmark Button