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

There are unsolved References in schema #62

Closed
darthweiter opened this issue Mar 1, 2024 · 2 comments
Closed

There are unsolved References in schema #62

darthweiter opened this issue Mar 1, 2024 · 2 comments

Comments

@darthweiter
Copy link
Contributor

Describe the bug
If i navigate in the schema, i found unsolved references or not complete resolved types, but the method getUnsolvedReferences() shows no entry.

Expected behavior
There are no unsolved references

Library Version
1.2.8

Additional context

I found some different problems, it happend with the latest merges where you adjust some of the pr and not merged all stuff.

  1. Problem: XsdAttribute are not supporting XsdBuiltInTypes -> solution: in class XsdAttribute add in constructor: if(XsdParserCore.getXsdTypesToJava().containsKey(type)) { HashMap<String, String> attributes = new HashMap<>(); attributes.put(NAME_TAG, type); this.simpleType = ReferenceBase.createFromXsd(new XsdBuiltInDataType(parser, attributes, this)); }

  2. Problem: XsdAttributeGroup can't resolve attributes -> solution: in class XsdAttributeGroup add in method replaceUnsolvedElements:
    if(element.getElement() instanceof XsdAttribute) { for(int i = 0; i < attributes.size(); i++) { ReferenceBase attributesUnsolvedReference = attributes.get(i); if(attributesUnsolvedReference instanceof UnsolvedReference && (((UnsolvedReference) attributesUnsolvedReference).getRef().substring(((UnsolvedReference) attributesUnsolvedReference).getRef().indexOf(":") + 1).equals(element.getName()))) { attributes.set(i, element); break; } } }

  3. Problem XsdUnion doesn't resolve correct memberTypes: solution -> in class XsdParserCore method resolveMemberTypes:
    move XsdSchema schema = union.getXsdSchema(); back into the for loop. Otherwise you will override the schema if you use a import schema and then use the original one. If it's to expensive to calculate the original schema on each memberType you can use a temp variable inside the for loop to not override the original schema.

  4. Problem schemas with imports, which includes other schemas are not supported at all: Solution: -> you need to include all transitive dependencies in the imports as well so in code XsdParserCore method resolveOtherNamespaceRefs you need the method findTransitiveDependencies and fill your relevantElements with this elements as well.

  5. I get some unsolved references, when i resolve memberTypes in union with transitiv includes, why do we need a the clone in the getElementFromSchema() method? This can produce unsolved references too, if you remove this all works fine.

testdata.zip

Attach the XSD file or a similar example that you are trying to parse.

@lcduarte
Copy link
Member

lcduarte commented Mar 2, 2024

Hello,

I've released a new version 1.2.9. It contains the suggestions for your first three points.

Regarding 4: I've added a test base on your description and your test files, it might be fixed with the changes in this new version because I didn't get the behavior you've described.

Regarding 5: The cloned elements had an issue where they were both adding UnsolvedReferences in the elementCopy constructor call and then again in the clone method, hence the loose UnsolvedReferences at the end of the parsing, even though all elements have the references solved. This version also solves the cases I've could identity where that happens.

Please check the new version and if the issues persist let me know.

@lcduarte lcduarte closed this as completed Mar 2, 2024
@darthweiter
Copy link
Contributor Author

i tested the new version and it looks good thanks :)

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