1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package tests;
17
18 import junit.framework.TestCase;
19 import org.apache.ws.commons.schema.*;
20 import org.w3c.dom.Document;
21
22 import javax.xml.namespace.QName;
23 import javax.xml.parsers.DocumentBuilderFactory;
24
25
26 public class AnyAttTest extends TestCase {
27
28 protected void setUp() throws Exception {
29
30 }
31
32 public void testAnyAtt() throws Exception{
33
34 DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
35 documentBuilderFactory.setNamespaceAware(true);
36 Document doc = documentBuilderFactory.newDocumentBuilder().
37 parse(Resources.asURI("anyAttTest.xsd"));
38
39 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
40 XmlSchema s = schemaCol.read(doc.getDocumentElement());
41
42
43 XmlSchemaElement elt = s.getElementByName(new QName("http://unqualified-elements.example.com","AnyAttContainer"));
44 assertNotNull("Element \"AnyAttContainer\" is missing! ",elt);
45
46 XmlSchemaType schemaType = elt.getSchemaType();
47 assertNotNull("Relevant schema type is missing!",schemaType);
48
49 XmlSchemaComplexType xmlSchemaComplexType = ((XmlSchemaComplexType) schemaType);
50 XmlSchemaParticle particle = xmlSchemaComplexType.getParticle();
51 assertNotNull(particle);
52
53 XmlSchemaAnyAttribute anyAttribute = xmlSchemaComplexType.getAnyAttribute();
54 assertNotNull("Any attribute is missing",anyAttribute);
55
56
57 }
58
59 }