nang
nang

Reputation: 431

XSLT - Output contents of a file (embed contents of a .css in generated .html)

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.

Upvotes: 0

Views: 240

Answers (1)

user357812
user357812

Reputation:

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.

Upvotes: 1

Related Questions