Advertisement
mrenon

Untitled

Dec 11th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. //Instanciation d'un objet schéma depuis schema1.xsd à partir d'un SchemaFactory
  2. SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
  3. Schema schema = schemaFactory.newSchema(new File(".", "schema1.xsd"));
  4.  
  5. //Attribution du schema instancié au Unmarshaller
  6. //Si le flux ne respecte pas le schema, une erreur est levée
  7. Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
  8. unmarshaller.setSchema(schema);
  9. Formation unmarshall = (Formation) unmarshaller.unmarshal(new File("formation.xml"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement