XSD:布尔元素类型同意]真QUOT;但不"真&QUOT ;.我怎样才能使它接受吗? [英] xsd:boolean element type accept "true" but not "True". How can I make it accept it?

查看:217
本文介绍了XSD:布尔元素类型同意]真QUOT;但不"真&QUOT ;.我怎样才能使它接受吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用xmllint --schema选项来验证我的XML看起来像这样

I am using xmllint --schema option to validate my XML that looks like this

<XML>
<Active>True</Active>
</XML>

在我的模式文件,我有如下描述有源元件行。

In my schema file, I have following line that describes Active element.

<xsd:element name="Active" type="xsd:boolean" />

当我运行xmllint,我得到错误信息,说

When I run xmllint, I get error messages that says

/tmp/schema_validation.xml:73:元素
  活动:模式有效性的错误:
  元素'活动':'真'是不是
  原子类型的有效值
  XS:布尔'。

/tmp/schema_validation.xml:73: element Active: Schemas validity error : Element 'Active': 'True' is not a valid value of the atomic type 'xs:boolean'.

当我改变的XML

<Active>true</Active>

然后错误信息消失。

Then the error message disappears.

所以,它看起来像XSD:布尔意味着它的全部小写真/假,而不是真/假,以xmllint ..我的问题是,如何才能让xmllint接受真为XSD:布尔类型?还是有不同的工具,我可以使用,这将验证此XML?更改XML或模式是不是我在这一点上的选择。

So, it looks like xsd:boolean means it's all lowercase "true/false" but not "True/False" to xmllint.. My question is, how can I make xmllint to accept "True" for xsd:boolean type? Or is there different tools that I can use that will validate this XML? Changing the XML or schema is not my option at this point.

谢谢!

推荐答案

您不能。

按照 XML Schema规范,一个布尔是真实是无效的:

According to the XML Schema specification, a boolean is true or false. True is not valid:



  3.2.2.1 Lexical representation
  An instance of a datatype that is defined as ·boolean· can have the 
  following legal literals {true, false, 1, 0}. 

  3.2.2.2 Canonical representation
  The canonical representation for boolean is the set of 
  literals {true, false}. 

如果您使用的是真正的验证工具对XML Schema标准,那么你就无法说服其接受真正的布尔值。

If the tool you are using truly validates against the XML Schema standard, then you cannot convince it to accept True for a boolean.

这篇关于XSD:布尔元素类型同意]真QUOT;但不&QUOT;真&QUOT ;.我怎样才能使它接受吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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