You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Jon Smith <jo...@gmail.com> on 2011/02/10 19:49:34 UTC
[configuration] XInclude support in xml files
Hi,
I have searched through the archive as well as documentation but couldn't
find if Commons Configuration's XML format supports XInclude.
I know Digester has added this support but XMLConfiguration doesn't seem to
be using it or, at least, does not allow XInclude awareness to be set to
true.
I also tried giving my own XInclude and Namespace aware DocumentBuilder to
DefaultConfigurationBuilder but didn't seem to get XInclude to work.
Following is what I am trying to do:
configuration.xml snippet:
<additional>
<xml fileName="file1.xml"/>
</additional>
file1.xml snippet:
<!-- namespaces declared in header -->
<myconfig>
<config1 name="something"/>
<xi:include href="file2.xml" parse="text"/>
</myconfig>
Any pointers?
The intent is to not to let users touch configuration.xml but include more
files to the already included (e.g. file1.xml) file.
thanks
J
Re: [configuration] XInclude support in xml files
Posted by Jon Smith <jo...@gmail.com>.
Providing a DocumentBuilder to DefaultConfigurationBuilder works only for
the configuration definition file (configuration.xml in my example below)
but not for nested xml files (like file1.xml, in my example).
What I ended up doing so all xml files use my own DocumentBuilder is to
extend existing XMLConfigurationProvider and override
getEmptyConfiguration() method and use this class for "xml" tag handling.
This solution appears to be working.
Thanks.
Azfar
On Fri, Feb 11, 2011 at 12:12 PM, Oliver Heger <oliver.heger@oliver-heger.de
> wrote:
> Am 10.02.2011 19:49, schrieb Jon Smith:
>
> Hi,
>>
>> I have searched through the archive as well as documentation but couldn't
>> find if Commons Configuration's XML format supports XInclude.
>>
>> I know Digester has added this support but XMLConfiguration doesn't seem
>> to
>> be using it or, at least, does not allow XInclude awareness to be set to
>> true.
>>
>> I also tried giving my own XInclude and Namespace aware DocumentBuilder to
>> DefaultConfigurationBuilder but didn't seem to get XInclude to work.
>>
>> Following is what I am trying to do:
>>
>> configuration.xml snippet:
>>
>> <additional>
>> <xml fileName="file1.xml"/>
>> </additional>
>>
>> file1.xml snippet:
>>
>> <!-- namespaces declared in header -->
>> <myconfig>
>> <config1 name="something"/>
>> <xi:include href="file2.xml" parse="text"/>
>> </myconfig>
>>
>> Any pointers?
>>
>> The intent is to not to let users touch configuration.xml but include more
>> files to the already included (e.g. file1.xml) file.
>>
>> thanks
>>
>> J
>>
>> It is correct that there is no support for XInclude in XMLConfiguration -
> unfortunately. (Patches would be welcome ;-)
>
> If Digester supports XInclude, then it would probably be a good idea to
> align the code. XMLConfiguration does not use Digester for reading XML
> files, it does its own parsing.
>
> Can you elaborate a bit why it did not work to setup your own
> DocumentBuilder?
>
> Oliver
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
Re: [configuration] XInclude support in xml files
Posted by Oliver Heger <ol...@oliver-heger.de>.
Am 10.02.2011 19:49, schrieb Jon Smith:
> Hi,
>
> I have searched through the archive as well as documentation but couldn't
> find if Commons Configuration's XML format supports XInclude.
>
> I know Digester has added this support but XMLConfiguration doesn't seem to
> be using it or, at least, does not allow XInclude awareness to be set to
> true.
>
> I also tried giving my own XInclude and Namespace aware DocumentBuilder to
> DefaultConfigurationBuilder but didn't seem to get XInclude to work.
>
> Following is what I am trying to do:
>
> configuration.xml snippet:
>
> <additional>
> <xml fileName="file1.xml"/>
> </additional>
>
> file1.xml snippet:
>
> <!-- namespaces declared in header -->
> <myconfig>
> <config1 name="something"/>
> <xi:include href="file2.xml" parse="text"/>
> </myconfig>
>
> Any pointers?
>
> The intent is to not to let users touch configuration.xml but include more
> files to the already included (e.g. file1.xml) file.
>
> thanks
>
> J
>
It is correct that there is no support for XInclude in XMLConfiguration
- unfortunately. (Patches would be welcome ;-)
If Digester supports XInclude, then it would probably be a good idea to
align the code. XMLConfiguration does not use Digester for reading XML
files, it does its own parsing.
Can you elaborate a bit why it did not work to setup your own
DocumentBuilder?
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org