Пример #1
0
    Context(Class clazz) {
      try {
        jaxbContext = JAXBContext.newInstance(clazz);

        marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        marshaller.setSchema(null);

        unmarshaller = jaxbContext.createUnmarshaller();
        unmarshaller.setSchema(null);
      } catch (JAXBException e) {
        e.printStackTrace();
      }
    }
Пример #2
0
 /** Used to retrieve the root document bound through JAXB */
 private static void getRootDocument() {
   if (rDocument == null) {
     try {
       JAXBContext jaxbCtxt = JAXBContext.newInstance("odin.odin.xml");
       Unmarshaller jaxbU = jaxbCtxt.createUnmarshaller();
       jaxbU.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
       File fRoot = new File("home.root.xml");
       JAXBElement<Root> rElement = jaxbU.unmarshal(new StreamSource(fRoot), Root.class);
       rDocument = rElement.getValue();
     } catch (JAXBException jaxbX) {
       System.err.println(
           "An error was caught while trying to read information from the server's root information document.");
       jaxbX.printStackTrace();
     }
   }
 }