I have a 7K lines, 500kb XML file. While this sounds ridiculous to call such a file large, it is a configuration file which is edited by hand and in this context the size is a problem:
- Syntax highlighting is extremely slow (at least it is in IntelliJ)
- Searching something in such a large file is a pain
Thus I would like to split the file into a number of small files. XInclude actually sounds great however there exists a sophisticated XSD which aids greatly in preventing errors including references to foreign keys and indexes which must be unique across the whole file. If I split the XML file into multiple small files the validation needs to span multiple files and check cross references.
--> I need the validator to first perform XInclude and then perform validation. While google suggests this is possible I have not been able to get this right: I tried to get it working with xmllint --xinclude --schema mySchema.xsd myXMLWithPlentyOfXIncludes.xml
, but if the included files contain no namespace, the validator complains that an unexpected tag has been found (because of wrong namespace) and if I add the xmlns attribute to the root tag of the included file it complains The attribute '{http://www.w3.org/XML/1998/namespace}base' is not allowed
.
So how should I set things up to get namespaces across files right? How do I get the validation done? Are there any more caveats I should be aware of?
Bonus: How do I get the validation to work in IntelliJ?
Sounds like a case for entities. Make each of the small files a single XML external entity, which can be edited on its own, and replace the master file with a very small file that simply links to these entities with entity references (&one; etc). When you run validation on the master file it will pull in the entities automatically.