0

I generate EMMA reports during my build, they look like this

<report>
  <stats>
    <packages value="110"/>
    <classes value="1762"/>
    <methods value="12617"/>
    <srcfiles value="962"/>
    <srclines value="61320"/>
  </stats>
  <data>
    <all name="all classes">
      <coverage type="class, %" value="2%   (42/1762)"/>
      <coverage type="method, %" value="2%   (302/12617)"/>
      <coverage type="block, %" value="3%   (6849/258033)"/>
      <coverage type="line, %" value="3%   (1592.9/61320)"/>

I need to get the percentage from the value attributes of the /report/data/all/coverage nodes. Currently getting these:

Invalid XPath expression: "/report/data/all/coverage[starts-with(@type,'block')]@value": Unexpected '@'
Invalid XPath expression: "substring-before(/report/data/all/coverage[starts-with(@type,'block']@value,'%')": Expected: )
4

1 回答 1

2

您在@value属性之前缺少来自 XPath 的正斜杠。您的开头函数中还缺少一个括号

尝试以下

/report/data/all/coverage[starts-with(@type,'block')]/@value


substring-before(/report/data/all/coverage[starts-with(@type,'block')]/@value,'%')
于 2012-06-23T08:45:48.073 回答