Reputation: 4881
I am using XSLT to transform a XML file in to a HTML file.
I would like to insert a plain text file in to the HTML as part of the transform.
Is this possible?
Upvotes: 10
Views: 6131
Reputation: 4881
Well the solution that I ended up using was somewhat simpler than those suggested above. I used the following :
<xsl:variable name="input-text" as="xs:string" select="unparsed-text('../Input/pipehat.txt', 'iso-8859-1')"/>
to get the text into a variable then just output the variable in the appropriate place.
<xsl:value-of select="$input-text"/>
Upvotes: 3
Reputation: 96830
In addition to the options Matthijs Bierman mentioned, you can also pass the contents of the text file into the transform as an argument, if the environment you're working with supports this.
For instance, in .NET, a program that performs a transform can read a file into a string variable, add it as a parameter to an XsltArgumentList
object, and pass this object to the XslCompiledTransform
's Transform
method.
Upvotes: 0
Reputation: 1757
You have a few options:
<text></text>
tags, you may import it with the document()
function. This works in XSLT1.0, and does not require another programming language.unparsed-text()
.Upvotes: 8