使用 XIncludes 解开一组 XML 文件的依赖关系树
我有一组 XML 文件(具体来说是 DocBook)。它们使用 XML 包含(也称为 XInclude)来相互引用。给定这些 XML 文件之一,找出引用它的文件列表的最佳方法是什么?我正在寻找为该文件建立依赖关系树。换句话说,如果我更改给定的 XML 文件,如何计算将受到影响的其他 XML 文件的列表?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在DocBook SourceForge 项目的SVN 存储库中,有一个xmldepend.xsl 样式表模块。也许这就是您正在寻找的:
http: //docbook.svn.sourceforge.net/viewvc/docbook/trunk/contrib/xsl/xmldepend/xmldepend.xsl
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
由于 XInclude 定义了单向关系,因此没有任何直接的基于 XML 的方法来执行此操作。
老实说,我可能会使用
find
或grep
进行文件搜索。在给定顶级 DocBook 文件的情况下,您可以使用 @mzjn 指出的样式表上的变体来生成复合文档中的所有依赖项,然后提取文档依赖于您当前感兴趣的文件的依赖项。
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
orgrep
.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.