Question

I've got several XSL-Transformations which have common code. The common code consists of functions built with exslt's function-extension. Now I want to outsource these functions into a library, in order to make them more maintainable.

The Transformations are compiled as into an executable as resources, and read from memory when they are needed. I would like to keep it that way, and use the same mechanism for the library. The reason is, that the executable will always know where they are and no path configuration is needed.
Now my question is: How do I import an external stylesheet, which is given as a string, and is not available as file?

One way to solve the problem is to write out the stylesheets into temporary files and inlude these. The problem there would be, that the file name of the temporary file will change every time, so I would have to manipulate the main transformation to include the tempfiles name. Paramaters don't work in this case.

Any ideas on how to solve this problem, which should be trivial?

Environment: libxml2, libxslt (xslt 1.0), exslt extension, Linux.

Thanks,
Jost

Was it helpful?

Solution

Thanks Dimitre and Michael for pushing me in the right direction.

The URIResolver-Mechanism is called "catalog" in libxml, and works straight forward (for simple use cases):

  1. Include "libxml/catalog.h"
  2. Initialize the system catalog, using the function "xmlInitializeCatalog"
  3. Add resolution mappings using "xmlCatalogAdd"
  4. Clean up, using "xmlCatalogCleanup"

Thanks for your hints,
Jost

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top