コード例 #1
0
        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);
            }
        }