1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package tests;
21
22 import junit.framework.TestCase;
23 import org.apache.ws.commons.schema.XmlSchema;
24 import org.apache.ws.commons.schema.XmlSchemaCollection;
25 import org.apache.ws.commons.schema.XmlSchemaElement;
26 import org.apache.ws.commons.schema.XmlSchemaType;
27 import org.w3c.dom.Document;
28
29 import javax.xml.parsers.DocumentBuilderFactory;
30 import java.util.Iterator;
31
32 public class AllSimpleTypeTest extends TestCase {
33
34 public void testSimpleTypeSchemaGeneration() throws Exception {
35
36 DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
37 documentBuilderFactory.setNamespaceAware(true);
38 Document doc = documentBuilderFactory.newDocumentBuilder().
39 parse(Resources.asURI("allSimpleTypes.xsd"));
40
41 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
42 XmlSchema schema = schemaCol.read(doc,null);
43 assertNotNull(schema);
44
45
46
47
48 Iterator values = schema.getElements().getValues();
49 while (values.hasNext()) {
50 XmlSchemaElement elt = (XmlSchemaElement) values.next();
51 XmlSchemaType schemaType = elt.getSchemaType();
52 assertNotNull(schemaType);
53
54 }
55
56
57 }
58 }