public string ValidateBook(string descriptionOfBookForErrorLog) { var ids = new List <string>(); var builder = new StringBuilder(); Ensure(RawDom.SafeSelectNodes("//div[contains(@class,'bloom-page')]").Count > 0, "Must have at least one page", builder); EnsureIdsAreUnique(this, "textarea", ids, builder); EnsureIdsAreUnique(this, "p", ids, builder); EnsureIdsAreUnique(this, "img", ids, builder); //TODO: validate other things, including html var x = builder.ToString().Trim(); if (x.Length == 0) { Logger.WriteEvent("HtmlDom.ValidateBook({0}): No Errors", descriptionOfBookForErrorLog); } else { Logger.WriteEvent("HtmlDom.ValidateBook({0}): {1}", descriptionOfBookForErrorLog, x); } return(builder.ToString()); }
/// <summary> /// Applies the XSLT, and returns an XML dom /// </summary> public XmlDocument ApplyXSLT(string pathToXSLT) { var transform = new XslCompiledTransform(); transform.Load(pathToXSLT); using (var stringWriter = new StringWriter()) using (var writer = XmlWriter.Create(stringWriter)) { transform.Transform(RawDom.CreateNavigator(), writer); var result = new XmlDocument(); result.LoadXml(stringWriter.ToString()); return(result); } }
public void RemoveModeStyleSheets() { foreach (XmlElement linkNode in RawDom.SafeSelectNodes("/html/head/link")) { var href = linkNode.GetAttribute("href"); if (href == null) { continue; } var fileName = Path.GetFileName(href); if (fileName.Contains("edit") || fileName.Contains("preview")) { linkNode.ParentNode.RemoveChild(linkNode); } } }
public void RemoveModeStyleSheets() { foreach (XmlElement linkNode in RawDom.SafeSelectNodes("/html/head/link")) { var href = linkNode.GetAttribute("href"); if (href == null) { continue; } var fileName = Path.GetFileName(href); if (fileName.Contains("edit") || fileName.Contains("preview")) { linkNode.ParentNode.RemoveChild(linkNode); } } // If present, remove the editMode attribute that tells use which mode we're editing in (original or translation) var body = RawDom.SafeSelectNodes("/html/body")[0] as XmlElement; if (body.HasAttribute("editMode")) { body.RemoveAttribute("editMode"); } }
public XmlElement SelectSingleNode(string xpath) { return(RawDom.SelectSingleNode(xpath) as XmlElement); }
public XmlNodeList SafeSelectNodes(string xpath) { return(RawDom.SafeSelectNodes(xpath)); }
public void AddStyleSheet(string locateFile) { RawDom.AddStyleSheet(locateFile); }