如何让我的XSLT转换与大型XML一起使用?

时间:2014-05-12 06:10:20

标签: xslt transformation httpmodule

我编写了代码来过滤掉作为Web服务增强功能的一部分引入的新XML元素。转换似乎适用于小型XML,但只要我增加它的大小就停止工作。使用SoapUI,它只返回一个空白响应。

有人可以帮忙吗?我是否需要更改下面的代码来处理大型XML?

    public void Dispose()
    {
        //clean-up code here.
    }

    public void Init(HttpApplication context)
    {
        context.BeginRequest += new EventHandler(context_BeginRequest);
        context.PreRequestHandlerExecute += new EventHandler       (context_PreRequestHandlerExecute);
    }

    void context_PreRequestHandlerExecute(object sender, EventArgs e)
    {
        HttpApplication app = (HttpApplication)sender;
        State state = (State)app.Context.Items["VersionManagerState"];
        if (state.ProcessRequest)
        {
            Stream xslres = Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Concat("TestService.VersionManager.",state.Version, ".xslt"));
            if (xslres != null)
            {
                state.Xsl = new XslCompiledTransform();
                state.Xsl.Load(XmlReader.Create(xslres));
                app.Context.Response.Filter = new OutputFilterStream(state, app.Context.Response.Filter);
            }
        }

    }

    void context_BeginRequest(object sender, EventArgs e)
    {
        HttpApplication app = (HttpApplication)sender;
        State state = new State();
        app.Context.Items["VersionManagerState"] = state;

        if (app.Context.Request.Url.AbsolutePath.EndsWith(".asmx") && app.Request.RequestType == "POST")
        {
            state.ProcessRequest = true;
            app.Context.Request.Filter = new InputFilterStream(state, app.Context.Request.Filter);
        }
    }

0 个答案:

没有答案