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

Function xmlGetBooleanProp

ThirdParty/libxml2/vtklibxml2/xmlschemas.c:6152–6184  ·  view source on GitHub ↗

* xmlGetBooleanProp: * @ctxt: a schema validation context * @node: a subtree containing XML Schema information * @name: the attribute name * @def: the default value * * Evaluate if a boolean property is set * * Returns the default if not found, 0 if found to be false, * 1 if found to be true */

Source from the content-addressed store, hash-verified

6150 * 1 if found to be true
6151 */
6152static int
6153xmlGetBooleanProp(xmlSchemaParserCtxtPtr ctxt,
6154 xmlNodePtr node,
6155 const char *name, int def)
6156{
6157 const xmlChar *val;
6158
6159 val = xmlSchemaGetProp(ctxt, node, name);
6160 if (val == NULL)
6161 return (def);
6162 /*
6163 * 3.2.2.1 Lexical representation
6164 * An instance of a datatype that is defined as `boolean`
6165 * can have the following legal literals {true, false, 1, 0}.
6166 */
6167 if (xmlStrEqual(val, BAD_CAST "true"))
6168 def = 1;
6169 else if (xmlStrEqual(val, BAD_CAST "false"))
6170 def = 0;
6171 else if (xmlStrEqual(val, BAD_CAST "1"))
6172 def = 1;
6173 else if (xmlStrEqual(val, BAD_CAST "0"))
6174 def = 0;
6175 else {
6176 xmlSchemaPSimpleTypeErr(ctxt,
6177 XML_SCHEMAP_INVALID_BOOLEAN,
6178 NULL,
6179 (xmlNodePtr) xmlSchemaGetPropNode(node, name),
6180 xmlSchemaGetBuiltInType(XML_SCHEMAS_BOOLEAN),
6181 NULL, val, NULL, NULL, NULL);
6182 }
6183 return (def);
6184}
6185
6186/************************************************************************
6187 * *

Callers 2

xmlSchemaParseElementFunction · 0.85

Calls 4

xmlSchemaGetPropFunction · 0.85
xmlStrEqualFunction · 0.85
xmlSchemaGetPropNodeFunction · 0.85
xmlSchemaGetBuiltInTypeFunction · 0.85

Tested by

no test coverage detected