简体   繁体   中英

Can I use XInclude with Java 1.5 XML Properties?

Since JDK 1.5 Properties can be loaded from a 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM