all groups > dotnet xml > january 2006 >
You're in the

dotnet xml

group:

Combine portions of multiple xml files into 1 xml file using xsl i


Combine portions of multiple xml files into 1 xml file using xsl i PK9
1/18/2006 2:20:03 PM
dotnet xml: I'm building a windows app using C#. The goal is to merge portions of
multiple xml files into one.

I currently have an .xsl stylesheet that pulls in the required sections of
multiple xml files and combines them into one xml file. This xsl works
correctly.

I'm now trying to utilize this xsl in my C# application, along with the
required xml files, to merge them into the one document. Basically I'm
looking for a code example of how to apply the xsl style sheet to the
documents and create a single xml file.

I started working with the XslTransform.Transform method, but it's my
understanding that this only applies to a single xml document. My example
below works if the XSL stylesheet only references a single xml document, but
I need to be able to work with multiple documents:
string strXMLPath = "C:\\XML\\XML Files\\IS\\Management\\Management.xml";
string strXSLPath = "C:\\XML\\StyleSheets\\Application\\MgmtStyles.xsl";

//Instantiate the XPathDocument class
XPathDocument xmlDoc = new XPathDocument(strXMLPath);
//Instantiate the XSLTransform class
XslTransform transform = new XslTransform();

transform.Load(strXSLPath);
XmlTextWriter writer = new XmlTextWriter("C:\\XML_FILES\\XML Data
Files\\IS\\Management\\TEMP.xml",null);
transform.Transform(xmlDoc,null,writer);




--
Re: Combine portions of multiple xml files into 1 xml file using xsl i Oleg Tkachenko [MVP]
1/19/2006 1:21:45 PM
[quoted text, click to view]

You've got at least two options:
1. Load additional XML documents in XSLT stylesheet using document()
function.
2. "merge portions of multiple xml files into one" using XInclude. Take
a look at "Combining XML Documents with XInclude" at
http://msdn.microsoft.com/library/en-us/dnxmlnet/html/xinclude.asp

--
Oleg Tkachenko [XML MVP, MCAD]
AddThis Social Bookmark Button