Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xml

boolean

xsd

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!

like image 266
Soichi Hayashi Avatar asked Aug 20 '09 20:08

Soichi Hayashi


People also ask

How do you represent a boolean in XML?

Syntax of XML boolean xml version="1.0" encoding="utf-8"?> Following is a boolean declaration in schemas. The value of a boolean is an Integer value whose values are '0' and '1', representing logical yes or no.

What is minOccurs in XSD?

The minOccurs attribute specifies the minimum number of times that the element can occur. It can have a value of 0 or any positive integer. The maxOccurs attribute specifies the maximum number of times that the element can occur.

What is meant by XSD?

An XML schema definition (XSD), is a framework document that defines the rules and constraints for XML documents. An XSD formally describes the elements in an XML document and can be used to validate the contents of the XML document to make sure that it adheres to the rules of the XSD.

What is Xsd anyType?

xsd:anyType is a type, like xsd:integer (though xsd:anyType is special in that it can act as a simple or complex type, and it places essentially no restrictions on the tree that it validates -- think of it loosely as the Schema language's analog of java. lang. Object).

Is Boolean TRUE or false in 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}.

What is the value space of Xs Boolean in XML?

The value space of xs:boolean is “true” and “false,” and its lexical space accepts true, false, and also “1” (for true) and “0” (for false). This datatype cannot be localized—for instance, to accept “vrai” and “faux” instead of “true” and “false”. Get XML Schema now with the O’Reilly learning platform.

What does xsd=boolean mean in xmllint?

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?

Is true Boolean valid in SQL?

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


1 Answers

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.

like image 121
Cheeso Avatar answered Oct 07 '22 16:10

Cheeso