i'm a little stucked with some XSLT issue.
I have some simple xml-files and the following stylesheet:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:param name="linked_content"/>
<xsl:template match="/">
<html>
<head>
<title>Chapter summary</title>
</head>
<body BGCOLOR="white">
<xsl:value-of select="$linked_content"></xsl:value-of>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The linked_content comes from a simple text file (e.g. summary.txt):
<p>
Consider this as a simple summary ^^
</p>
<h3>Part One</h3>
Now my question: How can i insert the HTML-Code from the text file as HTML code into the resulting html file. I know, the code above wont work, since i only get >, < in the resulting inserted text.
I'm not stuck to submit the content through a parameter. If their's a way to read the textfile from within the stylesheet, that would great!
Anyone an idea?
EDIT: Still stuck here. I tried a workaround reading the text file in java and setting the content as a parameter to the stylesheet. Sadly the
signs are being translated in the process to < and > ... thus, the html code is screwed. Is there a chance to force the stylesheet not to transform them?
Thx!
Are your html files well-formed?
You can try using 'copy-of' in your xsl.
<p><xsl:copy-of select="document('yourHtmlDoc.html')"/></p>
If you need specific items out of your html file, you can even set a path, given that your html is well-formed.
<xsl:copy-of select="document('yourHtmlDoc.html')/tagsNeeded"/>
You can use unparsed-text() function which can read external file in. Or if you know that the external file is a valid xml, you can use document() function as well. Both XSLT 2.0 functions however - i think.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With