XSLT use blank lines

CassianS

New Member
I have the following XML:\[code\]<node><mtype>code</mtype><mtext><script> // a Javascript example alert("Hello World"); </script></mtext></node>\[/code\]The same text in HTML would be written as follows:\[code\]<pre><code><script> // a Javascript example alert("Hello World"); </script></code></pre>\[/code\]We can see that the actual text is HTML encoded, which is fine. What I want to do next is use the following XSLT to represent the above mtext as the \[code\] element in Word XML (with a specific style).\[code\]<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" > <xsl:template match="/"> <xsl:for-each select="/node"> <xsl:if test="mtype = 'code'"> <w:p> <w:pPr><w:jc w:val="left" /></w:pPr> <!--<xsl:text select="mtext/node()"/>--> <w:r><w:t><xsl:value-of select="mtext/node()" disable-output-escaping="yes"/></w:t></w:r> </w:p> </xsl:if> </xsl:for-each> </xsl:template></xsl:stylesheet>\[/code\]If I run the XLST agains the defined XML I get the following:$ xsltproc code.xslt code.xml<?xml version="1.0"?><w:p xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"><w:pPr><w:jc w:val="left"/></w:pPr><w:r><w:t><script> // a Javascript example alert("Hello World"); </script></w:t></w:r></w:p>\[/code\]This isn't what I would like to achieve. The first thing are the actual special characters and the more important thing are the new lines that are stipped. Whatever I use in the element is visible in one line only, but my text has multiple lines, which is why I also need multiple lines.I've heard that I could use or , but I wasn't able to produce the XML that would actually create the multiline sections in Microsoft Word.Any ideas are welcome.Thanks
 
Back
Top