commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Spies, Brennan" <>
Subject RE: [Commons Configuration] XML Schema support, and other questions
Date Tue, 11 Dec 2007 21:18:35 GMT

Thanks for the reply.

Let me clarify the last point. Parsing the XML is not really the problem.
Using XPath syntax (with namespaces) is. If, for example, I have the
following XML:

<Application xmlns="urn:example">

Using an XPath expression to get the Owner's name in Commons Configuration as
specified in the docs (I assume) would give me an XPath string like


While this works without namespaces, in the example I've given above you'd
get nothing back. You'd have to convert it to something like


in order to retrieve that value.

Also, being able to bind a subtree to a Java object automatically is a huge
convenience that saves a lot of coding manually populating those properties.
In my case, I use JAXB to bind the subtree that starts with <Transport>, for

@XmlRootElement(name="Transport", namespace="urn:example")
public class Transport {
	@XmlElement(name="URL", namespace="urn:example")
	private URI providerURL;
	private String namingFactory;

I don't really see any evidence that Commons Configuration supports this,
though I wouldn't mind doing a little custom coding if CC did the heavy
lifting for me.


Brennan Spies

-----Original Message-----
From: Oliver Heger [] 
Sent: Tuesday, December 11, 2007 12:49 PM
To: Jakarta Commons Users List
Subject: Re: [Commons Configuration] XML Schema support, and other questions

Hi, comments inline...

Spies, Brennan wrote:
> Hi all,
> I am considering using Commons Configuration for my project, but am not
> if I would be able to do the type of configuration that I want.
> Some background: 
> I am writing a project that uses two sources of configuration, LDAP and XML
> (local). The LDAP properties represent "reserved" (user cannot override)
> "default" properties (user can override), while the local XML file
> (user-defined) represents all the user-controlled configuration
> properties-some have defaults in LDAP, some don't. The
> seems to support that, so far so good.
CompositeConfiguration and also DefaultConfigurationBuilder allow to 
define an order of configuration sources in which to search for 
properties. So if your configurations are correctly ordered, you can 
achieve the desired behavior.

> The XML file is defined by an XML Schema, and has namespaces associated
> it. Namespaces seems to muck with XPath expressions, as you have to use
> functions like 'local-name()' to correctly get the path. It looks like
> Commons Configuration only supports DTDs...:-(
That's right, so far only DTDs are supported.

> The other thing that I am doing is using a mix of properties (key = value)
> and actual beans which I am binding (on the XML end) using JAXB. 
Not sure if I understand this requirement correctly. You can parse a XML 
file with XMLConfiguration no matter of its content. If some parts of 
the document do not represent properties, they do not disturb the 
parsing process. As long as you specify the correct keys to your 
properties you can access them.


> So, can I achieve what I want using Commons Configuration and maybe a
> custom coding? Or should I write this one myself?
> Thanks,
> Brennan

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message