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 and comons-jxpath
Date Wed, 13 Dec 2006 20:57:38 GMT
Hi,

my knowledge about extension functions for jxpath is somewhat limited. 
As far as I understand the topic you have to register a class with the 
functions at the JXPathContext object. Is this correct?

If this is true, you can easily extend XPathExpressionEngine to register 
your extension functions: Just derive your own engine class from 
XPathExpressionEngine and override the createContext() method. Here you 
can call the super method and obtain the context object. Then you can 
perform additional initializations, e.g. registering functions.

Is this what you are after?
Oliver

MASTRELLA STEFANO wrote:
> Hi all,
> 
> I'm using commons-configuration with the XPathExpressionEngine installed
> on a CompositeConfiguration based on an XMLConfiguration and a
> PropertiesConfiguration.
> I'd like to use some user defined xpath function, via implementation of
> org.apache.commons.jxpath.Functions and
> org.apache.commons.jxpath.Function, but doing this I need to wrap most
> of the feature the Configuration implementation give to me.
> I try to explain with an example.
> 
> This is the xml part of the configuration file
> 
> **********
> config.xml
> **********
> <conf>
>    <big-integer>
>      <direct-link value="99887766"/>
>      <indirect-link
> value="resolver-ns:resolve-value(/conf/link[@name='big-integer-link']/va
> lue/@val)"/>
>      <interpolated-indirect-link
> value="resolver-ns:resolve-value(/conf/link[@name='big-integer-link']/in
> terpolated/@value)"/>
>      <double-indirect-link
> value="resolver-ns:resolve-value(/conf/link[@name='big-integer-link']/in
> direct-link/@value)"/>
>      <interpolate-link value="${big-integer.value}"/>
>    </big-integer>
> 
>    <link name="big-integer-link">
>      <interpolated value="${big-integer.value}"/>
>      <value val="1122334455"/>
>      <indirect-link
> value="resolver-ns:resolve-value(/conf/double-link[@name='big-integer-do
> uble-link']/value/@val)"/>
>    </link>
> </conf>
> 
> And this is the part for the properties file
> 
> *****************
> config.properties
> *****************
> 
> big-integer.value=9021784365
> 
> both of them are loaded within a CompositeConfiguration configured as
> 
> *****************
> composite.xml
> *****************
> 
> <configuration>
>   <properties fileName="config.properties"/>
>   <xml fileName="config.xml"/>
> </configuration>
> 
> As you can see in the xml file there's a user defined xpath function
> resolve-value, which is able to resolve an xpath expression and return
> the value addressed.
> To do this I need to extrapolate a JXPathContext from the Document of
> the XMLConfiguration, but this mean to browse it without some feature
> such as variable interpolation.
> As a consequence I need to reimplement those sort of feature.
> 
> So the question is, is it possible to install user defined functions in
> addition to an XPathExpressionEngine?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message