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

References are not resolved from transitive dependencies (of more than one level) #58

Closed
SimonCockx opened this issue Feb 20, 2024 · 3 comments · Fixed by #59
Closed

Comments

@SimonCockx
Copy link
Contributor

SimonCockx commented Feb 20, 2024

Describe the bug
Suppose I have file A.xsd which includes B.xsd which includes C.xsd which includes D.xsd. If I have a reference to D.xsd in A.xsd, it will not be resolved by the parser.

This is because transitive dependencies are implemented incorrectly: they are not implemented in a recursive way and will only include "one level" of transitivity, e.g., C.xsd in my example will be included, but D.xsd will not.

See the XsdParserCore class:

Set<String> transitiveIncludes = new HashSet<>();

for(String includedFile : includedFiles){
    parseElements.keySet()
             .stream()
             .filter(fileNameAux -> fileNameAux.endsWith(includedFile))
             .findFirst()
             .ifPresent(fullIncludedFileName -> transitiveIncludes.addAll(parseElements.get(fullIncludedFileName)
                  .stream()
                  .filter(referenceBase -> referenceBase instanceof ConcreteElement && referenceBase.getElement() instanceof XsdInclude)
                  .map(referenceBase -> (((XsdInclude) referenceBase.getElement()).getSchemaLocation()))
                  .collect(Collectors.toList())));
}

Expected behavior
I expect transitive dependencies to work correctly, i.e., transitively.

Library Version
1.2.6

@darthweiter
Copy link
Contributor

darthweiter commented Feb 24, 2024

@SimonCockx This is a nice solution.
I found an other bug, the unsolved references are not solved correctly.
I used your solution for the transitve includes there and it works -> #61

lcduarte added a commit that referenced this issue Feb 24, 2024
@lcduarte
Copy link
Member

Thanks for the issue and the PR, it looks good! I've approved it, I'll review the one opened by @darthweiter since it appear to be related. I may deploy a new version with the suggested solutions today if everything works.

@lcduarte
Copy link
Member

I've released a new version, 1.2.8, with the code for this issue.

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

Successfully merging a pull request may close this issue.

3 participants