public void EqualsTest2() { QualifiedName name1 = new QualifiedName("foo", "http://foo.com", "f"); QualifiedName name2 = new QualifiedName("foo", "http://foo.com", "f"); Assert.AreEqual(name1, name2, "Should be the same."); }
public void NotEqualsTest2() { QualifiedName name1 = new QualifiedName("foo", "http://foo.com", "f"); QualifiedName name2 = null; Assert.IsFalse(name1 == name2, "Should not be the same."); }
public void EqualsTest3() { QualifiedName name1 = new QualifiedName("foo", "http://foo.com", "f"); QualifiedName name2 = new QualifiedName("foo", "http://foo.com", "ggg"); Assert.IsTrue(name1 == name2, "Should be the same."); }
public void HashCodeTest() { QualifiedName name1 = new QualifiedName("foo", "http://foo.com", "f"); XmlQualifiedName xmlQualifiedName = new XmlQualifiedName("foo", "http://foo.com"); Assert.AreEqual(name1.GetHashCode(), xmlQualifiedName.GetHashCode()); }
public static XmlElementPath Resolve (IList<XObject> path, string defaultNamespace = null, string defaultPrefix = null) { var elementPath = new XmlElementPath (); if (!string.IsNullOrEmpty (defaultNamespace)) elementPath.Namespaces.AddPrefix (defaultNamespace, defaultPrefix); 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 : ""); var qn = new QualifiedName (el.Name.Name, ns, el.Name.Prefix ?? ""); elementPath.Elements.Add (qn); } return elementPath; }
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() { // 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 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); }
async Task Init () { if (shipOrderAttributes != null) return; // 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 = await SchemaCompletionData.GetAttributeCompletionData(shipToPath, CancellationToken.None); // Get shiporder attributes. shipOrderPath = new XmlElementPath(); shipOrderPath.Elements.Add(shipOrderName); shipOrderAttributes = await SchemaCompletionData.GetAttributeCompletionData(shipOrderPath, CancellationToken.None); }
/// <summary> /// Finds an element in the schema. /// </summary> /// <remarks> /// Only looks at the elements that are defined in the /// root of the schema so it will not find any elements /// that are defined inside any complex types. /// </remarks> public XmlSchemaElement FindElement (QualifiedName name) { EnsureLoaded(); foreach (XmlSchemaElement element in schema.Elements.Values) { if (name.Equals (element.QualifiedName)) { return element; } } MonoDevelop.Core.LoggingService.LogDebug ("XmlSchemaDataObject did not find element '{0}' in the schema", name.Name); return null; }
XmlSchemaElement FindElement (XmlSchemaGroupRef groupRef, QualifiedName name) { var group = FindGroup (groupRef.RefName.Name); if (group == null) return null; var sequence = group.Particle as XmlSchemaSequence; if (sequence != null) return FindElement (sequence.Items, name); var choice = group.Particle as XmlSchemaChoice; if (choice != null) return FindElement (choice.Items, name); return null; }
/// <summary> /// Finds the element in the collection of schema objects. /// </summary> XmlSchemaElement FindElement (XmlSchemaObjectCollection items, QualifiedName name) { XmlSchemaElement matchedElement = null; foreach (XmlSchemaObject schemaObject in items) { var element = schemaObject as XmlSchemaElement; var sequence = schemaObject as XmlSchemaSequence; var choice = schemaObject as XmlSchemaChoice; var groupRef = schemaObject as XmlSchemaGroupRef; if (element != null) { if (element.Name != null) { if (name.Name == element.Name) { return element; } } else if (element.RefName != null) { if (name.Name == element.RefName.Name) { matchedElement = FindElement (element.RefName); } else { var abstractElement = FindElement (element.RefName); if (abstractElement != null && abstractElement.IsAbstract) { matchedElement = FindSubstitutionGroupElement (abstractElement.QualifiedName, name); } } } } else if (sequence != null) { matchedElement = FindElement (sequence.Items, name); } else if (choice != null) { matchedElement = FindElement (choice.Items, name); } else if (groupRef != null) { matchedElement = FindElement (groupRef, name); } if (matchedElement != null) return matchedElement; } return null; }
/// <summary> /// Finds the named child element contained in the restriction element. /// </summary> XmlSchemaElement FindChildElement (XmlSchemaComplexContentRestriction restriction, QualifiedName name) { var sequence = restriction.Particle as XmlSchemaSequence; if (sequence != null) return FindElement (sequence.Items, name); var groupRef = restriction.Particle as XmlSchemaGroupRef; if (groupRef != null) return FindElement (groupRef, name); return null; }
/// <summary> /// Finds the named child element contained in the extension element. /// </summary> XmlSchemaElement FindChildElement (XmlSchemaComplexContentExtension extension, QualifiedName name) { var complexType = FindNamedType (schema, extension.BaseTypeName); if (complexType == null) return null; var matchedElement = FindChildElement (complexType, name); if (matchedElement != null) return matchedElement; var sequence = extension.Particle as XmlSchemaSequence; if (sequence != null) return FindElement (sequence.Items, name); var choice = extension.Particle as XmlSchemaChoice; if (choice != null) return FindElement (choice.Items, name); var groupRef = extension.Particle as XmlSchemaGroupRef; if (groupRef != null) return FindElement (groupRef, name); return null; }
XmlSchemaElement FindChildElement (XmlSchemaComplexType complexType, QualifiedName name) { var sequence = complexType.Particle as XmlSchemaSequence; if (sequence != null) return FindElement (sequence.Items, name); var choice = complexType.Particle as XmlSchemaChoice; if (choice != null) return FindElement (choice.Items, name); var complexContent = complexType.ContentModel as XmlSchemaComplexContent; if (complexContent != null) { var extension = complexContent.Content as XmlSchemaComplexContentExtension; if (extension != null) return FindChildElement (extension, name); var restriction = complexContent.Content as XmlSchemaComplexContentRestriction; if (restriction != null) return FindChildElement (restriction, name); } var groupRef = complexType.Particle as XmlSchemaGroupRef; if (groupRef != null) return FindElement(groupRef, name); var all = complexType.Particle as XmlSchemaAll; if (all != null) return FindElement(all.Items, name); return null; }
/// <summary> /// Finds an element that matches the specified <paramref name="name"/> /// from the children of the given <paramref name="element"/>. /// </summary> XmlSchemaElement FindChildElement (XmlSchemaElement element, QualifiedName name) { var complexType = GetElementAsComplexType (element); if (complexType != null) return FindChildElement (complexType, name); return null; }
/// <summary> /// Finds the complex type with the specified name. /// </summary> public XmlSchemaComplexType FindComplexType (QualifiedName name) { EnsureLoaded (); var qualifiedName = new XmlQualifiedName (name.Name, name.Namespace); return FindNamedType (schema, qualifiedName); }
/// <summary> /// Looks for the substitution group element of the specified name. /// </summary> XmlSchemaElement FindSubstitutionGroupElement (XmlQualifiedName group, QualifiedName name) { foreach (XmlSchemaElement element in schema.Elements.Values) if (element.SubstitutionGroup == group && element.Name != null && element.Name == name.Name) return element; return null; }
public void Init() { path = new XmlElementPath(); qualifiedName = new QualifiedName("foo", "http://foo"); path.Elements.Add(qualifiedName); }