如何解决 XPATH 的错误 java.lang.RuntimeException?添加了 MAVEN 依赖项

How to solve error java.lang.RuntimeException for XPATH ? MAVEN dependencies added

我收到以下错误

 java.lang.RuntimeException:  Trying XBeans path engine... Trying XQRL... Trying XDK... Trying delegated path engine... FAILED on data(//v:shape[contains(@id,'PowerPlusWaterMarkObject')]/v:textpath/@string)

在执行以下代码时

private String getWaterMark(XWPFDocument document) {
   try {
        XWPFHeader defaultHeader = document.getHeaderFooterPolicy().getDefaultHeader();
        final String xpathFilter = "data(//v:shape[contains(@id,'PowerPlusWaterMarkObject')]/v:textpath/@string)";
        XmlObject[] xmlobjects = defaultHeader._getHdrFtr().selectPath(xpathFilter);
        return xmlobjects[0].toString();
   } catch (Exception ex) {
       logger.error("Error while getting Watermark content from document: ", ex);
   }
}

我在 pom.xml 文件中添加了以下依赖项。

        <!-- https://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans-xpath -->
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans-xpath</artifactId>
            <version>2.6.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/net.sf.saxon/Saxon-HE -->
        <dependency>
            <groupId>net.sf.saxon</groupId>
            <artifactId>Saxon-HE</artifactId>
            <version>10.6</version>
        </dependency>

我刚刚更换了我的 XPATH,它解决了我的问题

*//v:shape/v:textpath/@string