86899

Dynamic XSL file

Question:

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?

Answer1:

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.

Recommend

  • Xsl v.2 won't work in Visual Studio 2013
  • using java to get xsl message
  • xsl data attribute not getting value showirorng > er
  • Excel macro -Split comma separated entries to new rows
  • Three Js Object3D Button Group Detect Single Object Click While Mouse Movement Causes Object3D Butto
  • jParallax trouble
  • Symfony2 redirect to https route fails (uses wrong port)
  • PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea
  • Is there a way to call library thread-local init/cleanup on thread creation/destruction?
  • What is this strange character in chrome's resource css viewer?
  • Making header act like google chrome mobile app address bar
  • Is there any way to call saveCurrentTurnWithMatchData without sending a push notification?
  • unable to get jsonEncode in magento2
  • Angular2 - Template reference inside NgSwitch
  • Dart - Isolate Cross Window Communication
  • Rest Services conventions
  • How can I replace the server in Web Component Tester
  • How to set elevation color?
  • Best way to dynamically load an xml configuration file into a Flex4/Flash movie at runtime?
  • Selenium to click on a javascript button corresponding to a text
  • Automatically associate new Sonar project with custom quality profile and quality gate
  • How can I speed up CURL tasks?
  • htaccess add www if not subdomain, if subdomain remove www
  • HTTP/2 streams vs HTTP/1.1 connections
  • PHP buffered output depending on server setting?
  • MVC3 Razor - ListBox pre-select not working
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • How to rebase a series of branches?
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Does CUDA 5 support STL or THRUST inside the device code?
  • jQuery tmpl and DataLink beta
  • Is there a mandatory requirement to switch app.yaml?
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • How do I configure my settings file to work with unit tests?
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • Is it possible to post an object from jquery to bottle.py?
  • UserPrincipal.Current returns apppool on IIS