allow us to find attributes as well as elements using an XML schema (xmlns)
This commit is contained in:
parent
f150251cf2
commit
e1e4dfbfb5
@ -113,25 +113,33 @@ namespace UniversalEditor.ObjectModels.Markup
|
||||
}
|
||||
}
|
||||
|
||||
public MarkupElement FindElementUsingSchema(string schema, string name)
|
||||
protected string FindSchemaTagPrefix(string schema)
|
||||
{
|
||||
string tagPrefix = null;
|
||||
for (int i = 0; i < this.ParentObjectModel.Elements.Count; i++)
|
||||
{
|
||||
MarkupTagElement tagTopLevel = (this.ParentObjectModel.Elements [i] as MarkupTagElement);
|
||||
if (tagTopLevel != null) {
|
||||
for (int j = 0; j < tagTopLevel.Attributes.Count; j++) {
|
||||
if (tagTopLevel.Attributes [j].Namespace.Equals ("xmlns")) {
|
||||
MarkupTagElement tagTopLevel = (this.ParentObjectModel.Elements[i] as MarkupTagElement);
|
||||
if (tagTopLevel != null)
|
||||
{
|
||||
for (int j = 0; j < tagTopLevel.Attributes.Count; j++)
|
||||
{
|
||||
if (tagTopLevel.Attributes[j].Namespace.Equals("xmlns"))
|
||||
{
|
||||
|
||||
if (tagTopLevel.Attributes [j].Value.Equals (schema)) {
|
||||
tagPrefix = tagTopLevel.Attributes [j].Name;
|
||||
break;
|
||||
if (tagTopLevel.Attributes[j].Value.Equals(schema))
|
||||
{
|
||||
return tagTopLevel.Attributes[j].Name;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public MarkupElement FindElementUsingSchema(string schema, string name)
|
||||
{
|
||||
string tagPrefix = FindSchemaTagPrefix(schema);
|
||||
|
||||
if (tagPrefix == null) {
|
||||
Console.WriteLine ("ue: MarkupObjectModel: tag prefix for schema '" + schema + "' not found");
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Markup
|
||||
@ -99,5 +100,19 @@ namespace UniversalEditor.ObjectModels.Markup
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public MarkupAttribute FindAttributeUsingSchema(string schema, string name)
|
||||
{
|
||||
string tagPrefix = FindSchemaTagPrefix(schema);
|
||||
if (tagPrefix != null)
|
||||
{
|
||||
for (int i = 0; i < Attributes.Count; i++)
|
||||
{
|
||||
if (Attributes[i].Namespace == tagPrefix && Attributes[i].Name == name)
|
||||
return Attributes[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user