internal static void MergeAttributes(DomElement fromElement, DomElement toElement) { // TODO Use of attr.Name here might not respect xmlns (rare) // Merge attributes foreach (var attr in fromElement.Attributes.ToArray()) { // Don't copy layout attributes if (IsLayoutAttr(attr)) { continue; } var current = toElement.Attributes[attr.Name]; if (current == null) { toElement.Attributes.Add(attr); } else if (IsMerging(current.Name)) { AttributeAppend(current, attr); } else { toElement.Attributes.Remove(attr.Name); toElement.Append(attr); toElement.Attributes.Add(attr); } } }
internal static DomObject ConvertNode(DomObject attr) { var __document = new HxlDocument(); DomElement root_article = __document.CreateElement("article"); DomObject root_article_hxlexpressionattribute = global::Carbonfrost.Commons.Hxl.HxlAttribute.Create("id", (__closure, __self__) => string.Concat((object)(__closure.Inside))); root_article.Append(root_article_hxlexpressionattribute); var conv = HxlCompilerConverter.ChooseConverter(attr); return(conv.Convert(attr, CSharpScriptGenerator.Instance)); }
internal virtual DomElement ApplyToElement(DomElement newElement) { var newEle = ConvertToElement(); if (newEle != null) { if (newElement == null) { newElement = newEle; } else { newElement.Append(newEle); } } return(newElement); }
static void ProcessElement(DomContainer e) { if (e == null) { return; } // TODO Copying to an array is wasteful (performance) foreach (var c in e.ChildNodes.ToArray()) { ProcessElement(c as DomElement); } // Language attributes can wrap the element -- // <span c:if /> ==> // <c:if> <span /> </c:if> if (e.Attributes == null) { return; } // TODO Correct order in these attributes (AttributeFragmentPriority) // TODO copying to array is wasteful (performance) var hxl = e.Attributes.OfType <HxlLangAttribute>().ToArray(); DomElement newElement = null; foreach (var m in hxl) { newElement = m.ApplyToElement(newElement); m.RemoveSelf(); } if (newElement != null) { e.ReplaceWith(newElement); newElement.Append(e); } }