commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Jaeger <christoph.jae...@inode.at>
Subject [configuration] Support for XPath like queries?
Date Wed, 17 Aug 2005 11:20:10 GMT
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


Mime
View raw message