public override void FixtureInit() { // Note element path. noteElementPath = new XmlElementPath(); QualifiedName noteQualifiedName = new QualifiedName("note", "http://www.w3schools.com"); noteElementPath.AddElement(noteQualifiedName); // Text element path. textElementPath = new XmlElementPath(); textElementPath.AddElement(noteQualifiedName); textElementPath.AddElement(new QualifiedName("text", "http://www.w3schools.com")); }
public void GetSchemasForElementPathUpdatesElementNamespacesUsingDefaultSchemaNamespace() { XmlElementPath path = new XmlElementPath(); path.AddElement(new QualifiedName("root", String.Empty)); path.AddElement(new QualifiedName("different-ns-element", "unknown-namespace")); path.AddElement(new QualifiedName("child", String.Empty)); string xml = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='default-ns' />"; XmlSchemaCompletion defaultSchema = new XmlSchemaCompletion(new StringReader(xml)); defaultSchema.FileName = "default.xsd"; schemas.GetSchemas(path, defaultSchema); XmlElementPath expectedPath = new XmlElementPath(); expectedPath.AddElement(new QualifiedName("root", "default-ns")); expectedPath.AddElement(new QualifiedName("different-ns-element", "unknown-namespace")); expectedPath.AddElement(new QualifiedName("child", "default-ns")); Assert.AreEqual(expectedPath, path); }
public void GetChildElementCompletionForDuplicateFooRootElement() { XmlElementPath path = new XmlElementPath(); path.AddElement(new QualifiedName("duplicate-foo-note", "foo")); XmlCompletionItemCollection items = schemas.GetChildElementCompletion(path, null); items.Sort(); List <XmlCompletionItem> expectedItems = new List <XmlCompletionItem>(); expectedItems.Add(new XmlCompletionItem("duplicate-foo-text", XmlCompletionItemType.XmlElement)); Assert.AreEqual(expectedItems.ToArray(), items.ToArray()); }
public void GetSchemasForElementPathReturnsDefaultSchemaWhenNoNamespaceUsedInPathButHasDefaultSchema() { XmlElementPath path = new XmlElementPath(); path.AddElement(new QualifiedName("root", String.Empty)); XmlSchemaCompletion defaultSchema = new XmlSchemaCompletion(); defaultSchema.FileName = "default.xsd"; XmlSchemaCompletionCollection foundSchemas = schemas.GetSchemas(path, defaultSchema); string[] expectedFileNames = new string[] { "default.xsd" }; Assert.AreEqual(expectedFileNames, XmlSchemaCompletionCollectionFileNames.GetFileNames(foundSchemas)); }
public override void FixtureInit() { // Get shipto attributes. shipToPath = new XmlElementPath(); QualifiedName shipOrderName = new QualifiedName("shiporder", "http://www.w3schools.com"); shipToPath.AddElement(shipOrderName); shipToPath.AddElement(new QualifiedName("shipto", "http://www.w3schools.com")); shipToAttributes = SchemaCompletion.GetAttributeCompletion(shipToPath); // Get shiporder attributes. shipOrderPath = new XmlElementPath(); shipOrderPath.AddElement(shipOrderName); shipOrderAttributes = SchemaCompletion.GetAttributeCompletion(shipOrderPath); }
public void UnusedNamespaceInScopeCannotBeFoundInSchemaCollection() { XmlElementPath path = new XmlElementPath(); path.NamespacesInScope.Add(new XmlNamespace("b", "namespace-which-does-not-exist-in-schema-collection")); path.AddElement(new QualifiedName("foo-note", "foo")); XmlCompletionItemCollection items = schemas.GetElementCompletionForAllNamespaces(path, null); items.Sort(); XmlCompletionItemCollection expectedItems = new XmlCompletionItemCollection(); expectedItems.Add(new XmlCompletionItem("foo-text", XmlCompletionItemType.XmlElement)); Assert.AreEqual(expectedItems, items); }
public void FooSchemaRootElementOnlyInPath() { XmlElementPath path = new XmlElementPath(); path.NamespacesInScope.Add(new XmlNamespace("b", "bar")); path.AddElement(new QualifiedName("foo-note", "foo")); XmlCompletionItemCollection items = schemas.GetElementCompletionForAllNamespaces(path, null); items.Sort(); XmlCompletionItemCollection expectedItems = new XmlCompletionItemCollection(); expectedItems.Add(new XmlCompletionItem("b:bar-note", XmlCompletionItemType.XmlElement)); expectedItems.Add(new XmlCompletionItem("foo-text", XmlCompletionItemType.XmlElement)); Assert.AreEqual(expectedItems, items); }
public void Init() { path = new XmlElementPath(); qualifiedName = new QualifiedName("foo", "http://foo"); path.AddElement(qualifiedName); }
public void FixtureInit() { schemaCompletion = new XmlSchemaCompletion(ResourceManager.ReadXsdSchema()); // Set up choice element's path. choicePath = new XmlElementPath(); choicePath.AddElement(new QualifiedName("schema", namespaceURI, prefix)); choicePath.AddElement(new QualifiedName("element", namespaceURI, prefix)); choicePath.AddElement(new QualifiedName("complexType", namespaceURI, prefix)); mixedAttributeValues = schemaCompletion.GetAttributeValueCompletion(choicePath, "mixed"); choicePath.AddElement(new QualifiedName("choice", namespaceURI, prefix)); // Get choice element info. choiceAttributes = schemaCompletion.GetAttributeCompletion(choicePath); maxOccursAttributeValues = schemaCompletion.GetAttributeValueCompletion(choicePath, "maxOccurs"); // Set up element path. elementPath = new XmlElementPath(); elementPath.AddElement(new QualifiedName("schema", namespaceURI, prefix)); elementFormDefaultAttributeValues = schemaCompletion.GetAttributeValueCompletion(elementPath, "elementFormDefault"); blockDefaultAttributeValues = schemaCompletion.GetAttributeValueCompletion(elementPath, "blockDefault"); finalDefaultAttributeValues = schemaCompletion.GetAttributeValueCompletion(elementPath, "finalDefault"); elementPath.AddElement(new QualifiedName("element", namespaceURI, prefix)); // Get element attribute info. elementAttributes = schemaCompletion.GetAttributeCompletion(elementPath); // Set up simple enum type path. simpleEnumPath = new XmlElementPath(); simpleEnumPath.AddElement(new QualifiedName("schema", namespaceURI, prefix)); simpleEnumPath.AddElement(new QualifiedName("simpleType", namespaceURI, prefix)); simpleEnumPath.AddElement(new QualifiedName("restriction", namespaceURI, prefix)); // Get child elements. simpleEnumElements = schemaCompletion.GetChildElementCompletion(simpleEnumPath); // Set up enum path. enumPath = new XmlElementPath(); enumPath.AddElement(new QualifiedName("schema", namespaceURI, prefix)); enumPath.AddElement(new QualifiedName("simpleType", namespaceURI, prefix)); enumPath.AddElement(new QualifiedName("restriction", namespaceURI, prefix)); enumPath.AddElement(new QualifiedName("enumeration", namespaceURI, prefix)); // Get attributes. enumAttributes = schemaCompletion.GetAttributeCompletion(enumPath); // Set up xs:all path. allElementPath = new XmlElementPath(); allElementPath.AddElement(new QualifiedName("schema", namespaceURI, prefix)); allElementPath.AddElement(new QualifiedName("element", namespaceURI, prefix)); allElementPath.AddElement(new QualifiedName("complexType", namespaceURI, prefix)); allElementPath.AddElement(new QualifiedName("all", namespaceURI, prefix)); // Get child elements of the xs:all element. allElementChildElements = schemaCompletion.GetChildElementCompletion(allElementPath); // Set up the path to the annotation element that is a child of xs:all. allElementAnnotationPath = new XmlElementPath(); allElementAnnotationPath.AddElement(new QualifiedName("schema", namespaceURI, prefix)); allElementAnnotationPath.AddElement(new QualifiedName("element", namespaceURI, prefix)); allElementAnnotationPath.AddElement(new QualifiedName("complexType", namespaceURI, prefix)); allElementAnnotationPath.AddElement(new QualifiedName("all", namespaceURI, prefix)); allElementAnnotationPath.AddElement(new QualifiedName("annotation", namespaceURI, prefix)); // Get the xs:all annotation child element. allElementAnnotationChildElements = schemaCompletion.GetChildElementCompletion(allElementAnnotationPath); }