01: package edu.iu.uis.eden.xml;
02:
03: import org.jdom.*;
04: import org.jdom.input.*;
05: import java.io.*;
06:
07: public class SchemaValidationTest {
08:
09: public static void main(String[] args) {
10: try {
11: SAXBuilder builder = new SAXBuilder(
12: "org.apache.xerces.parsers.SAXParser", true);
13:
14: builder.setFeature(
15: "http://apache.org/xml/features/validation/schema",
16: true);
17:
18: builder.setFeature(
19: "http://xml.org/sax/features/validation", true);
20:
21: builder
22: .setFeature(
23: "http://apache.org/xml/features/validation/schema-full-checking",
24: true);
25:
26: builder
27: .setProperty(
28: "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
29: "file:///C:/java/projects/workflow/test/data/WorkgroupSchema.xsd");
30:
31: Document doc = builder.build(new File(
32: "test/data/WorkgroupContentTravel.xml"));
33:
34: System.out.println("XML is validated");
35: } catch (Exception e) {
36: System.out.println("Caught exception: " + e.toString());
37: e.printStackTrace(System.out);
38: }
39: }
40: }
|