Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  2. Schema schema = null;
  3. if (this.classificationConfig == null)
  4. {
  5. try
  6. {
  7. schema = sf.newSchema(this.getClass().getResource("/PdfReader/classification.xsd"));
  8. }
  9. catch (SAXException e)
  10. {
  11. log
  12. .error(
  13. "Problem with reading classification xml configuration. Xml is not valid by xsd schema. ", e);
  14. }
  15.  
  16. JAXBContext ctx = JAXBContext.newInstance(Classification.class);
  17. Unmarshaller unmarsh = ctx.createUnmarshaller();
  18. unmarsh.setSchema(schema);
  19.  
  20. this.classificationConfig =
  21. (Classification) unmarsh.unmarshal(new ByteArrayInputStream(xmlConfig.getBytes()));
  22.  
  23. }
  24. else
  25. {
  26. try
  27. {
  28. schema = sf.newSchema(this.getClass().getResource("/PdfReader/pdfReaderAdapter.xsd"));
  29. }
  30. catch (SAXException e)
  31. {
  32. log.error("Problem with reading pdfReaderAdapter xml configuration. Xml is not valid by xsd schema.",
  33. e);
  34. }
  35.  
  36. JAXBContext ctx = JAXBContext.newInstance(PdfReaderAdapter.class);
  37. Unmarshaller unmarsh = ctx.createUnmarshaller();
  38. unmarsh.setSchema(schema);
  39.  
  40. this.readerAdapterConfig =
  41. (PdfReaderAdapter) unmarsh.unmarshal(new ByteArrayInputStream(xmlConfig.getBytes()));
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement