Oliver,
Here is my code fragment:
try {
XMLConfiguration config = new XMLConfiguration();
String base = System.getProperty("user.dir");
config.setBasePath(base);
config.setFileName("DirectorWithSingleAssistant.xml");
config.load();
//
.....
...
}
catch (Exception e) {
fail(e.toString());
}
And my XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Config SYSTEM "../../../yyyy.dtd">
Sorry to bother you, but another problem has come up also:
While to parsing the file, it doesn't seem to recognize structured
properties as advertised in the 'XML - How to'. For example, with XML:
<Families>
<Family name="ES">
<X a="a" b="b"/>
</Family>
<Family name="B">
<X a="a" b="b"/>
</Family>
</Families>
When I iterate:
for (Iterator iter = config.getKeys(); iter.hasNext();) {
String key = (String) iter.next();
String value = config.getString(key);
System.out.println(key + " = " + value);
}
I get:
[EMAIL PROTECTED] = ES
[EMAIL PROTECTED] = a
[EMAIL PROTECTED] = b
And I am unable to access, as I'd hoped, via:
Families.Family(0)[EMAIL PROTECTED], etc...
Anything obvious?
Many thanks for your help.
Bill
-----Original Message-----
From: Oliver Heger [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 20, 2005 7:44 AM
To: Jakarta Commons Users List
Subject: Re: XMLConfiguration load problem - External Entity not found
William Evans wrote:
>I am using 'commons-configuration-1.2.jar' to make it easier to read
XML
>configuration files.
>
>
>
>The files are not terribly complex but do have associated DTDs. Ideally
>I would like to specify the DTD location using a local, relative path.
>The problem is that when I try and load the file, I get:
>
>
>
>Relative URI "../../../yyyy.dtd"; can not be resolved without a base
>URI.
>
>
>
>So, after reading about a similar problem with solution posted by
>Oliver, I tried specifying the full path. Now I get:
>
>
>
>External entity not found:
>"file://C:/eclipse/workspace/xxxx/dtds/yyyyy.dtd".
>
>
>
>Or...
>
>
>
>External entity not found: "C:/eclipse/workspace/xxxx/dtds/yyyyy.dtd".
>
>
>
>What is up here? Is the use of DTDs not really supported? In the
article
>I found, Oliver said that he had fixed the relative path problem. Is
>there some other issue going on?
>
>
>
>Any help much appreciated...
>
>
>
>Bill
>
>
>
Could you please provide a code fragment how you setup and load your
XMLConfiguration instance? And full stack traces of exceptions might be
useful, too.
The mentioned fix should be in 1.2. There is a unit test that tests
loading a document that refers to a local DTD. But maybe not all
posibilities are covered?
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]