动态 XSL 文件 [英] Dynamic XSL file

查看:20
本文介绍了动态 XSL 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 3 个 XSL 文件,其中包含指向 C:\templates\Test\file.pdf 之类的路径

I have 3 XSL files which have paths in them to something like C:\templates\Test\file.pdf

此路径并不总是相同的,而不是将其硬编码在 XSL 中,我希望它可以将路径 C:\templates\test\ 替换为标记 [BASEPATH] 和当我将 xsl 文件读入 XSLTransform 对象时(是的,我知道它已被弃用,我可能同时移至 XSLCompiledTransform),我希望将标记 [BASEPATH] 替换为web 文件夹(或 Server.MapPath("~") 在 .net 中看到的)

This path isn't always going to be the same and rather than having it hard coded in the XSL, I'd like it so that the path C:\templates\test\ is replaced with a tag [BASEPATH] and when I read in the xsl file into the XSLTransform object (yes I know it's been deprecated, I may move over to the XSLCompiledTransform at the same time), I'd like the tag [BASEPATH] to be replaced with the absolute file path of the web folder (or Server.MapPath("~") seeing as it is in .net)

我想我可以制作一个 XSLLoader aspx 页面,该页面通过查询字符串获取 XSL 文件的名称,然后通过 xml 内容类型返回 XSL 文件.当我尝试这个时,我得到了一个 503 错误,所以我不确定你是否可以将这样的 url 传递到 XSLTransform.Load 方法中.

I thought I may be able to make an XSLLoader aspx page which takes the name of the XSL file through the querystring and then returns the XSL file via xml content-type. When I try this, I get a 503 error though so I'm not sure if you can pass urls like this into the XSLTransform.Load method.

有什么想法可以做什么吗?

Any ideas what to do?

推荐答案

你看过 XSL 参数了吗?

Have you looked at XSL parameters?

<xsl:param name="basepath" select="'C:\Users\Graeme\'" />

<xsl:value-of select="document(concat($basepath, 'test.pdf'))" />

然后,大多数体面的 XSLT 引擎都有一种从外部设置根级别参数的方法.

Then, most decent XSLT engines have a way to set a root level parameter from outside.

这篇关于动态 XSL 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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