XML 模式/验证:数据类型双精度的不同分隔符 [英] XML-schema/validation: different separator for datatype double

查看:10
本文介绍了XML 模式/验证:数据类型双精度的不同分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 xsd 文件中某些参数的数据类型从字符串更改为它们的真实类型,在本例中为双精度类型.现在我面临的问题是这里的逗号用作分隔符,而不是 w3 定义的点(http://www.w3.org/TR/xmlschema-2/#double) 在反序列化(C#,VS2008)期间导致错误.

I changed the datatype of some parameters within my xsd file from string to their real type, in this case double. now I'm facing the problem that around here the comma is used as a separator and not the point as defined by the w3 (http://www.w3.org/TR/xmlschema-2/#double) causing erros all over during deserialization (C#, VS2008).

我的问题:我可以使用 w3 模式进行验证,但双值使用不同的分隔符吗?

my question: Can I use the w3 schema for validation but with a different separator for double values?

感谢您的帮助

推荐答案

如果你想继续使用 XML Schema 简单类型,你不能这样做.十进制及其派生的类型被锁定为使用句点.正如你所说:这里的规范.

You cannot do that if you want to continue to use the XML Schema simple types. decimal and the types derived from it are locked down to using a period. As you say: the spec here.

如果要使用逗号作为分隔符,需要定义自己的简单类型,例如:

If you want to use a comma as a separator, you need to define your own simple type, for example:

<xs:simpleType name="MyDecimal">
  <xs:restriction base="xs:string">
    <xs:pattern value="d+(,d+)?"/>
  </xs:restriction>
</xs:simpleType>

不过,在您这样做之前,请小心;XML 是一种数据存储格式,而不是一种表示格式.您可能需要考虑是在加载后还是在 XSLT 转换等期间对其进行排序.

Before you do that, though, be careful; XML is a data storage format, not a presentation format. You might want to think about whether you sort this out after loading or during XSLT transformation, etc.

这篇关于XML 模式/验证:数据类型双精度的不同分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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