Example #1
0
        public static HtmlDocumentFacade ProcessDifferences(HtmlDocumentFacade doc)
        {
            var urlSource = HttpContext.Current.Request["tsp-src"];
            if (urlSource != null)
            {
                return null;
            }
            HtmlDocumentFacade diffDoc = doc;
            doc.Trace("begindocInherits");
            var docInherits = doc.querySelectorAll("html>head>link[rel='export']");
            doc.Trace("enddocInherits");
            if (docInherits.Count == 0) return null;
            if (docInherits.Count > 1)
            {
                throw new ArgumentException("Cannot inherit from more than one page");
            }
            var metaEl = docInherits[0];
            var baseDocRelativeURL = metaEl.getAttribute("href");
            if (string.IsNullOrEmpty(baseDocRelativeURL)) throw new ArgumentException("No Content Attribute found");
            var inheritedContentFilePath = doc.GetHostContentFilePath(baseDocRelativeURL);
            var superHandler = new tspHandler(inheritedContentFilePath);
            HtmlDocumentFacade superDoc = superHandler.ProcessFile();

            //var nodeHierarchy = new Stack<HtmlNodeFacade>();
            //nodeHierarchy.Push(diffDoc.html);
            //var differenceStack = new Stack<NodeDifference>();
            //var differences = new List<NodeDifference>();
            //ProcessNode(nodeHierarchy, differenceStack, differences);
            //MergeDifferences(superDoc, differences);
            //return superDoc;
            ProcessTransform(superDoc.html, doc.html);
            return superDoc;
        }