Browse Source

SD2-758. XML element and attribute completion now works for complex types defined inside an xs:all element.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1340 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 20 years ago
parent
commit
e0dd5e3fca
  1. 3
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionData.cs
  2. 30
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AllElementTestFixture.cs

3
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionData.cs

@ -794,6 +794,7 @@ namespace ICSharpCode.XmlEditor @@ -794,6 +794,7 @@ namespace ICSharpCode.XmlEditor
XmlSchemaSequence sequence = complexType.Particle as XmlSchemaSequence;
XmlSchemaChoice choice = complexType.Particle as XmlSchemaChoice;
XmlSchemaGroupRef groupRef = complexType.Particle as XmlSchemaGroupRef;
XmlSchemaAll all = complexType.Particle as XmlSchemaAll;
XmlSchemaComplexContent complexContent = complexType.ContentModel as XmlSchemaComplexContent;
if (sequence != null) {
@ -810,6 +811,8 @@ namespace ICSharpCode.XmlEditor @@ -810,6 +811,8 @@ namespace ICSharpCode.XmlEditor
}
} else if (groupRef != null) {
matchedElement = FindElement(groupRef, name);
} else if (all != null) {
matchedElement = FindElement(all.Items, name);
}
return matchedElement;

30
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AllElementTestFixture.cs

@ -21,13 +21,18 @@ namespace XmlEditor.Tests.Schema @@ -21,13 +21,18 @@ namespace XmlEditor.Tests.Schema
public class AllElementTestFixture : SchemaTestFixtureBase
{
ICompletionData[] personElementChildren;
ICompletionData[] firstNameAttributes;
ICompletionData[] firstNameElementChildren;
public override void FixtureInit()
{
XmlElementPath path = new XmlElementPath();
path.Elements.Add(new QualifiedName("person", "http://foo"));
personElementChildren = SchemaCompletionData.GetChildElementCompletionData(path);
path.Elements.Add(new QualifiedName("firstname", "http://foo"));
firstNameAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
firstNameElementChildren = SchemaCompletionData.GetChildElementCompletionData(path);
}
[Test]
@ -37,13 +42,34 @@ namespace XmlEditor.Tests.Schema @@ -37,13 +42,34 @@ namespace XmlEditor.Tests.Schema
"Should be 2 child elements.");
}
[Test]
public void FirstNameElementHasAttribute()
{
Assert.AreEqual(1, firstNameAttributes.Length, "Should have one attribute.");
}
[Test]
public void FirstNameElementHasChildren()
{
Assert.AreEqual(2, firstNameElementChildren.Length,
"Should be 2 child elements.");
}
protected override string GetSchema()
{
return "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" targetNamespace=\"http://foo\">\r\n" +
" <xs:element name=\"person\">\r\n" +
" <xs:complexType>\r\n" +
" <xs:all>\r\n" +
" <xs:element name=\"firstname\" type=\"xs:string\"/>\r\n" +
" <xs:element name=\"firstname\">\r\n" +
" <xs:complexType>\r\n" +
" <xs:sequence>\r\n" +
" <xs:element name=\"short\" type=\"xs:string\"/>\r\n" +
" <xs:element name=\"title\" type=\"xs:string\"/>\r\n" +
" </xs:sequence>\r\n" +
" <xs:attribute name=\"id\"/>\r\n" +
" </xs:complexType>\r\n" +
" </xs:element>\r\n" +
" <xs:element name=\"lastname\" type=\"xs:string\"/>\r\n" +
" </xs:all>\r\n" +
" </xs:complexType>\r\n" +

Loading…
Cancel
Save