Monday, February 21, 2011

Can XSLT be used to form a plain txt file, not just html?

Lately I have become a huge fan of XSL, XPath and XML, but I've only used it to format outputted html documents, with a head and body sections.

I was wondering if its possible to use good of XSLT to format other types of documents, like plain txt?

From stackoverflow
  • Yes of course - just use

    <xsl:output method="text" indent="yes"/>
    

    instead of

    <xsl:output method="html" indent="yes"/>
    

    Marc

    UPDATE: whitespace and formatting text exactly as needed are always a bit tricky in XSLT. Check out some of those references:

    JL : Thanks Marc, will line breaks occur naturally, same as in the template?
    Pavel Minaev : If you use direct element constructors, whitespace within will be collapsed by the usual rules. `` is space-preserving, and lets you control output at character precision, however.

0 comments:

Post a Comment