Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 15th, 2003, 11:27 AM
Registered User
 
Join Date: Jun 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to dimondwoof
Default Where are my whitespaces going?

I've got an XML document that I have created from a DataSet. I take
the XML and run it through an XSLT to make a few minor
modifications. I've got a couple of fields where the value is
something like "sentence complete". After the transformation, the
field now reads "sentencecomplete". Can anyone tell me how to
preserve the white spaces in my XML document?
 
Old July 16th, 2003, 12:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti
Default

Show us your code please.
It will be easier to discuss then.
 
Old July 16th, 2003, 10:54 AM
Registered User
 
Join Date: Jun 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to dimondwoof
Default

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.
 
Old July 17th, 2003, 08:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti
Default

As you say, before running the transformation all the whitespaces are there.
Therefore, whitespaces are stripped out due to transformation instead of VB code. In that case we have to look at the stylesheet (and of course at the generated XML source from the DB). Without seeing it it's impossible to find the reason of such misfunctionality.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I keep leading and trailing whitespaces? 2BOrNot2B XSLT 2 October 31st, 2008 11:35 AM
Removing whitespaces with certain conditions trishla XSLT 16 October 4th, 2007 05:35 PM
preserving whitespaces in attribute values? kaps77 XSLT 7 August 13th, 2007 11:48 AM
Preserved leading and tailing whitespaces problem ivan603 XML 0 February 7th, 2006 10:18 PM
checking for any whitespaces furia_cross Javascript How-To 1 September 7th, 2005 05:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.