Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select collection item by element value #62

Open
kwin opened this issue Oct 3, 2022 · 2 comments
Open

Select collection item by element value #62

kwin opened this issue Oct 3, 2022 · 2 comments

Comments

@kwin
Copy link
Contributor

kwin commented Oct 3, 2022

For arrays one is often interested in referencing a particular item. Current referencing is only supported by index, but often the index is unknown. In that case it would be beneficial to reference an item by selecting the first one having a particular element value for example with an XPath like syntax:

${settings.servers[id='apache'].passphrase}

@michael-o
Copy link
Member

michael-o commented Oct 3, 2022

The statement is incomplete. Curly missing and with XPath the value must be in single quotes.

@kwin
Copy link
Contributor Author

kwin commented Oct 3, 2022

@michael-o Thanks, fixed above.

The current logic for collections is in

interpolationTargets.add( new InterpolationTarget( value, basePath + "[" + i + "]" ) );
which just adds a target there with the index qualifier, i.e. the lookup does not actually interpret the index but just retrieves the mapping with that name. Just adding more InterpolationTargets with path containing the XPath expression does not really scale, so this seems to require a major extension of this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants