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