Java 和 XML:如何获取包含文件的列表
我对 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
扩展
DefaultHandler
和
@Overwrite
的resolveEntity
方法。您的实现将简单地打印或记录 publicId/systemId 并返回 null,因此 SAXParser 将使用默认行为来解析实体。使用
SAXParser
构造函数传递您的DefaultHandler
子类。Extend
DefaultHandler
and@Overwrite
theresolveEntity
method. Your implementation will simply print or log the publicId/systemId and returnnull
, so theSAXParser
will use the default behaviour to resolve the entities.Pass your
DefaultHandler
subclass with theSAXParser
constructor.