【问题标题】:Can I use XInclude with Java 1.5 XML Properties?我可以将 XInclude 与 Java 1.5 XML 属性一起使用吗?
【发布时间】:2010-04-29 10:22:24
【问题描述】:

从 JDK 1.5 开始,可以从简单的 XML 文件加载属性(请参阅IBM article)。是否可以在这些 XML 属性文件之一中使用XInclude 来组合多个文件?

【问题讨论】:

    标签: java xml properties xinclude


    【解决方案1】:

    据我所知,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>
    

    这应该可行。

    【讨论】:

      猜你喜欢
      • 2010-11-16
      • 2014-02-12
      • 1970-01-01
      • 2012-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多