this is pretty hacky, but allows us to FIndElementUsingSchema for a default schema

This commit is contained in:
Michael Becker 2020-08-21 12:03:04 -04:00
parent 3f3943e1de
commit 0ee168a5a9
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7

View File

@ -163,9 +163,17 @@ namespace UniversalEditor.ObjectModels.Markup
return tag.Value;
}
public string DefaultSchema { get; set; } = null;
public MarkupElement FindElementUsingSchema(string schema, string name)
{
string tagPrefix = null;
string defaultSchema = null;
if (DefaultSchema != null && DefaultSchema == schema)
{
return FindElement(name);
}
for (int i = 0; i < this.Elements.Count; i++) {
MarkupTagElement tagTopLevel = (this.Elements [i] as MarkupTagElement);
@ -175,10 +183,27 @@ namespace UniversalEditor.ObjectModels.Markup
if (tagTopLevel.Attributes [j].Value.Equals (schema)) {
tagPrefix = tagTopLevel.Attributes [j].Name;
MarkupAttribute attXMLNS = tagTopLevel.Attributes["xmlns"];
if (attXMLNS != null)
{
defaultSchema = attXMLNS.Value;
}
break;
}
}
// BEGIN: added 2020-08-20 by beckermj - for xmlns without namespace
else if (tagTopLevel.Attributes[j].Name == "xmlns")
{
if (tagTopLevel.Attributes[j].Value.Equals(schema))
{
defaultSchema = schema;
return tagTopLevel;
}
}
// END: added 2020-08-20 by beckermj - for xmlns without namespace
}
}
}
@ -188,6 +213,13 @@ namespace UniversalEditor.ObjectModels.Markup
return null;
}
DefaultSchema = defaultSchema;
if (DefaultSchema != null && DefaultSchema == schema)
{
MarkupElement el = FindElement(name);
if (el != null) return el;
}
string fullName = tagPrefix + ":" + name;
return FindElement (fullName);
}