NET中的XSL转换? [英] XSL Transform in .NET?

查看:58
本文介绍了NET中的XSL转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用xsl样式表转换xml文件(将iPod库plist转换为我的应用程序可以处理的xml代码).我已经使用Xsl.XslCompiledTransform对象成功地在VB.NET中应用了转换,这产生了一个可以成功用于我的应用程序的xml文件.

我的问题是,返回到新的xml文件的所有值都是字符串值,我要求数字为数字,字符串为字符串.我在我的xslt文件中对此值进行了测试:

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:choose>
  <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>
</xsl:choose>


这样可以成功找到数字格式的值,但是生成的xml文件仍然返回所有字符串值.有人有指针吗?我几乎没有xml知识.

预先感谢.


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.

推荐答案

XML是基于文本的,所有内容都是字符串.
XML is text based, everything is a string.


如果您有XML模式文件( * .xsd),对于生成的XML,您可以使用VS工具生成尊重类型的类.尽管XML文件实际上只是一个文本图块,但使用该模式以及一种序列化和反序列化机制,可以根据该模式中定义的内容输入类型化的信息.

请在此处查看此工具: http://xsd2code.codeplex.com/ [
If you have an XML schema file (*.xsd) for your generated XML you can use VS tools to generate classes that respect the type. Eventhough the XML file is infact only a text tile, using the schema and a serializing and deserializing mechanism one can have typed information according to what is defined in the schema.

Please have a look at this tool here: http://xsd2code.codeplex.com/[^]. It does exactly what you''re looking for.

Best Regards,

—MRB


这篇关于NET中的XSL转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆