Java 和 XML:如何获取包含文件的列表

发布于 2024-11-19 12:57:44 字数 616 浏览 5 评论 0原文

我对 Xinclude 或作为实体包含的文件有疑问。我需要知道解析器已包含哪些文件。例子:

<?xml version="1.0" ?>
<!DOCTYPE docBookChapter [
    <!ENTITY externalFile SYSTEM "entityIncluded.xml">
]>
<chapter xmlns="http://www.w3.org/1999/xhtml"
xmlns:xi="http://www.w3.org/2001/XInclude">
    <title>Third chapter</title>
    <xi:include href="xIncluded.xml"/>
    <chapter>
        &externalFile;</chapter>
</chapter>
The parser creates DOM successfully, but how to get names of files included? The element xi:include is already replaced with content of file.

I have problem with by Xinclude or as an entity included files. I need to know, which files have been included by parser. Example:

<?xml version="1.0" ?>
<!DOCTYPE docBookChapter [
    <!ENTITY externalFile SYSTEM "entityIncluded.xml">
]>
<chapter xmlns="http://www.w3.org/1999/xhtml"
xmlns:xi="http://www.w3.org/2001/XInclude">
    <title>Third chapter</title>
    <xi:include href="xIncluded.xml"/>
    <chapter>
        &externalFile;</chapter>
</chapter>

The parser creates DOM successfully, but how to get names of files included? The element xi:include is already replaced with content of file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

避讳 2024-11-26 12:57:44

扩展 DefaultHandler@OverwriteresolveEntity 方法。您的实现将简单地打印或记录 publicId/systemId 并返回 null,因此 SAXParser 将使用默认行为来解析实体。

使用 SAXParser 构造函数传递您的 DefaultHandler 子类。

Extend DefaultHandler and @Overwrite the resolveEntity method. Your implementation will simply print or log the publicId/systemId and return null, so the SAXParser will use the default behaviour to resolve the entities.

Pass your DefaultHandler subclass with the SAXParser constructor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文