通过XML/XSLT流程流式处理Blob图片 [英] Stream a blob image through a XML / XSLT process

查看:95
本文介绍了通过XML/XSLT流程流式处理Blob图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在C#ASP.NET项目中使用XML/XSLT技术显示数据库中的图像.这是显示我如何使用XSLT的代码示例.

I am trying to display an image from database with a XML / XSLT technology in a C# ASP.NET project. Here's a code sample showing how I use XSLT.

/// <summary>
/// Get HTML form xml 
/// </summary>
/// <param name="xsltPath">the path to the xsl stylesheet</param>
/// <param name="xml">contain the xml</param>
/// <returns>the html</returns>
public string GetHtmlFrom_XML_XSL(string xsltPath, string xml) 
{
    xml = this.CleanString(xml);
    MemoryStream stream = new MemoryStream(ASCIIEncoding.UTF8.GetBytes(xml));
    XPathDocument document = new XPathDocument(stream);
    StringWriter writer = new StringWriter();
    XslCompiledTransform transform = new XslCompiledTransform();
    transform.Load(xsltPath);
    transform.Transform(document, null, writer);
    return writer.ToString();
}

我现在必须在SQL Server中显示来自Blob的图像...我不知道如何执行此操作.我试图像这样在xsl工作表中使用.ashx处理程序:

I now have to display an image from a blob in a SQL server... I have no clue how to do that. I tried to use a .ashx handler within the xsl sheet like that :

    <img height="150" width="120">
      <xsl:attribute name="src">~/ImageHandler.ashx?atoContactId=<xsl:value-of select="owner/picture" /></xsl:attribute>
      <xsl:attribute name="alt">
        <xsl:value-of select="owner/name" />
      </xsl:attribute>
    </img>

但是,当然,XSLT生成的html是在浏览器中流式传输的,并且src属性的请求HTTP不会被处理.这导致图像为空(红叉).

But of course, the html produced by the XSLT is streamed in the browser, and the request HTTP of the src attribute is not processed. That's resulting an empty image (red cross).

是否有任何工作方式,或者我应该忘记显示斑点图像的XML/XSLT?

Is there any way of working or i should forget XML / XSLT for the displaying of a blob image ?

推荐答案

此处是答案,如何从SQL Server读取Blob.

Here and here are the answers, how to read blobs from sql server.

通常,您必须首先从sql server中读取图像.然后,您可以使用任何要在页面上显示的技术.

In general, you have to read image from sql server first. Then you may use whatever technology you want to display it on page.

这篇关于通过XML/XSLT流程流式处理Blob图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆