Here's the code I'm using. BTW, this is a XML to XML transformation. I'm converting it to a string because I'm using WinHTTP to send it to another site for processing into their db. I'm building this in
VB.NET, VS 2003.
'Get the data
dsBooking = GetDataSet(lngJailBookingID)
'Load the data from the DataSet into a string in an XML format
strXML = dsBooking.GetXml.ToString
'Send the XML doc to the function to get it processed through the XSLT
strXML = TransformDocument(strXML)
' Initiate a reader to load the XML string that is passed
' to this function.
Dim myXmlReader As XmlReader = Nothing
Dim myXmlDataDocument As New XmlDataDocument
' Load the XML string into the reader
myXmlDataDocument.LoadXml(strXML)
' Create an XPath object, load the XML Document into it
Dim myXPathNavigator As XPathNavigator = myXmlDataDocument.CreateNavigator()
' And run it through the Transformer
myXmlReader = m_XslTransform.Transform(myXPathNavigator, Nothing)
' Create a new XML Document, load the reader into it,
' and save it off to a string
Dim XMLTartget As New XmlDocument
XMLTartget.Load(myXmlReader)
strXML = XMLTartget.OuterXml
When I inspect the strXML string variable at this point, most (of all the fields, the Comments field doesn't get spaces stripped out) of the whitespaces are stripped out. For example, there is a field that should have the value "sentance completed" but ends up "sentancecompleted". Also, in the XSLT, I add a namespace to an element. It should show up as <absi:booking xmlns:absi="http://www.absi.org/absi/xml/v0.40">, but instead shows up as <absi:bookingxmlns:absi="http://www.absi.org/absi/xml/v0.40">. And, of course, is no longer well-formed XML because there are 2 colons in the name.
If I inspect the string BEFORE running the transformation, all the white spaces are there.