I have made an xslt extention in VS2008 that lists out some data from a weather-service I have. The XPathNodeIterator that is beeing returned from getNextPeriod() shows me this data when I run it as a test in VS:
Yes, it does. I have tried both ways. Somewhere from where the result is returned from my class to the result i rendered in XSLT, it removes bothe the comma and/or the dot.
Well, still the same when I change to string() or number(). I'm starting to think that I have to be getting something wront in the middle. Somehow the dot is not getting to the xslt from my extention. Is there any other properties I could be getting wrong?
Glad you got it sorted :) Culture-info (and then especially decimal-separators and dates) can be a pain. Good to see my initial thought was the correct one ;)
Issues with custom XSLT extention
Hi, everyone!
I have made an xslt extention in VS2008 that lists out some data from a weather-service I have. The XPathNodeIterator that is beeing returned from getNextPeriod() shows me this data when I run it as a test in VS:
But when I use it in my XSLT file, it returns "29" as windspeed, and NOT "2,9" as it should...
<xsl:variable name="YRdata" select="KS.YR:getNextPeriod('http://www.someurl.com/somexml.xml')" />Anyone got any idea how to solve this?
Best regards,
ChristopherWB
Its probably because it expects a . (dot) as decimal-separator and not a , (comma) (which is usually the thousand-separator)
Try replacing the , with a . or change to the appropriate culture-settings.
HTH,
Peter
Hi, Peter!
I changed to a ".", but I still get the same "error". My assembly now outputs:
Does it write out the correct xml if you use this in your macro:
Maybe try something like
You could also try wrapping your output in a CDATA field:
Well, this is strange.. I added CDATA in my dll, but now it gives me this when I do a "copy-of":
Here is what my class returns when I set up a breakpoint in VS:
I have no idea where the "." or "," is going. This is so strange. Am I missing something here? Hehe.
Just for reference, here is my function i C#:
Strange indeed....
Does it return 43 in both situations? (with a dot and with a comma?)
Yes, it does. I have tried both ways. Somewhere from where the result is returned from my class to the result i rendered in XSLT, it removes bothe the comma and/or the dot.
How is this even possible? I changed my c# code to the following:
// Windspeed
XmlNode wind = xd.CreateElement("windspeed");
string strWindspeed = pd.Windspeed.ToString().Replace(",", ".");
wind.AppendChild(xd.CreateTextNode(strWindspeed + "."));
I even tried to change "CreateTextNode" to "CreateCDataSection", but it makes do difference.
now the output in debug is:
and the XSLT outputs:
Hi Christopher
Have you tried in your XSLT to specifiy the data type of the windspeed eg
or
Tom
Hi, Tom.
Well, still the same when I change to string() or number(). I'm starting to think that I have to be getting something wront in the middle. Somehow the dot is not getting to the xslt from my extention. Is there any other properties I could be getting wrong?
I am guess that in the XML file itself looks fine? eg 4.3?
Tom
Yes, my c# function that returns "return xd.CreateNavigator().Select(".");" produces the following result i Visual Studio XML Visualizer:
So the function absolutely returns the windspeed "4.3".
What C# type is the windspeed in your PeriodData class?
What happens if you just hardcode your C# method:
xd.LoadXml("<perioddata><windspeed>4.3</windspeed>.....</perioddata>");
Have you also tried debugging the method by attaching the the IIS process to see if the result might be different when calling it from your website?
I finally figured it out! After a good night sleep, black coffee and a new approach I changed my code to the following:
With good help from all of you, especially Peter and Morten, I attached a local IIS to VS and it all came clear.
Umb backend treets the culture different form frontend, so that's why I got conflicting results. Thanks to all of you!
Glad you got it sorted :) Culture-info (and then especially decimal-separators and dates) can be a pain. Good to see my initial thought was the correct one ;)
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.