File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -272,5 +272,22 @@ public void ConvertJsonToXmlString()
272
272
var result = Frends . Xml . Xml . ConvertJsonToXml ( new JsonToXmlInput ( ) { Json = json } ) ;
273
273
Assert . That ( result , Does . Contain ( "<url>http://www.google.com</url>" ) ) ;
274
274
}
275
+
276
+ [ Test ]
277
+ public void WhiteSpaceIsPreserved ( )
278
+ {
279
+ const string transformXml = @"<?xml version=""1.0""?>
280
+ <test></test>" ;
281
+
282
+ const string xslt = @"<?xml version=""1.0""?>
283
+ <xsl:stylesheet xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" version=""2.0"">
284
+ <xsl:template match=""test"">
285
+ <xsl:value-of select="".""/>
286
+ </xsl:template>
287
+ </xsl:stylesheet>" ;
288
+
289
+ var res = Frends . Xml . Xml . Transform ( new TransformInput ( ) { Xml = transformXml , Xslt = xslt } ) ;
290
+ Assert . That ( res , Is . EqualTo ( @"<?xml version=""1.0"" encoding=""UTF-8""?>" ) ) ; // no newline caused by empty tag
291
+ }
275
292
}
276
293
}
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ public static string Transform(TransformInput input)
69
69
{
70
70
//XmlDocument always produces MemoryStream where its encoding matches the input XML's declaration
71
71
XmlDocument xmldoc = new XmlDocument ( ) ;
72
+ xmldoc . PreserveWhitespace = true ;
72
73
xmldoc . LoadXml ( input . Xml ) ;
73
74
xmldoc . Save ( inputStream ) ;
74
75
xmldoc = null ;
You can’t perform that action at this time.
0 commit comments