/// <summary> /// Creates a new <see cref="CompositeXmlReader"/> instance wrapping a set of XML data <see cref="Stream"/>s as /// specified by <paramref name="streams"/> and with the specified <see cref="XmlReaderSettings"/> object. /// </summary> /// <param name="streams"> /// The set of compound <see cref="Stream"/>s containing the pieces of XML data to wrap. /// </param> /// <param name="settings"> /// The <see cref="XmlReaderSettings"/> object used to configure the new <see cref="CompositeXmlReader"/> /// instance. This value can be <c>null</c>. /// </param> /// <returns> /// A <see cref="CompositeXmlReader"/> object to read the compound XML <see cref="Stream"/>s as a whole XML /// composite. /// </returns> public static XmlReader Create(IEnumerable <Stream> streams, XmlReaderSettings settings) { var enumerable = streams as Stream[] ?? streams.ToArray(); // checks that streams is not null as well if (!enumerable.Any()) { throw new ArgumentException("List of compound streams is empty.", "streams"); } // it is *essential* that all XmlReaders share the same XmlNameTable for any (most) XslTransform(s) to succeed settings = settings.IfNotNull(s => s.Clone()) ?? new XmlReaderSettings(); settings.NameTable = new NameTable(); var compoundReaders = enumerable .Select(s => new CompoundXmlReader(XmlReader.Create(s, settings))) .ToArray(); var outlineReader = CreateOutline(compoundReaders.Length, settings); return(new CompositeXmlReader(outlineReader, compoundReaders)); }