Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-173

[configuration] Missing useful functionality of XPath in HierarchicalConfiguration

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      Hi,

      I find out that there is missing very usefull functionality for
      org.apache.commons.configuration.HierarchicalConfiguration.

      For instance, I have XML like below:

      <?xml version="1.0" encoding="UTF-8"?>
      <Configuration>
      <Service name="contract.funds" class="my.MyClass">
      <ServiceParameters>
      <Param key="generate.request" value="true" />
      <Param key="request.xml.name"
      value="LifeFunds_REQ.xml" />
      <Param key="transform.response" value="true" />
      <Param key="reply.xml.name"
      value="dummy/LifeFunds_REP.xml" />
      <Param key="digester-rules.xml"
      value="LifeFunds_rules.xml" />
      </ServiceParameters>
      </Service>

      <Service name="contract.servicing.agents" class="my.MyClass">
      <ServiceParameters>
      <Param key="generate.request" value="true" />
      <Param key="request.xml.name"
      value="LifeServicingAgents_REQ.xml" />
      <Param key="transform.response" value="true" />
      <Param key="reply.xml.name"
      value="dummy/LifeServicingAgents_REP.xml" />
      <Param key="digester-rules.xml"
      value="LifeServicingAgents_rules.xml" />
      </ServiceParameters>
      </Service>

      <Service name="contract.additional.info" class="my.MyClass">
      <ServiceParameters>
      <Param key="generate.request" value="true" />
      <Param key="request.xml.name"
      value="LifeAdditionalInfo_REQ.xml" />
      <Param key="transform.response" value="true" />
      <Param key="reply.xml.name"
      value="dummy/LifeAdditionalInfo_REP.xml" />
      <Param key="digester-rules.xml"
      value="LifeAdditionalInfo_rules.xml" />
      </ServiceParameters>
      </Service>
      </Configuration>

      From the application I would like to go directly to the configuration of
      service with name: "contract.funds" instead of reading whole hierarhi and check
      if the name is equals "contract.funds" I prefer to get its parameters like this:

      config.getProperty("Service[@name='contract.funds']").ServiceParameters.Param)

      instead of calling in a loop:

      for(int i=0;;i++){
      if(config.getProperty("Service("i")[@name]").equals("contract.funds"))

      { // DO SOMETHING }

      }

      So in a simple words - it would be very helpfull if there will be full
      supoorted the XML Path Language (XPath) during requesting properties.

      Best regards
      Rafal

        Activity

        Henri Yandell made changes -
        Affects Version/s 1.1 Final [ 12311695 ]
        Henri Yandell made changes -
        Component/s Configuration [ 12311107 ]
        Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
        Project Commons [ 12310458 ] Commons Configuration [ 12310467 ]
        Affects Version/s 1.1 Final [ 12311652 ]
        Key COM-2223 CONFIGURATION-173
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 35753 12342375
        Hide
        Oliver Heger added a comment -

        The user guide was updated to cover the new features. So marking this issue as
        fixed. If you encounter problems with the new classes, please file new
        (specific) bug reports.

        Thanks.

        Show
        Oliver Heger added a comment - The user guide was updated to cover the new features. So marking this issue as fixed. If you encounter problems with the new classes, please file new (specific) bug reports. Thanks.
        Hide
        Oliver Heger added a comment -

        A first implementation of an XPathExpressionEngine is now available in SVN. I
        will update the user guide accordingly soon. In short usage is as follows:

        HierarchicalConfiguration config = ...
        config.setExpressionEngine(new XPathExpressionEngine());
        // from now on XPATH expressions can be used when accessing properties
        String prop = config.getString("tables/table[1]");

        Feedback welcome!

        Show
        Oliver Heger added a comment - A first implementation of an XPathExpressionEngine is now available in SVN. I will update the user guide accordingly soon. In short usage is as follows: HierarchicalConfiguration config = ... config.setExpressionEngine(new XPathExpressionEngine()); // from now on XPATH expressions can be used when accessing properties String prop = config.getString("tables/table [1] "); Feedback welcome!
        Hide
        Oliver Heger added a comment -

        Okay, all preperations are almost done: hierarchical configuration classes now
        support pluggable expression engines, which interpret property keys.

        I am now going to implement an XPath expression engine based on Commons JXPath.
        So an experimental version should be available soon.

        Show
        Oliver Heger added a comment - Okay, all preperations are almost done: hierarchical configuration classes now support pluggable expression engines, which interpret property keys. I am now going to implement an XPath expression engine based on Commons JXPath. So an experimental version should be available soon.
        Hide
        Oliver Heger added a comment -

        I would really love to have such a feature in commons-configuration. XPath
        support is indeed very often requested.

        However I feel before we can start to implement this feature, it would be wise
        to do a little polishing of the HierarchicalConfiguration.Node class to create a
        clean and consistent interface (which must be backwards compatible).

        Show
        Oliver Heger added a comment - I would really love to have such a feature in commons-configuration. XPath support is indeed very often requested. However I feel before we can start to implement this feature, it would be wise to do a little polishing of the HierarchicalConfiguration.Node class to create a clean and consistent interface (which must be backwards compatible).
        Rafal Zablocki created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Rafal Zablocki
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development