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

Error while parsing rnc #1730

Closed
asm0dey opened this issue Aug 15, 2023 · 7 comments · Fixed by #1769
Closed

Error while parsing rnc #1730

asm0dey opened this issue Aug 15, 2023 · 7 comments · Fixed by #1769

Comments

@asm0dey
Copy link

asm0dey commented Aug 15, 2023

Hi everybody,

I'm trying to parse opds.rnc, which includes atom.rnc with ModelLoader.load from com.sun.xml.bind:jaxb-xjc:4.0.3

I've got a following exception:

Exception in thread "main" java. lang.NullPointerException: Cannot invoke "com.sun.tools.rngom.ast.builder.CommentList.addComment(String, com.sun.tools.rngom.ast.om.Location)" because "comments" is null 
  at com.sun.tools.rngom.parse.compact.CompactSyntax.getComments(CompactSyntax.java:330) 
  at com.sun.tools.rngom.parse.compact.CompactSyntax.noteTopLevelComments(CompactSyntax.java:294) 
  at com.sun.tools.rngom.parse.compact.CompactSyntax.NamespaceDecl(CompactSyntax.java:789) 
  at com.sun.tools.rngom.parse.compact.CompactSyntax.Preamble(CompactSyntax.java:770) 
  at com.sun.tools.rngom.parse.compact.CompactSyntax.IncludedGrammar(CompactSyntax.java:714) 
  at com.sun.tools.rngom.parse.compact.CompactSyntax.parseInclude(CompactSyntax.java:150) 
  at com.sun.tools.rngom.parse.compact.CompactParseable.parseInclude(CompactParseable.java:63) 
  at com.sun.tools.rngom.digested.IncludeImpl.endInclude(IncludeImpl.java:59) 
  at com.sun.tools.rngom.parse.host.IncludeHost.endInclude(IncludeHost.java:52) 
  at com.sun.tools.rngom.parse.compact.CompactSyntax.Include(CompactSyntax.java:1663) 
  at com.sun.tools.rngom.parse.compact.CompactSyntax.GrammarComponent(CompactSyntax.java:1563) 
  at com.sun.tools.rngom.parse.compact.CompactSyntax.GrammarBody(CompactSyntax.java:1546) 
  at com.sun.tools.rngom.parse.compact.CompactSyntax.TopLevelGrammar(CompactSyntax.java:747) 
  at com.sun.tools.rngom.parse.compact.CompactSyntax.Input(CompactSyntax.java:442) 
  at com.sun.tools.rngom.parse.compact.CompactSyntax.parse(CompactSyntax.java:135) 
  at com.sun.tools.rngom.parse.compact.CompactParseable.parse(CompactParseable.java:55)
  at com.sun.tools.xjc.ModelLoader.loadRELAXNG(ModelLoader.java:580)
  at com.sun.tools.xjc.ModelLoader.loadRELAXNGCompact(ModelLoader.java:568)
  at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:134)
  at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:88)
  at org.redundent.kotlin.xml.gen.DslGenerator.generate(DslGenerator.kt:55)
  at org.redundent.kotlin.xml.gen.DslGeneratorKt.main(DslGenerator.kt:23)

Indeed, sometimes the following lines:

          if (comments == null)
            comments = sb.makeCommentList();

returns the null comments. It seems to me that it happens when SchemaBuilder contains a [#document: null].

It seems that it happens when CompactSyntax handles include. This statement is supported by the fact that when I parse just atom.rnc no errors happens.

@laurentschoelens
Copy link
Contributor

Hi @asm0dey

Since you provided the schema you try to generate java classes from, I'll try to provide a PR that fixes the error.

Regards

@asm0dey
Copy link
Author

asm0dey commented Sep 2, 2023

@laurentschoelens thank you very much! The generation of a correct code model from this schema is very interesting thing by itself because of complex hierarchies

@laurentschoelens
Copy link
Contributor

By curiosity : which tool do you use to generate java classes ?

@asm0dey
Copy link
Author

asm0dey commented Sep 2, 2023

Do you mean source code? I actually generate Kotlin with KotlinPoet

@laurentschoelens
Copy link
Contributor

Yes sorry, generate the source code from the rnc schema

@asm0dey
Copy link
Author

asm0dey commented Sep 2, 2023

JavaPoet and KotlinPoet are always my tools of choice for the code generation

@laurentschoelens
Copy link
Contributor

Reproduced
Working on PR 😄

laurentschoelens added a commit to laurentschoelens/jaxb-ri that referenced this issue Oct 16, 2023
laurentschoelens added a commit to laurentschoelens/jaxb-ri that referenced this issue Feb 9, 2024
lukasj added a commit to laurentschoelens/jaxb-ri that referenced this issue Feb 9, 2024
lukasj added a commit that referenced this issue Feb 9, 2024
Co-authored-by: Lukas Jungmann <lukas.jungmann@oracle.com>
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.

2 participants