MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlSchemaPGetBoolNodeValue

Function xmlSchemaPGetBoolNodeValue

ThirdParty/libxml2/vtklibxml2/xmlschemas.c:6105–6138  ·  view source on GitHub ↗

* xmlSchemaPGetBoolNodeValue: * @ctxt: a schema validation context * @ownerItem: the owner as a schema item * @node: the node holding the value * * Converts a boolean string value into 1 or 0. * * Returns 0 or 1. */

Source from the content-addressed store, hash-verified

6103 * Returns 0 or 1.
6104 */
6105static int
6106xmlSchemaPGetBoolNodeValue(xmlSchemaParserCtxtPtr ctxt,
6107 xmlSchemaBasicItemPtr ownerItem,
6108 xmlNodePtr node)
6109{
6110 xmlChar *value = NULL;
6111 int res = 0;
6112
6113 value = xmlNodeGetContent(node);
6114 /*
6115 * 3.2.2.1 Lexical representation
6116 * An instance of a datatype that is defined as `boolean`
6117 * can have the following legal literals {true, false, 1, 0}.
6118 */
6119 if (xmlStrEqual(BAD_CAST value, BAD_CAST "true"))
6120 res = 1;
6121 else if (xmlStrEqual(BAD_CAST value, BAD_CAST "false"))
6122 res = 0;
6123 else if (xmlStrEqual(BAD_CAST value, BAD_CAST "1"))
6124 res = 1;
6125 else if (xmlStrEqual(BAD_CAST value, BAD_CAST "0"))
6126 res = 0;
6127 else {
6128 xmlSchemaPSimpleTypeErr(ctxt,
6129 XML_SCHEMAP_INVALID_BOOLEAN,
6130 ownerItem, node,
6131 xmlSchemaGetBuiltInType(XML_SCHEMAS_BOOLEAN),
6132 NULL, BAD_CAST value,
6133 NULL, NULL, NULL);
6134 }
6135 if (value != NULL)
6136 xmlFree(value);
6137 return (res);
6138}
6139
6140/**
6141 * xmlGetBooleanProp:

Callers 1

Calls 3

xmlNodeGetContentFunction · 0.85
xmlStrEqualFunction · 0.85
xmlSchemaGetBuiltInTypeFunction · 0.85

Tested by

no test coverage detected