views:

93

answers:

1

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  A: 

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.

Boldewyn
Thanks, that's the way I've gone - have got the variable being used now, just need to figure out how to set the root level param from the C#.
Graeme
Great, that's it working now - thanks - to pass in arguments in C# to the deprecated XslTransform object, you do the following:XsltArgumentList xslArg = new XsltArgumentList();xslArg.AddParam("day","",day);xslArg.AddParam("year","",year);xslArg.AddParam("weather","",weather);XslTransform xslt = new XslTransform();xslt.Load(stylesheet);XPathDocument xpathdocument = new XPathDocument(filename);XmlTextWriter writer = new XmlTextWriter("priceClassExample.html",null);xslt.Transform(xpathdocument, xslArg, writer);writer.Close();
Graeme