You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
first thanks for the very fast response on issue #24! Everything s fine, just left a star.
But I found another problem while parsing a xsd with subdirectories: I attached a example zip to reproduce the problem. issue28_xsd.zip
Parsing the issue_28.xsd shows a
java.lang.NullPointerException
at org.xmlet.xsdparser.core.XsdParserCore.lambda$null$7(XsdParserCore.java:144)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485)
at org.xmlet.xsdparser.core.XsdParserCore.lambda$resolveOtherNamespaceRefs$8(XsdParserCore.java:123)
at java.util.HashMap$KeySet.forEach(HashMap.java:933)
using 1.0.33-SNAPSHOT.
The problem is the import of issue_28b.xsd from issue_28.xsd (with subdirectory issue_28) and from issue_28a.xsd (without subdirectory). If the schemaLocation is specified with an absolute file, it's working.
I looked in the source code and found
private Map<String, List<ReferenceBase>> parseElements = new HashMap<>();
private Map<String, List<UnsolvedReference>> unsolvedElements = new HashMap<>();
List<String> schemaLocations = new ArrayList<>();
Map<String, String> schemaLocationsMap = new HashMap<>();
protected String currentFile;
After debugging I saw, thew the keys in schemaLocations sometimes have the directory in it, sometimes not. So I'd suggest using URI instead:
private Map<URL, List<ReferenceBase>> parseElements = new HashMap<>();
private Map<URL, List<UnsolvedReference>> unsolvedElements = new HashMap<>();
List<URL> schemaLocations = new ArrayList<>();
protected URL currentFile;
because the URLs are normalized. (The schemaLocationsMap not necessary an more). Instead of string manipulation to create a new filename, using url = new URL(currentFile, importedFileName);
is easier.
If I can help you with more explanations or java code, please let me know.
The text was updated successfully, but these errors were encountered:
Thanks for the star! Also sorry for taking so long this time around.
I probably need to improve the way I work with files, but for now I solved your issue with a temporary solution. I tested with your use case and it didn't give me any errors parsing. A new release is available, (1.1.0), with the fix.
I'll try to improve XsdParser with your suggestion once I have some more free time. Or if you are up to it you can create a pull request with your solution and I'll give it a look. Either way, thanks for the feedback!
Hello,
first thanks for the very fast response on issue #24! Everything s fine, just left a star.
But I found another problem while parsing a xsd with subdirectories: I attached a example zip to reproduce the problem.
issue28_xsd.zip
Parsing the issue_28.xsd shows a
using 1.0.33-SNAPSHOT.
The problem is the import of issue_28b.xsd from issue_28.xsd (with subdirectory issue_28) and from issue_28a.xsd (without subdirectory). If the schemaLocation is specified with an absolute file, it's working.
I looked in the source code and found
After debugging I saw, thew the keys in schemaLocations sometimes have the directory in it, sometimes not. So I'd suggest using URI instead:
because the URLs are normalized. (The schemaLocationsMap not necessary an more). Instead of string manipulation to create a new filename, using
url = new URL(currentFile, importedFileName);
is easier.
If I can help you with more explanations or java code, please let me know.
The text was updated successfully, but these errors were encountered: