* 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 */
| 6150 | * 1 if found to be true |
| 6151 | */ |
| 6152 | static int |
| 6153 | xmlGetBooleanProp(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 | * * |
no test coverage detected