Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: newLine issue when using XSLCompiledTransform.Transform()

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 5/14/2009 6:00:00 PM
Zest4Quest wrote:
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>     xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
> exclude-result-prefixes="msxsl"
>                 xmlns:ms="urn:schemas-microsoft-com:xslt"
>                 xmlns:dt="urn:schemas-microsoft-com:datatypes">
>   
>   <xsl:output method="text" indent="yes"/>
> 
>   <xsl:template match="/">
>     <xsl:text>{\rtf1{\fonttbl{\f0\fnil\fcharset0 
> Arial;}}\viewkind4\uc1\pard\lang1033\fs18</xsl:text>
>     <xsl:for-each select="Assessment/ObGyn">
>         <xsl:if test ="OBGYNNotes != ''">
>           <xsl:text> \line \b Additional  Information: \b0 </xsl:text>
>           <xsl:value-of select ="OBGYNNotes"/>
>         </xsl:if>      
>     </xsl:for-each>   
>     <xsl:text>}</xsl:text>
>   </xsl:template>
> </xsl:stylesheet>

When I take that stylesheet and use it with Visual Studio 2008 in a .NET 
3.5 application with the following code

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;

namespace ConsoleApplication568
{
     class Program
     {
         static void Main(string[] args)
         {
             string xml = @"<?xml version=""1.0"" 
encoding=""utf-16""?><Assessment
xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" >
<ObGyn>
<OBGYNNotes>a
b
c
d
e
</OBGYNNotes>
</ObGyn>
</Assessment>";

             XslCompiledTransform proc = new XslCompiledTransform();
             proc.Load(@"..\..\XSLTFile2.xslt");
             string result;
             using (StringWriter sw = new StringWriter())
             {
                 proc.Transform(new XPathDocument(new 
StringReader(xml)), null, sw);
                 result = sw.ToString();
                 sw.Close();
             }
             Console.WriteLine("Result is|{0}|", result);

         }
     }
}

it outputs

Result is|{\rtf1{\fonttbl{\f0\fnil\fcharset0
Arial;}}\viewkind4\uc1\pard\lang1033\fs18 \line \b Additional 
Information: \b0
a
b
c
d
e
}|

to the console so I don't see any missing line breaks.



-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent