java - RelaxNG: merging grammar inside a jar -


i using relaxng , jing (relaxng validator in java) validating xml files , need merge grammars (reuse of element definitions in 2 grammars).
achieve merge include grammar element , give href attribute value of included grammar file:

<include href="embededgrammar.xml"/> 

all grammar files located @ same path in resources of java project.
when testing application within ide included grammar in found , xml data files validated.
when package application jar file embedded grammar not found , error message reports tries find @ same location jar file (not in jar file @ same place embedding grammar should).

i have implemented workaround implement clean solution therefore if solved such issue please let me know how.
thanks.

edit:it working fine if hard code href value point file inside jar file (jar:file:./jarfile.jar/path/to/file/ebeddedgrammar.xml) jar file name may change (version number appended) not possible test within ide.

i found solution consists in registering urlstreamhandler allows refer resources url classpath protocol can spring framework. result can refer embedded grammar file this:

<include href="classpath:path/to/resource/embeddedgrammar.xml"/> 

a clear explanation on how register , use urlstreamhandler can found here: url load resources classpath in java


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -