1 package tests;
2
3 import junit.framework.TestCase;
4 import org.apache.ws.commons.schema.*;
5 import org.w3c.dom.Document;
6
7 import javax.xml.namespace.QName;
8 import javax.xml.parsers.DocumentBuilderFactory;
9 import java.util.Iterator;
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 public class TestUnqualifiedSchema extends TestCase {
27
28
29 public void testUnqualifiedSchemas() throws Exception {
30 DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
31 documentBuilderFactory.setNamespaceAware(true);
32 Document doc = documentBuilderFactory.newDocumentBuilder().
33 parse(Resources.asURI("unqualifiedTypes.xsd"));
34 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
35 XmlSchema s = schemaCol.read(doc.getDocumentElement());
36
37 assertNotNull(s);
38
39 XmlSchemaElement e=s.getElementByName(new QName("http://soapinterop.org/xsd","complexElt") );
40 XmlSchemaComplexType t =(XmlSchemaComplexType)e.getSchemaType();
41 assertNotNull(t);
42
43 XmlSchemaSequence seq = (XmlSchemaSequence)t.getParticle();
44 XmlSchemaObjectCollection items = seq.getItems();
45 Iterator iterator = items.getIterator();
46 while (iterator.hasNext()) {
47 XmlSchemaElement elt2 = (XmlSchemaElement) iterator.next();
48 System.out.println(elt2.getQName());
49 XmlSchemaType schemaType2 = elt2.getSchemaType();
50
51 assertNotNull(schemaType2);
52 }
53
54
55
56 }
57
58
59 }