Dynamic XSL file

别来无恙 提交于 2019-12-25 02:57:45

问题


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

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)

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?


回答1:


Have you looked at XSL parameters?

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

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

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



来源:https://stackoverflow.com/questions/1707674/dynamic-xsl-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!