Line break in XSLT…sounds simple. When I created a XSLT for generating Microsoft Excel files I couldn’t understand why I couldn’t get line breaks. I tried inserting vbCrLf in the XSLT (using ASP) and inserting with XSLT (#13;). Nothing worked.
I posted a question on Expert Exchange and got an answer from someone who had used indent=”yes” in XSLT output when using method=”xml”. That worked fine when used with my Excelt XSLT file.
But when I was going to make a CSV export using XSLT, the same formula didn’t work. After some googling and testing I found this solution: Use method=”text” and indent=”yes” in xsl:output. Use xsl text and put a line break (#x0D;) and use xml:space=”preserve”.
Note the key here is xml:space=”preserve”. Without it won’t work. It only worked if I added some text before the line break. But obviously, in a CSV, I don’t wont test at the end of the line.
Arghh..How can i post html/xml code in my blog? I have used the CODE tag earlier when posting ASP and Javascript code. But doesn’t work with XML, it doesn’t show up in the post.