Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
854 views
in Technique[技术] by (71.8m points)

xml - xsd:boolean element type accept "true" but not "True". How can I make it accept it?

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="xs:boolean" />

When I run xmllint, I get error messages that says

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

When I change the XML to

<Active>true</Active>

Then the error message disappears.

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.

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You cannot.

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}. 

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...