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

Function xmlSchemaValAtomicType

ThirdParty/libxml2/vtklibxml2/xmlschemastypes.c:2441–3599  ·  view source on GitHub ↗

* xmlSchemaValAtomicType: * @type: the predefined type * @value: the value to check * @val: the return computed value * @node: the node containing the value * flags: flags to control the validation * * Check that a value conforms to the lexical space of the atomic type. * if true a value is computed and returned in @val. * This checks the value space for list types as well (IDREFS, NMT

Source from the content-addressed store, hash-verified

2439 * and -1 in case of internal or API error.
2440 */
2441static int
2442xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
2443 xmlSchemaValPtr * val, xmlNodePtr node, int flags,
2444 xmlSchemaWhitespaceValueType ws,
2445 int normOnTheFly, int applyNorm, int createStringValue)
2446{
2447 xmlSchemaValPtr v;
2448 xmlChar *norm = NULL;
2449 int ret = 0;
2450
2451 if ((xmlSchemaTypesInitialized == 0) &&
2452 (xmlSchemaInitTypes() < 0))
2453 return (-1);
2454 if (type == NULL)
2455 return (-1);
2456
2457 /*
2458 * validating a non existent text node is similar to validating
2459 * an empty one.
2460 */
2461 if (value == NULL)
2462 value = BAD_CAST "";
2463
2464 if (val != NULL)
2465 *val = NULL;
2466 if ((flags == 0) && (value != NULL)) {
2467
2468 if ((type->builtInType != XML_SCHEMAS_STRING) &&
2469 (type->builtInType != XML_SCHEMAS_ANYTYPE) &&
2470 (type->builtInType != XML_SCHEMAS_ANYSIMPLETYPE)) {
2471 if (type->builtInType == XML_SCHEMAS_NORMSTRING)
2472 norm = xmlSchemaWhiteSpaceReplace(value);
2473 else
2474 norm = xmlSchemaCollapseString(value);
2475 if (norm != NULL)
2476 value = norm;
2477 }
2478 }
2479
2480 switch (type->builtInType) {
2481 case XML_SCHEMAS_UNKNOWN:
2482 goto error;
2483 case XML_SCHEMAS_ANYTYPE:
2484 case XML_SCHEMAS_ANYSIMPLETYPE:
2485 if ((createStringValue) && (val != NULL)) {
2486 v = xmlSchemaNewValue(XML_SCHEMAS_ANYSIMPLETYPE);
2487 if (v != NULL) {
2488 v->value.str = xmlStrdup(value);
2489 *val = v;
2490 } else {
2491 goto error;
2492 }
2493 }
2494 goto return0;
2495 case XML_SCHEMAS_STRING:
2496 if (! normOnTheFly) {
2497 const xmlChar *cur = value;
2498

Callers 2

Calls 15

xmlSchemaInitTypesFunction · 0.85
xmlSchemaCollapseStringFunction · 0.85
xmlSchemaNewValueFunction · 0.85
xmlStrdupFunction · 0.85
xmlSchemaValidateDatesFunction · 0.85
xmlSchemaFreeValueFunction · 0.85
xmlValidateNMTokenFunction · 0.85
xmlValidateNameFunction · 0.85

Tested by

no test coverage detected