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

Xml merger ID fallback not working #621

Closed
hohwille opened this issue Sep 17, 2024 · 0 comments · Fixed by #622
Closed

Xml merger ID fallback not working #621

hohwille opened this issue Sep 17, 2024 · 0 comments · Fixed by #622
Labels
bug Something isn't working configuration should be configurable or configuration change workspace

Comments

@hohwille
Copy link
Member

Expected behavior

See #43, #403 etc. We specified the ID fallback as following:
https://github.com/devonfw/IDEasy/blob/main/documentation/configurator.adoc#element-identification

Actual behavior

The implementation is wrong and never tested:

if (id.isEmpty()) {
// handle case where element has no attribute
if (sourceElement.getElementAttributes().isEmpty()) {
// use name as id
id = sourceElement.getElement().getLocalName();
} else {
// look for id or name attributes
String idAttr = sourceElement.getElement().getAttribute("id");
if (idAttr.isEmpty()) {
idAttr = sourceElement.getElement().getAttribute("name");
if (idAttr.isEmpty()) {
throw new IllegalStateException(
"No merge:id value defined for element " + sourceElement.getXPath() + " in document " + sourceElement.getDocumentPath());
}
}
}

While it tries to handle the cases it does not actually initialize a fallback at all and IMHO the only fallback for the name is incorrect.

Steps to reproduce (bug) / Use Case of feature request (enhancement)

  1. write a XML template and omit merge:id attributes for elements that have name or id attribute
  2. run the XML merger on that

Related/Dependent Issues

#403

Comments/Hints:

As stated above the fallback needs to be name(), @id or @name according to the attribute presence.

Affected version:

  • latest 2024.09.002-beta-SNAPSHOT
@hohwille hohwille added the bug Something isn't working label Sep 17, 2024
@hohwille hohwille added this to the release:2024.09.002 milestone Sep 17, 2024
@hohwille hohwille added workspace configuration should be configurable or configuration change labels Sep 17, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in IDEasy board Sep 17, 2024
hohwille added a commit to hohwille/IDEasy that referenced this issue Sep 17, 2024
hohwille added a commit to hohwille/IDEasy that referenced this issue Sep 17, 2024
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in IDEasy board Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working configuration should be configurable or configuration change workspace
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant