1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package tests.w3c;
17
18 import org.w3c.dom.Element;
19 import org.w3c.dom.Node;
20 import org.w3c.dom.NodeList;
21
22
23
24
25
26 public class SchemaTest {
27
28 private final static String SCHEMA_DOCUMENT = "schemaDocument";
29
30 private final static String EXPECTED = "expected";
31
32 private final static String CURRENT = "current";
33
34 String schemaDocumentLink = null;
35
36 private String expectedValidity = null;
37
38 String currentStatus = null;
39
40 String currentDate = null;
41
42 public SchemaTest(Element n) throws Exception {
43 NodeList nl = n.getChildNodes();
44 for (int i = 0; i < nl.getLength(); i++) {
45 Node c = nl.item(i);
46 if (!(c instanceof Element))
47 continue;
48 Element elem = (Element) c;
49 String elemName = elem.getNodeName();
50 if (elemName.equals(SCHEMA_DOCUMENT)) {
51 schemaDocumentLink = elem.getAttributeNS(
52 "http://www.w3.org/1999/xlink", "href");
53
54
55
56 if (schemaDocumentLink.equals("./NISTTestsAll/NISTSchema-anyURI-maxLength-1.xsd")) {
57 schemaDocumentLink = "./nisttest/NISTTestsAll/NISTSchema-anyURI-maxLength-1.xsd";
58 }
59 }
60
61 if (elemName.equals(EXPECTED)) {
62 expectedValidity = elem.getAttribute("validity");
63 }
64
65 if (elemName.equals(CURRENT)) {
66 currentStatus = elem.getAttribute("status");
67 currentDate = elem.getAttribute("date");
68 }
69 }
70 }
71
72 public boolean isValid() {
73 return expectedValidity.equals("valid");
74 }
75
76 public String toString() {
77 StringBuffer sb = new StringBuffer("href=");
78 sb.append(schemaDocumentLink);
79 sb.append(" expectedValidity=");
80 sb.append(expectedValidity);
81 sb.append(" currentStatus=");
82 sb.append(currentStatus);
83 sb.append(" currentDate=");
84 sb.append(currentDate);
85
86 return sb.toString();
87 }
88 }