public override void FixtureInit() { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("html", "http://foo/xhtml")); htmlChildElements = SchemaCompletionData.GetChildElementCompletionData(path); }
public override void FixtureInit() { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("schema", "http://www.w3.org/2001/XMLSchema")); schemaChildElements = SchemaCompletionData.GetChildElementCompletionData(path); //schemaAttributes = SchemaCompletionData.GetAttributeCompletionData(path); // Get include elements attributes. path.Elements.Add(new QualifiedName("include", "http://www.w3.org/2001/XMLSchema")); includeAttributes = SchemaCompletionData.GetAttributeCompletionData(path); // Get annotation element info. path.Elements.RemoveLast(); path.Elements.Add(new QualifiedName("annotation", "http://www.w3.org/2001/XMLSchema")); annotationChildElements = SchemaCompletionData.GetChildElementCompletionData(path); annotationAttributes = SchemaCompletionData.GetAttributeCompletionData(path); // Get app info attributes. path.Elements.Add(new QualifiedName("appinfo", "http://www.w3.org/2001/XMLSchema")); appInfoAttributes = SchemaCompletionData.GetAttributeCompletionData(path); // Get foo attributes. path = new XmlElementPath(); path.Elements.Add(new QualifiedName("foo", "http://www.w3.org/2001/XMLSchema")); fooAttributes = SchemaCompletionData.GetAttributeCompletionData(path); }
public void NotEqual() { XmlElementPath newPath = new XmlElementPath(); newPath.Elements.Add(new QualifiedName("Foo", "bar")); Assert.IsFalse(newPath.Equals(path), "Should not be equal."); }
public override void FixtureInit() { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("foo", "http://foo.com")); attributeCompletionData = SchemaCompletionData.GetAttributeCompletionData(path); }
public override void FixtureInit() { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); noteChildElements = SchemaCompletionData.GetChildElementCompletionData(path); }
public void Equality() { XmlElementPath newPath = new XmlElementPath(); newPath.Elements.Add(new QualifiedName("foo", "http://foo")); Assert.IsTrue(newPath.Equals(path), "Should be equal."); }
public void CompactPathItem() { XmlElementPath newPath = new XmlElementPath(); newPath.Elements.Add(new QualifiedName("bar", "http://bar", "b")); path.Compact(); Assert.IsTrue(newPath.Equals(path), "Should be equal."); }
public override void FixtureInit() { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("project", "http://nant.sf.net//nant-0.84.xsd")); path.Elements.Add(new QualifiedName("attrib", "http://nant.sf.net//nant-0.84.xsd")); attributes = SchemaCompletionData.GetAttributeCompletionData(path); }
public void NoAttributesForUnknownElement() { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("foobar", "http://www.w3schools.com")); CompletionDataList attributes = SchemaCompletionData.GetAttributeCompletionData(path); Assert.AreEqual(0, attributes.Count, "Should not find attributes for unknown element."); }
public void TextHasNoChildElements() { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); path.Elements.Add(new QualifiedName("text", "http://www.w3schools.com")); Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Count, "Should be no child elements."); }
public override void FixtureInit() { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); attributeCompletionData = SchemaCompletionData.GetAttributeCompletionData(path); attributeName = attributeCompletionData[0].DisplayText; }
public override void FixtureInit() { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); XmlSchemaElement element = SchemaCompletionData.FindElement(path); attribute = SchemaCompletionData.FindAttribute(element, "name"); missingAttribute = SchemaCompletionData.FindAttribute(element, "missing"); }
public void Init() { path = new XmlElementPath(); firstQualifiedName = new QualifiedName("foo", "http://foo", "f"); path.Elements.Add(firstQualifiedName); secondQualifiedName = new QualifiedName("bar", "http://bar", "b"); path.Elements.Add(secondQualifiedName); }
public override void FixtureInit() { rootElementCompletionData = SchemaCompletionData.GetElementCompletionData(); XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("foo", "http://foo.com")); fooChildElementCompletionData = SchemaCompletionData.GetChildElementCompletionData(path); }
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); }
public void PathTest4() { string text = "<x:foo xmlns:x='" + namespaceURI + "' "; elementPath = XmlParser.GetActiveElementStartPath(text, text.Length); expectedElementPath = new XmlElementPath(); expectedElementPath.Elements.Add(new QualifiedName("foo", namespaceURI, "x")); Assert.IsTrue(expectedElementPath.Equals(elementPath), "Incorrect active element path."); }
public void SuccessTest4() { string text = "<bar xmlns='http://test.com'><foo xmlns='" + namespaceURI + "' ><"; elementPath = XmlParser.GetParentElementPath(text); expectedElementPath = new XmlElementPath(); expectedElementPath.Elements.Add(new QualifiedName("foo", namespaceURI)); Assert.IsTrue(elementPath.Equals(expectedElementPath), "Incorrect active element path."); }
public override void FixtureInit() { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("root", "http://foo")); rootChildElements = SchemaCompletionData.GetChildElementCompletionData(path); path.Elements.Add(new QualifiedName("foo", "http://foo")); fooAttributes = SchemaCompletionData.GetAttributeCompletionData(path); }
public void PathTest5() { string text = "<foo xmlns='" + namespaceURI + "'><bar a='a'>"; elementPath = XmlParser.GetActiveElementStartPathAtIndex(text, text.IndexOf("='a'")); expectedElementPath = new XmlElementPath(); expectedElementPath.Elements.Add(new QualifiedName("foo", namespaceURI)); expectedElementPath.Elements.Add(new QualifiedName("bar", namespaceURI)); Assert.IsTrue(elementPath.Equals(expectedElementPath), "Incorrect active element path."); }
public override void FixtureInit() { // Note element path. noteElementPath = new XmlElementPath(); QualifiedName noteQualifiedName = new QualifiedName("note", "http://www.w3schools.com"); noteElementPath.Elements.Add(noteQualifiedName); // Text element path. textElementPath = new XmlElementPath(); textElementPath.Elements.Add(noteQualifiedName); textElementPath.Elements.Add(new QualifiedName("text", "http://www.w3schools.com")); }
public void FixtureInit() { XmlTextReader reader = ResourceManager.GetXhtmlStrictSchema(); schemaCompletionData = new XmlSchemaCompletionData(reader); // Set up h1 element's path. h1Path = new XmlElementPath(); h1Path.Elements.Add(new QualifiedName("html", namespaceURI)); h1Path.Elements.Add(new QualifiedName("body", namespaceURI)); h1Path.Elements.Add(new QualifiedName("h1", namespaceURI)); // Get h1 element info. h1Attributes = schemaCompletionData.GetAttributeCompletionData(h1Path); }
public override void FixtureInit() { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("project", "http://foo")); path.Elements.Add(new QualifiedName("items", "http://foo")); itemsElementChildren = SchemaCompletionData.GetChildElementCompletionData(path); path.Elements.Add(new QualifiedName("file", "http://foo")); fileElementAttributes = SchemaCompletionData.GetAttributeCompletionData(path); fileElementChildren = SchemaCompletionData.GetChildElementCompletionData(path); }
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.RemoveLast(); path.Elements.Add(new QualifiedName("choice", "http://www.w3.org/2001/XMLSchema")); choiceChildElements = SchemaCompletionData.GetChildElementCompletionData(path); }
public override void FixtureInit() { // Get shipto attributes. shipToPath = new XmlElementPath(); QualifiedName shipOrderName = new QualifiedName("shiporder", "http://www.w3schools.com"); shipToPath.Elements.Add(shipOrderName); shipToPath.Elements.Add(new QualifiedName("shipto", "http://www.w3schools.com")); shipToAttributes = SchemaCompletionData.GetAttributeCompletionData(shipToPath); // Get shiporder attributes. shipOrderPath = new XmlElementPath(); shipOrderPath.Elements.Add(shipOrderName); shipOrderAttributes = SchemaCompletionData.GetAttributeCompletionData(shipOrderPath); }
/// <summary> /// Finds the schema given the xml element path. /// </summary> public XmlSchemaCompletionData FindSchema (IXmlSchemaCompletionDataCollection schemaCompletionDataItems, XmlElementPath path) { if (path.Elements.Count > 0) { string namespaceUri = path.Elements[0].Namespace; if (namespaceUri.Length > 0) { return schemaCompletionDataItems[namespaceUri]; } else if (defaultSchemaCompletionData != null) { // Use the default schema namespace if none // specified in a xml element path, otherwise // we will not find any attribute or element matches // later. foreach (QualifiedName name in path.Elements) { if (name.Namespace.Length == 0) { name.Namespace = defaultSchemaCompletionData.NamespaceUri; } } return defaultSchemaCompletionData; } } return null; }
public XmlSchemaCompletionData FindSchema (XmlElementPath path) { return FindSchema (XmlSchemaManager.SchemaCompletionDataItems, path); }
XmlElementPath ConvertPath (IList<XObject> path) { var elementPath = new XmlElementPath (); if (defaultSchemaCompletionData != null && !string.IsNullOrEmpty (defaultSchemaCompletionData.NamespaceUri)) elementPath.Namespaces.AddPrefix (defaultSchemaCompletionData.NamespaceUri, defaultNamespacePrefix ?? ""); foreach (var obj in path) { var el = obj as XElement; if (el == null) continue; foreach (var att in el.Attributes) { if (!string.IsNullOrEmpty (att.Value)) { if (att.Name.HasPrefix) { if (att.Name.Prefix == "xmlns") elementPath.Namespaces.AddPrefix (att.Value, att.Name.Name); } else if (att.Name.Name == "xmlns") { elementPath.Namespaces.AddPrefix (att.Value, ""); } } } string ns = elementPath.Namespaces.GetNamespace (el.Name.HasPrefix? el.Name.Prefix : ""); QualifiedName qn = new QualifiedName (el.Name.Name, ns, el.Name.Prefix ?? String.Empty); elementPath.Elements.Add (qn); } return elementPath; }
public XmlSchemaCompletionData FindSchema(XmlElementPath path) { return(FindSchema(XmlSchemaManager.SchemaCompletionDataItems, path)); }
public void FixtureInit() { XmlTextReader reader = ResourceManager.GetXsdSchema(); schemaCompletionData = new XmlSchemaCompletionData(reader); // Set up choice element's path. choicePath = new XmlElementPath(); choicePath.Elements.Add(new QualifiedName("schema", namespaceURI, prefix)); choicePath.Elements.Add(new QualifiedName("element", namespaceURI, prefix)); choicePath.Elements.Add(new QualifiedName("complexType", namespaceURI, prefix)); mixedAttributeValues = schemaCompletionData.GetAttributeValueCompletionData(choicePath, "mixed"); choicePath.Elements.Add(new QualifiedName("choice", namespaceURI, prefix)); // Get choice element info. choiceAttributes = schemaCompletionData.GetAttributeCompletionData(choicePath); maxOccursAttributeValues = schemaCompletionData.GetAttributeValueCompletionData(choicePath, "maxOccurs"); // Set up element path. elementPath = new XmlElementPath(); elementPath.Elements.Add(new QualifiedName("schema", namespaceURI, prefix)); elementFormDefaultAttributeValues = schemaCompletionData.GetAttributeValueCompletionData(elementPath, "elementFormDefault"); blockDefaultAttributeValues = schemaCompletionData.GetAttributeValueCompletionData(elementPath, "blockDefault"); finalDefaultAttributeValues = schemaCompletionData.GetAttributeValueCompletionData(elementPath, "finalDefault"); elementPath.Elements.Add(new QualifiedName("element", namespaceURI, prefix)); // Get element attribute info. elementAttributes = schemaCompletionData.GetAttributeCompletionData(elementPath); // Set up simple enum type path. simpleEnumPath = new XmlElementPath(); simpleEnumPath.Elements.Add(new QualifiedName("schema", namespaceURI, prefix)); simpleEnumPath.Elements.Add(new QualifiedName("simpleType", namespaceURI, prefix)); simpleEnumPath.Elements.Add(new QualifiedName("restriction", namespaceURI, prefix)); // Get child elements. simpleEnumElements = schemaCompletionData.GetChildElementCompletionData(simpleEnumPath); // Set up enum path. enumPath = new XmlElementPath(); enumPath.Elements.Add(new QualifiedName("schema", namespaceURI, prefix)); enumPath.Elements.Add(new QualifiedName("simpleType", namespaceURI, prefix)); enumPath.Elements.Add(new QualifiedName("restriction", namespaceURI, prefix)); enumPath.Elements.Add(new QualifiedName("enumeration", namespaceURI, prefix)); // Get attributes. enumAttributes = schemaCompletionData.GetAttributeCompletionData(enumPath); // Set up xs:all path. allElementPath = new XmlElementPath(); allElementPath.Elements.Add(new QualifiedName("schema", namespaceURI, prefix)); allElementPath.Elements.Add(new QualifiedName("element", namespaceURI, prefix)); allElementPath.Elements.Add(new QualifiedName("complexType", namespaceURI, prefix)); allElementPath.Elements.Add(new QualifiedName("all", namespaceURI, prefix)); // Get child elements of the xs:all element. allElementChildElements = schemaCompletionData.GetChildElementCompletionData(allElementPath); // Set up the path to the annotation element that is a child of xs:all. allElementAnnotationPath = new XmlElementPath(); allElementAnnotationPath.Elements.Add(new QualifiedName("schema", namespaceURI, prefix)); allElementAnnotationPath.Elements.Add(new QualifiedName("element", namespaceURI, prefix)); allElementAnnotationPath.Elements.Add(new QualifiedName("complexType", namespaceURI, prefix)); allElementAnnotationPath.Elements.Add(new QualifiedName("all", namespaceURI, prefix)); allElementAnnotationPath.Elements.Add(new QualifiedName("annotation", namespaceURI, prefix)); // Get the xs:all annotation child element. allElementAnnotationChildElements = schemaCompletionData.GetChildElementCompletionData(allElementAnnotationPath); }
/// <summary> /// Finds the schema given the xml element path. /// </summary> public XmlSchemaCompletionData FindSchema(IXmlSchemaCompletionDataCollection schemaCompletionDataItems, XmlElementPath path) { if (path.Elements.Count > 0) { string namespaceUri = path.Elements[0].Namespace; if (namespaceUri.Length > 0) { return(schemaCompletionDataItems[namespaceUri]); } else if (defaultSchemaCompletionData != null) { // Use the default schema namespace if none // specified in a xml element path, otherwise // we will not find any attribute or element matches // later. foreach (QualifiedName name in path.Elements) { if (name.Namespace.Length == 0) { name.Namespace = defaultSchemaCompletionData.NamespaceUri; } } return(defaultSchemaCompletionData); } } return(null); }
static XmlElementPath ConvertPath (IEnumerable<XElement> path) { XmlElementPath elementPath = new XmlElementPath (); var namespaces = new Dictionary<string, string> (); string defaultNamespace = null; foreach (XElement el in path) { foreach (XAttribute att in el.Attributes) { if (att.Name.HasPrefix) { if (att.Name.Prefix == "xmlns") namespaces [att.Name.Name] = att.Value; } else { if (att.Name.Name == "xmlns") defaultNamespace = att.Value; } } string ns = null; if (el.Name.HasPrefix) namespaces.TryGetValue (el.Name.Prefix, out ns); else ns = defaultNamespace; QualifiedName qn = new QualifiedName (el.Name.Name, ns, el.Name.Prefix ?? String.Empty); elementPath.Elements.Add (qn); } return elementPath; }
public void Init() { path = new XmlElementPath(); qualifiedName = new QualifiedName("foo", "http://foo"); path.Elements.Add(qualifiedName); }