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

Function xmlSchemaPValAttrNodeValue

ThirdParty/libxml2/vtklibxml2/xmlschemas.c:6234–6288  ·  view source on GitHub ↗

* xmlSchemaPValAttrNodeValue: * * @pctxt: a schema parser context * @ownerItem: the schema object owner if existent * @attr: the schema attribute node being validated * @value: the value * @type: the built-in type to be validated against * * Validates a value against the given built-in type. * This one is intended to be used internally for validation * of schema attribute values during

Source from the content-addressed store, hash-verified

6232 * number otherwise and -1 in case of an internal or API error.
6233 */
6234static int
6235xmlSchemaPValAttrNodeValue(xmlSchemaParserCtxtPtr pctxt,
6236 xmlSchemaBasicItemPtr ownerItem,
6237 xmlAttrPtr attr,
6238 const xmlChar *value,
6239 xmlSchemaTypePtr type)
6240{
6241
6242 int ret = 0;
6243
6244 /*
6245 * NOTE: Should we move this to xmlschematypes.c? Hmm, but this
6246 * one is really meant to be used internally, so better not.
6247 */
6248 if ((pctxt == NULL) || (type == NULL) || (attr == NULL))
6249 return (-1);
6250 if (type->type != XML_SCHEMA_TYPE_BASIC) {
6251 PERROR_INT("xmlSchemaPValAttrNodeValue",
6252 "the given type is not a built-in type");
6253 return (-1);
6254 }
6255 switch (type->builtInType) {
6256 case XML_SCHEMAS_NCNAME:
6257 case XML_SCHEMAS_QNAME:
6258 case XML_SCHEMAS_ANYURI:
6259 case XML_SCHEMAS_TOKEN:
6260 case XML_SCHEMAS_LANGUAGE:
6261 ret = xmlSchemaValPredefTypeNode(type, value, NULL,
6262 (xmlNodePtr) attr);
6263 break;
6264 default: {
6265 PERROR_INT("xmlSchemaPValAttrNodeValue",
6266 "validation using the given type is not supported while "
6267 "parsing a schema");
6268 return (-1);
6269 }
6270 }
6271 /*
6272 * TODO: Should we use the S4S error codes instead?
6273 */
6274 if (ret < 0) {
6275 PERROR_INT("xmlSchemaPValAttrNodeValue",
6276 "failed to validate a schema attribute value");
6277 return (-1);
6278 } else if (ret > 0) {
6279 if (WXS_IS_LIST(type))
6280 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
6281 else
6282 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
6283 xmlSchemaPSimpleTypeErr(pctxt,
6284 ret, ownerItem, (xmlNodePtr) attr,
6285 type, NULL, value, NULL, NULL, NULL);
6286 }
6287 return (ret);
6288}
6289
6290/**
6291 * xmlSchemaPValAttrNode:

Callers 2

xmlSchemaPValAttrNodeFunction · 0.85
xmlSchemaParseWildcardNsFunction · 0.85

Calls 1

Tested by

no test coverage detected