public void GetAttributeCompletion_TemplateElementIsChildOfStylesheetElement_SubstitutionGroupUsedForTemplateAndMatchAttributeReturned() { var path = new XmlElementPath(); path.AddElement(new QualifiedName("stylesheet", namespaceURI)); path.AddElement(new QualifiedName("template", namespaceURI)); XmlCompletionItemCollection completionItems = schemaCompletion.GetAttributeCompletion(path); bool contains = completionItems.Contains("match"); Assert.IsTrue(contains); }
public void FixtureInit() { schemaCompletion = new XmlSchemaCompletion(ResourceManager.ReadXhtmlStrictSchema()); // Set up h1 element's path. h1Path = new XmlElementPath(); h1Path.AddElement(new QualifiedName("html", namespaceURI)); h1Path.AddElement(new QualifiedName("body", namespaceURI)); h1Path.AddElement(new QualifiedName("h1", namespaceURI)); // Get h1 element info. h1Attributes = schemaCompletion.GetAttributeCompletion(h1Path); }
/// <summary> /// Gets the missing attributes for the specified element based /// on its associated schema. /// </summary> string[] GetMissingAttributes(XmlElement element) { XmlElementPath elementPath = GetElementPath(element); List <string> attributes = new List <string>(); XmlSchemaCompletion schema = FindSchema(elementPath); if (schema != null) { XmlCompletionItemCollection completionItems = schema.GetAttributeCompletion(elementPath); foreach (XmlCompletionItem item in completionItems) { // Ignore existing attributes. if (!element.HasAttribute(item.Text)) { attributes.Add(item.Text); } } } return(attributes.ToArray()); }
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); }