xsl-list
[Top] [All Lists]

Re: [xsl] How to prevent stripping of EOL/CR chars at the end of lines?

2009-08-12 07:05:16
Ben Stover schrieb:
When I apply an xslt script onto an source XML file (under WinXP) then
everything is fine except the fact that the result XML file is on one
single, very, very long line.

How to I prevent stripping of EOL/CR line end chars?

The source file contains them, the XSLT script contains them. So the
reuslt file should contains them as well.

Moreover the prepended blanks/tabs at the beginning of a line should
NOT stripped as well.

Try adding xml:space="preserve" where you think it is necessary.

In addition, are you using MSXML? If so, be aware that whitespace is
stripped by default for MSDOM. So in order to preserve whitespace on
your input tree and your XSLT source tree, you need to instruct MSXML
not to strip whitespace as illustrated in the following VBScript.

# more /t2 msdom-whitespace.vbs
Option Explicit

Function GetDom( filename)
  Set GetDom = CreateObject("MSXML2.DOMDocument.6.0")
  GetDom.async = false
  GetDom.preserveWhiteSpace = true
  GetDom.load( filename)
End Function

Dim xml
Set xml = GetDom("urmel.xml")
If xml.parseError.errorCode <> 0 Then
  WScript.Echo "Fehler XML: " + xml.parseError.reason
End If

Dim xsl
Set xsl = GetDom("urmel.xsl")
If xsl.parseError.errorCode <> 0 Then
  WScript.Echo "Fehler XSL: " + xsl.parseError.reason
End If

WScript.Echo xml.transformNode(xsl.documentElement)

--
Michael Ludwig

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>