internal static XmlNode ProcessSageLinkElement(SageContext context, XmlNode node) { Contract.Requires<ArgumentNullException>(node != null); if (node.SelectSingleElement("ancestor::sage:literal", XmlNamespaces.Manager) != null) return node; XmlElement linkElem = (XmlElement) node; string linkName = context.ProcessText(linkElem.GetAttribute("ref")); bool rawString = linkElem.GetAttribute("raw").EqualsAnyOf("1", "yes", "true"); if (!string.IsNullOrEmpty(linkName) && rawString) { if (context.Url.Links.ContainsKey(linkName)) { linkElem.InnerText = context.Url.Links[linkName].Value; } return linkElem; } string linkHref = context.Url.GetUrl(linkElem); if (!string.IsNullOrEmpty(linkHref)) { linkElem.SetAttribute("href", linkHref); } foreach (XmlNode child in node.ChildNodes) { XmlNode processed = NodeEvaluator.GetNodeHandler(child)(context, child); if (processed != null) node.ReplaceChild(processed, child); else node.RemoveChild(child); } return linkElem; }
internal static XmlNode ProcessHrefAttribute(SageContext context, XmlNode node) { Contract.Requires<ArgumentNullException>(node != null); if (node.SelectSingleElement("ancestor::sage:literal", XmlNamespaces.Manager) != null) return node; node.InnerText = context.ProcessText(node.InnerText); return node; }