Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSLT inserting a TXT file

Tags:

xml

xslt

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?

like image 627
BENBUN Coder Avatar asked Nov 04 '10 17:11

BENBUN Coder


People also ask

How do I write text in XSLT?

XSLT <xsl:text>The <xsl:text> element is used to write literal text to the output. Tip: This element may contain literal text, entity references, and #PCDATA.

How do I read a text file in XSLT?

If you can use XSLT 2.0 you could use unparsed-text() ... Text File (Do not use the text file as direct input to the XSLT.) ! ITEM_NAME Item value !


1 Answers

You have a few options:

  1. If you can surround the plain text in <text></text> tags, you may import it with the document() function. This works in XSLT1.0, and does not require another programming language.
  2. If you cannot modify the source file, but you do have XSLT2.0, then you may do it using unparsed-text().
  3. If you do not have XSLT2.0, but you are using Java, then you may be able to invoke a Java function. Microsoft platforms will probably offer similar functionality.
like image 50
Matthijs Bierman Avatar answered Sep 25 '22 19:09

Matthijs Bierman