Creating a GoView from an XSLT transformation

I am using XSLT transformations to create web pages, and I would like to be able to use GoView diagrams in these pages. I have used diagrams extensively on other pages created from pages.

I have enclosed the GoView control in a user control, and I “declare” that user control in the XSLT file. That works without error. When the Page.ParseControl code runs to add the XSLT-generated controls to the page, he user controls diagram-creating code runs as it should. But, no diagram is rendered on the page.

I know this is a dodgey way to do this; a third party control, wrapped in a user control, and generated from within an XSLT transformation but, it would give me some wonderful modularity in my application if I can pull it off.

Does anyone have any experience with this sort of thing? Is there a step I am missing?

Thanks in advance for any advice you can offer.

Well. I’ve searched this forum, and our complete record of GoDiagram support email… no one has ever asked this question.

If you look at the page source in the browser, are you getting the

<img src="GoWebImage.axd?GoView=9ca3b8...

you would expect for the GoView?

I went googling, and found this…

but… it may look familiar.

Yes, that article does look familiar! Smile

I tried this before and had to abandon it for the time being.


Here is how to do it:

Remember, I have wrapped the GoView functionality in a user control…

In the XSLT file, within the <xsl:stylesheet > tag, you should declare the user control “name space” with the “remove” parameter. Here is the one I have in my file:

<xsl:stylesheet version=“1.0” xmlns:asp=“remove”

Then, wherever you want the control to appear, you include the control declaration in the XSLT. In my case, like this:

<cc1:FlowChart ID=“FlowChart1” runat=“server”></cc1:FlowChart>

In the page that uses the transformation, I do the following:

I call out to a data service that returns the xml data for the page. I apply the XSLT transformation like so:

    XmlNode xnode = srvc.GetObject(Int32.Parse(tmp)); //srvc is the data service object, which has a GetObject method.
    XmlDocument xdoc = new XmlDocument();
    xdoc.AppendChild(xdoc.ImportNode(xnode, true));
    StringWriter sw = new StringWriter();
    XslCompiledTransform xtfrm = new XslCompiledTransform();

    xtfrm.Transform(xdoc, null, sw);
    String sHTML = sw.ToString();

Then, I remove the namespace declarations from the stylesheet tag, that would cause problems:

    sHTML = sHTML.Replace("xmlns:asp=\"remove\"", "");
    sHTML = sHTML.Replace("xmlns:cc1=\"remove\"", "");

Then, I add in the “Register” tag necessary for the user control that contains the GoView.

    sHTML = "<%@ Register Src=\"~/ctrlChartFlow.ascx\" TagName=\"FlowChart\" TagPrefix=\"cc1\" %>" + sHTML;

Then I continue on with the creation of the page content:

        hldrItem.Controls.Clear(); //hldrItem is the PlaceHolder control for this page's content
        StringWriter sw2 = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw2);
        Control data = Page.ParseControl(sHTML); //here is where the user control's GoView creation code is called.

I hope someone finds this information useful. I think this is a really powerful way to have template-based functionality that can use the (wonderful) GoView diagrams within the pages.