我可以将XInclude与Java 1.5 XML属性一起使用吗?

时间:2010-04-29 10:22:24

标签: java xml properties xinclude

由于可以从简单的XML文件加载JDK 1.5属性(参见IBM article)。是否可以在其中一个XML属性文件中使用XInclude来组合多个文件?

1 个答案:

答案 0 :(得分:0)

据我所知,java.util.Properties使用DOM来解析xml属性文件,而DOM确实支持XInclude。但它默认关闭了。也许你可以指定一个系统属性来打开它(但我不知道)。

另一种可能性是尝试使用DTD:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties [
    <!ENTITY include1 SYSTEM "./include1.xml">
    <!ENTITY include2 SYSTEM "http://foobar.com/include2.xml">
]>

<properties>
    <entry key="foo">bar</entry>
    <entry key="fu">baz</entry>
    &include1;
    &include2;
</properties>

这应该有用。