Question

Locked

XSL Transform in .NET?

By Soundbomber ·
Hi,
I am using an xsl stylesheet to transform a xml file (an iPod library plist to xml code that my app can handle). I have succesfully applied the transform in VB.NET using an Xsl.XslCompiledTransform object, and this results in an xml file that I can successfully use with my app. My problem is this, all the values return to the new xml file are string values, I require the numbers to be numbers, strings to be strings. I havein my xslt file applied a test to the value thus:

xsl:when test="number(following-sibling::node()[1]) = following-sibling::node()[1]"
xsl:value-of select="number(following-sibling::node()[1])"/
/xsl:when
xsl:otherwise
xsl:value-of select="following-sibling::node()[1]"/
/xsl:otherwise

this successfully finds number formated values, but the resulting xml file still returns all string values. Does anyone have any pointers? I have virtually no xml knowledge.
Thanks in advance.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Answered

by Soundbomber In reply to XSL Transform in .NET?

OK so it seems that all xml attributes are returned as string values, so I will find another way round!

Collapse -

xml is text

by Tony Hopkinson In reply to XSL Transform in .NET?

, if you want to treat some of it as numbers, you have to convert it.

There are a few ways to do that.
You can serialise / deserialise to an object. Net will do that for you, though there are some limits and rules, and after simple structures a good bit of cacking about.

You can create a schema to describe the xml. That can be typed. Then you can either use it in code, or use the Data source wizrd thingy.

Last and almost certainly least you can hard code
Int32 MyNumber = Convert.ToInt32(SomeXmlNode.InnertText);

Given of course the node does contain a number, and of course the XmlNode isn't null....

If it's one off, you could get away with that but it's about as comfortable to reuse as someone else's suppository.

Collapse -

Thanks

by Soundbomber In reply to XSL Transform in .NET?

Thanks Tony, that has answered my question AND put a rather unpleasant picture in my head!!! :0

Back to Software Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums