开发者

Can I use XInclude with Java 1.5 XML Properties?

开发者 https://www.devze.com 2022-12-28 09:20 出处:网络
Since JDK 1.5 Properties can be loaded from 开发者_StackOverflowa simple XML file (see IBM article). Is it possible to use XInclude in one of these XML properties files to compose multiple files?As fa

Since JDK 1.5 Properties can be loaded from 开发者_StackOverflowa simple XML file (see IBM article). Is it possible to use XInclude in one of these XML properties files to compose multiple files?


As far as I know, java.util.Properties uses DOM to parse xml properties files, and DOM does support XInclude. But it's turned off by default. Maybe you can specify a system property to turn it on (but I don't know).

Another possibility is to try with DTD inclusion:

<?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>

This should work.

0

精彩评论

暂无评论...
验证码 换一张
取 消