XSLT transform with multiple XML input files

5k Views Asked by At

Is it possible to perform a transform on multiple input XML files?

It doesn't appear to be possible using XslCompiledTransform, but is there an alternative way of applying an XSLT?

3

There are 3 best solutions below

1
On BEST ANSWER

You can use the XSL function document() in your XSLT to reference an external XML file.

0
On
  • Apply the transformation to each input XML file individually and compose the resulting XML documents into a single document.

  • Compose the input XML files into a single document and apply the transformation, e.g.

XElement root = new XElement("root",
    XElement.Load("file1.xml"),
    XElement.Load("file2.xml"),
    XElement.Load("file3.xml"));

XslCompiledTransform transform;
transform.Transform(root.CreateReader(), output);
0
On

With XSL function some security settings are necessary in C#. I believe this is the correct solution:

<xsl:include href="Filename"/>

This method handles multiple files.