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