commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: Commons Configuration XPath engine
Date Fri, 19 Feb 2010 21:17:56 GMT
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


Mime
View raw message