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. 5
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionData.cs
  2. 30
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AllElementTestFixture.cs

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

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

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

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

Loading…
Cancel
Save