tags:

views:

24

answers:

1

Hi,

is there a way to output the contents of a file in XSLT? Background: I have an xml file as input for a xslt stylesheet and generate an html file, which links to a css. So far so good.

Now I want to change my xslt in a way that the contents of the css is embedded within the html file (using a <style> element). However, I would like to keep the xslt and css separated, if possible.

Thanks! Nang.

+1  A: 

Yes, this can be done with XSLT 2.0

From http://www.w3.org/TR/xslt20/#unparsed-text

The unparsed-text function reads an external resource (for example, a file) and returns its contents as a string.

The $href argument must be a string in the form of a URI. The URI must contain no fragment identifier, and must identify a resource that can be read as text. If the URI is a relative URI, then it is resolved relative to the base URI from the static context.

Alejandro
+1: Cool. However, like so often: Is there also a way in XSLT1.0?
nang
@nang: XSLT 1.0 ony works with tree (allready parsed XML document, as example). So, if your CSS stylesheet can't be provided as a tree, there will be no solution in XSLT 1.0
Alejandro