I have a set of XML files (DocBook, to be specific). These use XML inclusions, aka XInclude, to reference one another. Given one of these XML files, what is the best way to figure out the list of files which reference it? I'm looking to build up the dependency tree for that file. Said another way, if I change a given XML file, how can I calculate the list of other XML files which will be effected?
Asked
Active
Viewed 295 times
2 Answers
4
In the SVN repository of the DocBook SourceForge project, there is an xmldepend.xsl stylesheet module. Perhaps it is what you are looking for:
http://docbook.svn.sourceforge.net/viewvc/docbook/trunk/contrib/xsl/xmldepend/xmldepend.xsl

mzjn
- 48,958
- 13
- 128
- 248
-
I think that provides the opposite of what the OP is after. – Nic Gibson Jan 04 '11 at 12:51
-
Thanks mzjn for the tip. Nic is right, but I think I can make this work in this direction. – Matthew Simoneau Feb 22 '11 at 23:53
-
I've tried this out and it does successfully list all the graphics an similar files, but not the included XML files themselves. I think this is because these includes are resolved upstream by org.apache.xml.resolver.tools.CatalogResolver. Any ideas how I can get this additional info? – Matthew Simoneau Feb 23 '11 at 00:00
2
Given the one way relationships defined by XInclude, there isn't any direct XML based way to do this.
Honestly, I would probably do a file search using find
or grep
.
You could, given the top level DocBook file, use a variant on the stylesheet that @mzjn pointed you at to generate all the dependencies in the compound document and then extract those where a document depends on the file you are currently interested in.

Nic Gibson
- 7,051
- 4
- 31
- 40