You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Christoph Jaeger <ch...@inode.at> on 2005/08/17 13:20:10 UTC

[configuration] Support for XPath like queries?

Hi,

I was reading the documentation about XMLConfiguration on
http://jakarta.apache.org/commons/configuration/howto_xml.html
and now I wonder how it would be possible to get a list of all the
fields of a table with a given tableType. The XML structure describe in
the example looks like:


<tables>
  <table tableType="system">
    <fields>
      <field>...</field>
      <field>...</field>
      <field>...</field>
...
    </fields>
  </table>
  <table tableType="application">
    <fields>
      <field>...</field>
      <field>...</field>
      <field>...</field>
...
    </fields>
  </table>
</tables>

Now you can query a list of fields of the first table using a property
name of "tables.table(0).fields.field".

But how would you query a list of fields for the table with tableType
"system"? One way could be to loop over all "tables.table[@tableType]"
elements, remember the index of the table containing the given tableType
and use the syntax described above to get the list of fields.

I think it would be a lot easier (to write, and also to read the code
afterwards), if one could just write:
"tables.table[@tableType='system'].fields.field"

Is a syntax like this supported by Commons Configuration? I think a read
about something like this, but can not seem to remember where.

Best Regards,

Christoph Jäger

Does the commons-configuration XMLConfiguration class support XPath


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


Re: [configuration] Support for XPath like queries?

Posted by Oliver Heger <he...@med.uni-marburg.de>.
Christoph Jaeger schrieb:
> Hi,
> 
> I was reading the documentation about XMLConfiguration on
> http://jakarta.apache.org/commons/configuration/howto_xml.html
> and now I wonder how it would be possible to get a list of all the
> fields of a table with a given tableType. The XML structure describe in
> the example looks like:
> 
> 
> <tables>
>   <table tableType="system">
>     <fields>
>       <field>...</field>
>       <field>...</field>
>       <field>...</field>
> ...
>     </fields>
>   </table>
>   <table tableType="application">
>     <fields>
>       <field>...</field>
>       <field>...</field>
>       <field>...</field>
> ...
>     </fields>
>   </table>
> </tables>
> 
> Now you can query a list of fields of the first table using a property
> name of "tables.table(0).fields.field".
> 
> But how would you query a list of fields for the table with tableType
> "system"? One way could be to loop over all "tables.table[@tableType]"
> elements, remember the index of the table containing the given tableType
> and use the syntax described above to get the list of fields.
> 
> I think it would be a lot easier (to write, and also to read the code
> afterwards), if one could just write:
> "tables.table[@tableType='system'].fields.field"
> 
> Is a syntax like this supported by Commons Configuration? I think a read
> about something like this, but can not seem to remember where.
> 
> Best Regards,
> 
> Christoph Jäger
> 
> Does the commons-configuration XMLConfiguration class support XPath
> 

Hi Christoph,

XPath syntax is not yet supported. There is an enhancement request for 
this in bugzilla:

http://issues.apache.org/bugzilla/show_bug.cgi?id=35753

I cannot estimate when we come to implement this, but I am myself very 
interested in this topic.

Oliver

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