これら 2 つの要素内のテキストをpom.xml
、ディレクトリ ツリー内の多数の要素に一覧表示する必要があります。ファイルには他の場所にも要素が含まれている可能性があります。私はこれら2つのコンテンツのみを探しています。
<file-name>:<line-no>:<path>:<text>
理想的には、形式で出力するツールを探しています。
parent/pom.xml:12:/project/groupId:com.acme.project
features/persist/pom.xml:14:/project/parent/groupId:com.acme.project
features/persist/pom.xml:32:/project/groupId:com.acme.project.persist
次の入力ファイルの場合:
**parent/pom/xml**
<project>
...
<groupId>
com.acme.project <!--LINE 12 -->
</groupId>
...
</project>
**feature/persist/pom.xml**
<project>
<parent>
<groupId>
com.acme.project <!--LINE 14 -->
</groupId>
</parent>
...
<groupId>
com.acme.project
</groupId>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
a.b.c.d <!-- this is not listed in output -->
</groupId>
</dependency>
</dependencies>
</dependencyManagement>
</project>
などの他のパスdependencyManagement/dependencies/dependency/groupId
は含まれないことに注意してください。
ここで検索すると、xmlstarlet に遭遇xmllint --xpath
しましたが、xpath について自分で理解するのに十分な知識がありません。