/// <summary> /// This is a temporary solution before the gui xml parse moves to the official NodeQuery.Parse method /// </summary> public static string GetNodeQueryXml(string guiQuery) { if (string.IsNullOrEmpty(guiQuery)) { return(guiQuery); } guiQuery = ReplacePath(guiQuery); foreach (var token in Tokens.AllKeys) { try { string repVal = null; switch (token) { case "[Me]": repVal = User.Current.Id.ToString(); break; case "[Site]": repVal = Site.Current.Id.ToString(); break; case "[Workspace]": repVal = PortalContext.Current.ContextWorkspace.Id.ToString(); break; case "[Page]": repVal = Page.Current.Id.ToString(); break; case "[Content]": repVal = PortalContext.Current.ContextNodeHead.Id.ToString(); break; default: repVal = Tokens[token]; break; } guiQuery = guiQuery.Replace(token, repVal).Replace(token.ToLower(), repVal); } catch (Exception ex) { Logger.WriteException(ex); } } var xsltTransform = Xslt.GetXslt("/Root/System/SystemPlugins/Renderers/Common/GuiToNodeQuery.xslt", false); var xDoc = new XmlDocument(); xDoc.LoadXml(guiQuery); using (var sw = new StringWriter()) { using (var writer = new XmlTextWriter(sw)) { xsltTransform.Transform(xDoc, null, writer); writer.Flush(); } return(sw.ToString()); } }
protected virtual void Render(TextWriter outputFileName, bool withChildren) { var writer = XmlWriter.Create(outputFileName, new XmlWriterSettings { Indent = true, Encoding = GetEncoding(), OmitXmlDeclaration = this.OmitXmlDeclaration }); var content = Content.Create(PortalContext.Current.ContextNode); var xml = new XPathDocument(content.GetXml(withChildren)); var xslt = Xslt.GetXslt(this.Path, true); var xsltArguments = GetXsltArgumentList(); xslt.Transform(xml, xsltArguments, writer); writer.Close(); }
private void SetBinary() { // cannot generate the view without a template if (Template == null) { return; } // load the source if exists IXPathNavigable viewSourceXml = GetSource(); if (viewSourceXml == null) { return; } var xsltTransform = Xslt.GetXslt(Template.Path, false); var newBinary = this.Binary ?? new BinaryData(); var ascxStream = new MemoryStream(); var xsltArgList = new System.Xml.Xsl.XsltArgumentList(); AddXsltParameters(xsltArgList); using (var sw = new StreamWriter(ascxStream, Encoding.UTF8)) { using (var writer = new HtmlTextWriter(sw)) { xsltTransform.Transform(viewSourceXml, xsltArgList, writer); writer.Flush(); this.Binary.SetStream(ascxStream); this.Binary = newBinary; sw.Flush(); ascxStream.Flush(); } } }
private void SetBinary() { if (Template == null) { //throw new InvalidOperationException("Template property is empty."); return; } var xsltTransform = Xslt.GetXslt(Template.Path, false); IXPathNavigable viewSourceXml = GetSource(); if (viewSourceXml == null) { throw new InvalidOperationException("View description xml bad or missing."); } var newBinary = this.Binary ?? new BinaryData(); var ascxStream = new MemoryStream(); var xsltArgList = new System.Xml.Xsl.XsltArgumentList(); AddXsltParameters(xsltArgList); using (var sw = new StreamWriter(ascxStream, Encoding.UTF8)) { using (var writer = new HtmlTextWriter(sw)) { xsltTransform.Transform(viewSourceXml, xsltArgList, writer); writer.Flush(); this.Binary.SetStream(ascxStream); this.Binary = newBinary; sw.Flush(); ascxStream.Flush(); } } }