问题标签 [dom4j]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
2173 浏览

java - 如何使用 Dom4j 测试元素的 CDATA 值?

有谁知道如何找出一个元素是否包含<![CDATA[ text ]]>?我搜索了 dom4j API 和 Jaxen,但我找不到如何做到这一点……如果我检索文本,它的 cdata 包装器会被修剪。

0 投票
2 回答
697 浏览

java - XSL 的后处理步骤


我目前正在开发一个使用 XSL 转换从 XML 生成 HTML 的项目。在输入字段上,我必须设置一些属性。
样本:

这很愚蠢,因为我必须编写相同的 XPath 3 次......我的想法是为 xsl 文件配备某种后处理器,这样我就可以编写:

我正在使用类似的东西来转换我的xml

我希望我可以从 Document 对象中创建一个 Transformer 对象。但它似乎必须是文件路径 - 至少我找不到直接使用 Document 的方法。
任何人都知道实现我想要的方法吗?

谢谢

0 投票
4 回答
13029 浏览

java - 如何在java中使用Dom4j获取XML的节点内容

我有一个 XML 文件,例如:

我已经导航到 node description,我想阅读完整的内容,包括<text>等等。

我使用了getText(),但它返回了空字符串。
我用过getStringValue(),但它过滤了所有<text>.
我用过asXML(),结果很接近,但结果包含<description>我不想要的。

有没有一种方法可以获取元素的 XML 内容?

0 投票
1 回答
1060 浏览

java - DOM4J 文档:读取 ISO-8859-1 xml

我需要读取以 ISO-8859-1 编码的 xml 文件。

我正在使用:

我收到一个"cannot find symbol"错误setXMLEncoding。这似乎应该是一件简单的事情,但我无法弄清楚我做错了什么。

0 投票
1 回答
791 浏览

xml - SQL Server 2008:从 ResultSet 中检索 XML 列值并将其存储在 Document 中

我想检索具有xml数据类型的列的值。我研究了检索的查询方法,但不太确定是否可以使用它来检索无类型的 xml 值。对于从结果集中检索 xml 列值也一无所知。检索后,我想将其存储在 a 中以Document供解析。

我想检索列值ETMADD 将包含在此列中的 xml 如下所示:

0 投票
3 回答
3947 浏览

java - 如何离线使用 dom4j SAXReader?

我想离线使用 SAXReader ,问题是 SAXReader 正在根据 DTD 验证 xml。我不想更改 DTD 或 XML 中的任何其他内容。通过在本网站和其他来源上进行搜索,我发现了 2 个对我没有帮助的答案:

  1. 使用EntityResolver绕过网络调用
  2. 使用 setIncludeExternalDTDDeclarations(false)

我尝试做的示例:


我仍然无法离线工作,请建议...谢谢

堆栈跟踪:

0 投票
2 回答
14641 浏览

java - 从给定节点中提取子节点数据

我想使用 DOM4j 在 Java 中解析 xml 文件。

我以这个 XML 为例:

给定请求(第一个节点)节点,如何提取子节点数据?

例如获取<response>状态码或<headerParameter>名称属性?

0 投票
1 回答
1769 浏览

java - dom 解析器中的 java.lang.StackOverflowError

以下是我的应用程序中的许多线程将访问的方法。

成功执行某个线程后,它会给出以下错误。

以下是成功执行线程的上定义方法的结果

0 投票
2 回答
9965 浏览

java - java.lang.NoClassDefFoundError: org/dom4j/Document

我有一个名为 XMLtoXML.java 的类,这是它的方法之一......

最后一行代码块使用 dom4j Document。我的类路径中有 dom4j-full.jar。如果我将此类作为独立类运行(在 Eclipse 中作为 Java 应用程序运行),那么它可以正常工作。当我在我的类路径中添加这个类作为 web appllication 和 dom4j-full.jar 的一部分时。
我得到了以下异常。

我也确信 dom4j jar 存在于类路径中。有人对问题有任何想法吗?

0 投票
1 回答
493 浏览

hibernate - Does the Hibernate Query Cache work in Dom4J mode

Background: Our project team is using Hibernate's dom4j entity mode to generate SOAP responses for a multiple client applications. The amount of data being delivered is massive and response time is an issue. We can significantly reduce the number of SQL calls by using the Hibernate Query Cache and/or the 2nd Level Cache. Due to the architecture of our system, the 1st Level Cache (Session) level mechanism will not improve performance in the way that Query Cacheing at the SessionFactory works.

Question: The underlying question is whether Hibernate's DOM4J Entity mode is compatible with Query cacheing. Query results are being put into the Query Cache. However, when a query.list() method executes and a matching cached query is found, then the following exception is thrown:

Caused by:

Our environment is Core-Spring/Hibernate...

In our spring-hibernate session factory configuration, the following configuration is used:

Initial Analysis: My gut feeling is that Hibernate's "experimental" DOM4J entity mode is not compatible with the Query and Entity Cache. It is also important to note that our Hibernate hbm.xml mapping files using dynamic mapping. That is, the mapping files do not have Class references; instead they have entity references. Thus, the XML responses get generated directly without populating a class's objects.

I would be tremendously grateful for any assistance in this matter.