relaxng / jing-trang

Schema validation and conversion based on RELAX NG
http://www.thaiopensource.com/relaxng/
Other
228 stars 69 forks source link

Fix NullPointerException when namespace URI is null. #248

Closed bguedas closed 5 years ago

bguedas commented 5 years ago

Inverting the equality avoids exception because ns is checked as not null.

bguedas commented 5 years ago

Here is the exception I got when trying to convert a RNG file to RNC:

Exception in thread "main" java.lang.NullPointerException
    at com.thaiopensource.relaxng.output.rnc.Output.checkContext(Output.java:1224)
    at com.thaiopensource.relaxng.output.rnc.Output.access$2800(Output.java:69)
    at com.thaiopensource.relaxng.output.rnc.Output$AnnotationChildOutput.visitElement(Output.java:879)
    at com.thaiopensource.relaxng.output.rnc.Output$AnnotationChildOutput.visitElement(Output.java:867)
    at com.thaiopensource.relaxng.edit.ElementAnnotation.accept(ElementAnnotation.java:60)
    at com.thaiopensource.relaxng.output.rnc.Output.topLevel(Output.java:145)
    at com.thaiopensource.relaxng.output.rnc.Output.output(Output.java:106)
    at com.thaiopensource.relaxng.output.rnc.RncOutputFormat.outputPattern(RncOutputFormat.java:33)
    at com.thaiopensource.relaxng.output.rnc.RncOutputFormat.output(RncOutputFormat.java:24)
    at com.thaiopensource.relaxng.translate.Driver.run(Driver.java:144)
    at com.thaiopensource.relaxng.translate.Driver.main(Driver.java:44)

after the fix:

/home/bguedas/test/input.rng:3:81: warning: in translated output prefix "a" not correctly bound to URI "http://relaxng.org/ns/compatibility/annotations/1.0" as perhaps needed for annotation because used inconsistently elsewhere

sideshowbarker commented 5 years ago

Thanks much — and sorry for the delay in getting around to testing and merging this