It is not that simple. I don't even think it is possible. Parsers are free to ignore whitespace they don't consider important or relevant, so the serializer simply generates whatever it can see in SAX or DOM.
Google for "XML Infoset" to read more on this subject.
Oleg
Steve Schwarz wrote:
Hi
This must be a FAQ but I can't seem to find the answer in the wiki or the archives...
How do I configure the XMLSerializer to preserve whitespace?
Here's my test case: Given an XML doc test.xml: <?xml version="1.0" encoding="UTF-8"?> <text>Some text with spaces</text>
I use an XSLT stylesheet text.xsl:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:preserve-space elements="text"/>
<xsl:template match="text"> <new-text><xsl:apply-templates/></new-text> </xsl:template> </xsl:stylesheet>
With this pipeline the extra whitespace is removed: <map:match pattern="text.xml"> <map:generate src="text.xml"/> <map:transform src="style/text.xsl"/> <map:serialize type="xml"/> </map:match>
Changing to the TextSerializer preserves the whitespace. Can I control this behavior for the XMLSerializer?
Thanks for any help, Steve
_________________________________________________________________
Get holiday tips for festive fun. http://special.msn.com/network/happyholidays.armx
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
