JAXB unmarshalling a xml with inclusions -


i have xml below called “thefile.xml”

    <!doctype page [       <!entity class_common system "class_common.xml" >]>      <api xmlns:denp="http://intranet.denali.com/wiki/docbook_profiling">      &class_common; 

as can see line above refers xml file called “class_common.xml” . however, when

    cl = class_xml.objectfactory.class.getclassloader();     context = jaxbcontext.newinstance("class_xml", cl);     unmarshaller u = context.createunmarshaller();     api = (api) u.unmarshal(new fileinputstream(classxmlfile)); 

i error following. did miss anything? thanks

exception in thread "main" javax.xml.bind.unmarshalexception - linked exception:

[org.xml.sax.saxparseexception; linenumber: 8; columnnumber: 17; external entity: failed read external document 'class_common.xml', because 'file' access not allowed due restriction set accessexternaldtd property.] 

ok, here answer, java code needs following

    cl = class_xml.objectfactory.class.getclassloader();     context = jaxbcontext.newinstance("class_xml", cl);     unmarshaller u = context.createunmarshaller();      saxparserfactory spf = saxparserfactory.newinstance();      spf.setxincludeaware(true);     spf.setnamespaceaware(true);     spf.setvalidating(true); // not required jaxb/xinclude      xmlreader xr = (xmlreader) spf.newsaxparser().getxmlreader();     saxsource source = new saxsource(xr, new inputsource(new            fileinputstream(classxmlfile)));      api = (api) u.unmarshal(source); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -