1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.Xml.Completion;
using NUnit.Framework;
namespace MonoDevelop.Xml.Tests.Schema
{
/// <summary>
/// Tests complex content restriction elements.
/// </summary>
[TestFixture]
public class RestrictionElementTestFixture : SchemaTestFixtureBase
{
CompletionDataList childElements;
CompletionDataList attributes;
CompletionDataList annotationChildElements;
CompletionDataList choiceChildElements;
public override void FixtureInit()
{
XmlElementPath path = new XmlElementPath();
path.Elements.Add(new QualifiedName("group", "http://www.w3.org/2001/XMLSchema"));
childElements = SchemaCompletionData.GetChildElementCompletionData(path);
attributes = SchemaCompletionData.GetAttributeCompletionData(path);
// Get annotation child elements.
path.Elements.Add(new QualifiedName("annotation", "http://www.w3.org/2001/XMLSchema"));
annotationChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
// Get choice child elements.
path.Elements.RemoveAt (path.Elements.Count - 1);
path.Elements.Add(new QualifiedName("choice", "http://www.w3.org/2001/XMLSchema"));
choiceChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
}
[Test]
public void GroupChildElementIsAnnotation()
{
Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "annotation"),
"Should have a child element called annotation.");
}
[Test]
public void GroupChildElementIsChoice()
{
Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "choice"),
"Should have a child element called choice.");
}
[Test]
public void GroupChildElementIsSequence()
{
Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "sequence"),
"Should have a child element called sequence.");
}
[Test]
public void GroupAttributeIsName()
{
Assert.IsTrue(SchemaTestFixtureBase.Contains(attributes, "name"),
"Should have an attribute called name.");
}
[Test]
public void AnnotationChildElementIsAppInfo()
{
Assert.IsTrue(SchemaTestFixtureBase.Contains(annotationChildElements, "appinfo"),
"Should have a child element called appinfo.");
}
[Test]
public void AnnotationChildElementIsDocumentation()
{
Assert.IsTrue(SchemaTestFixtureBase.Contains(annotationChildElements, "documentation"),
"Should have a child element called appinfo.");
}
[Test]
public void ChoiceChildElementIsSequence()
{
Assert.IsTrue(SchemaTestFixtureBase.Contains(choiceChildElements, "element"),
"Should have a child element called element.");
}
protected override string GetSchema()
{
return "<xs:schema targetNamespace=\"http://www.w3.org/2001/XMLSchema\" blockDefault=\"#all\" elementFormDefault=\"qualified\" version=\"1.0\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xml:lang=\"EN\" xmlns:hfp=\"http://www.w3.org/2001/XMLSchema-hasFacetAndProperty\">\r\n" +
"\r\n" +
" <xs:element name=\"group\" type=\"xs:namedGroup\" id=\"group\">\r\n" +
" </xs:element>\r\n" +
"\r\n" +
" <xs:element name=\"annotation\" id=\"annotation\">\r\n" +
" <xs:complexType>\r\n" +
" <xs:choice minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
" <xs:element name=\"appinfo\"/>\r\n" +
" <xs:element name=\"documentation\"/>\r\n" +
" </xs:choice>\r\n" +
" <xs:attribute name=\"id\" type=\"xs:ID\"/>\r\n" +
" </xs:complexType>\r\n" +
" </xs:element>\r\n" +
"\r\n" +
"\r\n" +
" <xs:complexType name=\"namedGroup\">\r\n" +
" <xs:complexContent>\r\n" +
" <xs:restriction base=\"xs:realGroup\">\r\n" +
" <xs:sequence>\r\n" +
" <xs:element ref=\"xs:annotation\" minOccurs=\"0\"/>\r\n" +
" <xs:choice minOccurs=\"1\" maxOccurs=\"1\">\r\n" +
" <xs:element ref=\"xs:choice\"/>\r\n" +
" <xs:element name=\"sequence\"/>\r\n" +
" </xs:choice>\r\n" +
" </xs:sequence>\r\n" +
" <xs:attribute name=\"name\" use=\"required\" type=\"xs:NCName\"/>\r\n" +
" <xs:attribute name=\"ref\" use=\"prohibited\"/>\r\n" +
" <xs:attribute name=\"minOccurs\" use=\"prohibited\"/>\r\n" +
" <xs:attribute name=\"maxOccurs\" use=\"prohibited\"/>\r\n" +
" <xs:anyAttribute namespace=\"##other\" processContents=\"lax\"/>\r\n" +
" </xs:restriction>\r\n" +
" </xs:complexContent>\r\n" +
" </xs:complexType>\r\n" +
"\r\n" +
" <xs:complexType name=\"realGroup\">\r\n" +
" <xs:sequence>\r\n" +
" <xs:element ref=\"xs:annotation\" minOccurs=\"0\"/>\r\n" +
" <xs:choice minOccurs=\"0\" maxOccurs=\"1\">\r\n" +
" <xs:element name=\"all\"/>\r\n" +
" <xs:element ref=\"xs:choice\"/>\r\n" +
" <xs:element name=\"sequence\"/>\r\n" +
" </xs:choice>\r\n" +
" </xs:sequence>\r\n" +
" <xs:anyAttribute namespace=\"##other\" processContents=\"lax\"/>\r\n" +
" </xs:complexType>\r\n" +
"\r\n" +
" <xs:element name=\"choice\" id=\"choice\">\r\n" +
" <xs:complexType>\r\n" +
" <xs:choice minOccurs=\"0\" maxOccurs=\"1\">\r\n" +
" <xs:element name=\"element\"/>\r\n" +
" <xs:element name=\"sequence\"/>\r\n" +
" </xs:choice>\r\n" +
" </xs:complexType>\r\n" +
" </xs:element>\r\n" +
"</xs:schema>";
}
}
}
|