You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Lorenzo Cavina <lc...@noemalife.com> on 2010/02/19 10:56:01 UTC
Commons Configuration XPath engine
Hi all,
i'm using the Commons Configuration library to manage XML
configurations. I'm trying to manage this configuration using the
built-in XPath expression engine based on Commons JXPath.
My XML configuration document looks like following:
<?xml version="1.0" encoding="utf-8"?>
<cfg:configuration
xmlns:cfg="http://www.noemalife.com/configuration/xml/main"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.noemalife.com/configuration/xml/main
configuration.xsd">
<cfg:entry name="background">blue</cfg:entry>
<cfg:entry name="showmenu" mode="free">yes</cfg:entry>
<cfg:entry name="showstatusbar">yes</cfg:entry>
</cfg:configuration>
Now the problem is that i really don't know how to manage the cfg
namespace.
That is:
- if i execute
configuration.getProperty("cfg:entry[@name='background']"); it doesn't
work at all, returning NULL (i also tryed with
configuration.getProperty("/cfg:entry[@name='background']") or
configuration.getProperty("/cfg:configuration/cfg:entry[@name='background']").....same
result!)
- if i REMOVE the namespace declarations from the configuration root
element and i execute
configuration.getProperty("entry[@name='background']"); i get the right
result. But i need the namespace declaration.
Does anybody knows how to manage namespaces?
Thank you very much.
Lorenzo
--
Ing. Lorenzo Cavina
Analyst \ Emr Development
NoemaLife S.p.A
Via Gobetti, 52
40129 Bologna - ITALY
T +39 051 70.98.247
F +39 051 70.98.200
lcavina@noemalife.com
www.noemalife.com
Re: Commons Configuration XPath engine
Posted by Oliver Heger <ol...@oliver-heger.de>.
Am 19.02.2010 10:56, schrieb Lorenzo Cavina:
> Hi all,
> i'm using the Commons Configuration library to manage XML
> configurations. I'm trying to manage this configuration using the
> built-in XPath expression engine based on Commons JXPath.
> My XML configuration document looks like following:
>
> <?xml version="1.0" encoding="utf-8"?>
> <cfg:configuration
> xmlns:cfg="http://www.noemalife.com/configuration/xml/main"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.noemalife.com/configuration/xml/main
> configuration.xsd">
>
> <cfg:entry name="background">blue</cfg:entry>
> <cfg:entry name="showmenu" mode="free">yes</cfg:entry>
> <cfg:entry name="showstatusbar">yes</cfg:entry>
>
> </cfg:configuration>
>
> Now the problem is that i really don't know how to manage the cfg
> namespace.
> That is:
> - if i execute
> configuration.getProperty("cfg:entry[@name='background']"); it doesn't
> work at all, returning NULL (i also tryed with
> configuration.getProperty("/cfg:entry[@name='background']") or
> configuration.getProperty("/cfg:configuration/cfg:entry[@name='background']").....same
> result!)
> - if i REMOVE the namespace declarations from the configuration root
> element and i execute
> configuration.getProperty("entry[@name='background']"); i get the right
> result. But i need the namespace declaration.
>
> Does anybody knows how to manage namespaces?
>
> Thank you very much.
>
> Lorenzo
>
I am not sure, but I think it is possible that namespace prefixes are
simply dropped. Can you check which keys your configuration contains?
For instance, obtain the iterator returned by getKeys() and print its
elements.
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org