本文介绍了从DOxygen XML输出中提取函数调用列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在DOxygen论坛上也发布了

I posted a question on the DOxygen forums and also am posting it here for a better response.

我有一个中等大小的C项目,包含大约2,900个函数。我正在使用DOxygen 1.5.9,并且它已成功生成函数的调用图。有没有办法将其提取出来以进行进一步分析?一个简单的配对列表就足够了,例如

I have a moderately sized C project of about 2,900 functions. I am using DOxygen 1.5.9 and it is successfully generating a call graph for the functions. Is there a way to extract this out for further analysis? A simple paired list would be sufficient, e.g.

Caller,Callee
FunctionX, FunctionY
...

我对XSLT感到满意,但我必须说DOxygen XML输出很复杂。以前有没有做过这件事,并且可以提供有关如何解析XML文件的指导?

I am comfortable with XSLT but I must say that the DOxygen XML output is complex. Has anyone done this before and can provide some guidance on how to parse the XML files?

预先感谢!

推荐答案

根据我在创建的人为示例中看到的内容,

Based on what I see in the contrived example that I created,


  • 使用如果我的regex-foo是正确的,则类似于 ^ _(。+)\d +(c | cpp | h | hpp)\.xml $ 的名称。 / li>
  • 查找所有< memberdef kind = function> 。它具有唯一的 id 属性。我相信XPath是 // memberdef [@ kind ='function']

  • 在该元素中,找到所有< references>

  • 对于每个标签, refid 属性$ b唯一地引用所调用的相应< memberdef> id 属性。

  • 每个< references> 中的文本节点对应于对应的< name> < memberdef> 被调用。

  • Parse files with a name similar to ^_(.+)\d+(c|cpp|h|hpp)\.xml$, if my regex-foo is right.
  • Find all <memberdef kind="function">. It has a unique id attribute. I believe the XPath for this is //memberdef[@kind='function'].
  • Within that element, find all <references>.
  • For each of those tags, the refid attribute uniquely refers to the id attribute of the corresponding <memberdef> that is being called.
  • The text node within each <references> corresponds to the <name> of the corresponding <memberdef> that is being called.

这似乎是一个不错的选择,是表示调用图的直接方法。使用XSLT或任何其他理智的XML解析套件,您都可以轻松获得所需的结果。

This seems like a nice, straightforward way to express call graphs. You should have no trouble using XSLT or any other sane XML-parsing suite to get the desired results.

这篇关于从DOxygen XML输出中提取函数调用列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 03:44