I have a nested folder structure structure containing dozens of various files (XML, DTD, XSL) with XML files referencing other DTD, XSL, and other XMLs (which can also reference other files). I.e. something like this (I removed some similar lines for brevity):
all.xml - root file:
<?xml version="1.0" ?> <!DOCTYPE notification [ <!ELEMENT notification ANY> <!ENTITY % types SYSTEM "dtd/types.dtd"> <!ENTITY % from SYSTEM "dtd/from.dtd"> <!ENTITY types_en SYSTEM "lang/en/types.xml"> <!ENTITY from_en SYSTEM "lang/en/from.xml"> <!ENTITY subj_ru SYSTEM "lang/ru/subjects.xml"> <!ENTITY desc_en SYSTEM "lang/en/descriptions.xml"> <!ENTITY regexp_en SYSTEM "lang/en/placeholders.xml"> %types; %from; ]> <notification> &types_en; &from_en; &templ_fr; </notification>
<?xml version="1.0" encoding="UTF-8" ?> <?xml-stylesheet type="text/xsl" href="../../xsl/descriptions.xsl"?> <!--DOCTYPE descriptions SYSTEM "../../dtd/descriptions.dtd"--> <descriptions lang="en">
And so on. So, there is a root file which includes DTDs and many other files which also include their own DTDs and XSL tables (different ones for different XMLs).
I need to find the way to merge them all into a single file. All solutions I found so far we either about merging several independent XML files or about adding a single DTD to a file (while in my case different DTDs are applied to different files and not all XMLs are independent because they are nested). The result of a single XML fine would be great.
Or, I'd almost be happy if I was able to just pack all the folders into a single file (.zip) and later read it like MS .docx format (where .ZIP file represents an isolated filesystem with working references between contained files). The file is processed with my own C# software so I don't need to bother about compatibility with other XML readers. But I don't know any method in .NET which would allow me to read and XML-parse a .ZIP file like a filesystem.
Or, maybe there is a method to catch any attempt to access any resource (be it another XML, DTD or XSLT) when parsing XML data with XmlTextReader? The purpose is to be able to intercept all requests to missing files and supply the contents of the requested resources to the XmlTextReader when it requests them.
Right now, I'm researching if System.IO.Packaging (OpenXML) can serve this purpose.