extern double xmlXPathNINF;
#endif
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
typedef xmlSchemaValDuration *xmlSchemaValDurationPtr;
struct _xmlSchemaValDuration {
long mon; /* mon stores years also */
- long day;
+ long day;
double sec; /* sec stores min and hour also */
};
/************************************************************************
* *
- * Datatype error handlers *
+ * Datatype error handlers *
* *
************************************************************************/
/**
/************************************************************************
* *
- * Base types support *
+ * Base types support *
* *
************************************************************************/
}
ret->type = XML_SCHEMA_FACET_MINLENGTH;
ret->val = xmlSchemaNewValue(XML_SCHEMAS_NNINTEGER);
+ if (ret->val == NULL) {
+ xmlFree(ret);
+ return(NULL);
+ }
ret->val->value.decimal.lo = value;
return (ret);
}
* Initialize one primitive built-in type
*/
static xmlSchemaTypePtr
-xmlSchemaInitBasicType(const char *name, xmlSchemaValType type,
+xmlSchemaInitBasicType(const char *name, xmlSchemaValType type,
xmlSchemaTypePtr baseType) {
xmlSchemaTypePtr ret;
ret->name = (const xmlChar *)name;
ret->targetNamespace = XML_SCHEMAS_NAMESPACE_NAME;
ret->type = XML_SCHEMA_TYPE_BASIC;
- ret->baseType = baseType;
+ ret->baseType = baseType;
ret->contentType = XML_SCHEMA_CONTENT_BASIC;
/*
* Primitive types.
*/
- switch (type) {
- case XML_SCHEMAS_STRING:
- case XML_SCHEMAS_DECIMAL:
- case XML_SCHEMAS_DATE:
- case XML_SCHEMAS_DATETIME:
- case XML_SCHEMAS_TIME:
- case XML_SCHEMAS_GYEAR:
- case XML_SCHEMAS_GYEARMONTH:
- case XML_SCHEMAS_GMONTH:
- case XML_SCHEMAS_GMONTHDAY:
- case XML_SCHEMAS_GDAY:
- case XML_SCHEMAS_DURATION:
- case XML_SCHEMAS_FLOAT:
- case XML_SCHEMAS_DOUBLE:
- case XML_SCHEMAS_BOOLEAN:
- case XML_SCHEMAS_ANYURI:
- case XML_SCHEMAS_HEXBINARY:
- case XML_SCHEMAS_BASE64BINARY:
- case XML_SCHEMAS_QNAME:
- case XML_SCHEMAS_NOTATION:
+ switch (type) {
+ case XML_SCHEMAS_STRING:
+ case XML_SCHEMAS_DECIMAL:
+ case XML_SCHEMAS_DATE:
+ case XML_SCHEMAS_DATETIME:
+ case XML_SCHEMAS_TIME:
+ case XML_SCHEMAS_GYEAR:
+ case XML_SCHEMAS_GYEARMONTH:
+ case XML_SCHEMAS_GMONTH:
+ case XML_SCHEMAS_GMONTHDAY:
+ case XML_SCHEMAS_GDAY:
+ case XML_SCHEMAS_DURATION:
+ case XML_SCHEMAS_FLOAT:
+ case XML_SCHEMAS_DOUBLE:
+ case XML_SCHEMAS_BOOLEAN:
+ case XML_SCHEMAS_ANYURI:
+ case XML_SCHEMAS_HEXBINARY:
+ case XML_SCHEMAS_BASE64BINARY:
+ case XML_SCHEMAS_QNAME:
+ case XML_SCHEMAS_NOTATION:
ret->flags |= XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE;
break;
default:
case XML_SCHEMAS_ENTITIES:
ret->flags |= XML_SCHEMAS_TYPE_VARIETY_LIST;
ret->facets = xmlSchemaNewMinLengthFacet(1);
- ret->flags |= XML_SCHEMAS_TYPE_HAS_FACETS;
+ ret->flags |= XML_SCHEMAS_TYPE_HAS_FACETS;
break;
default:
ret->flags |= XML_SCHEMAS_TYPE_VARIETY_ATOMIC;
return;
xmlSchemaTypesBank = xmlHashCreate(40);
-
+
/*
* 3.4.7 Built-in Complex Type Definition
*/
xmlSchemaTypeAnyTypeDef = xmlSchemaInitBasicType("anyType",
- XML_SCHEMAS_ANYTYPE,
+ XML_SCHEMAS_ANYTYPE,
NULL);
xmlSchemaTypeAnyTypeDef->baseType = xmlSchemaTypeAnyTypeDef;
xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED;
/*
* Init the content type.
*/
- xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED;
+ xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED;
{
xmlSchemaParticlePtr particle;
xmlSchemaModelGroupPtr sequence;
return;
}
memset(sequence, 0, sizeof(xmlSchemaModelGroup));
- sequence->type = XML_SCHEMA_TYPE_SEQUENCE;
+ sequence->type = XML_SCHEMA_TYPE_SEQUENCE;
particle->children = (xmlSchemaTreeItemPtr) sequence;
/* Second particle. */
particle = xmlSchemaAddParticle();
}
memset(wild, 0, sizeof(xmlSchemaWildcard));
wild->type = XML_SCHEMA_TYPE_ANY;
- wild->any = 1;
- wild->processContents = XML_SCHEMAS_ANY_LAX;
- particle->children = (xmlSchemaTreeItemPtr) wild;
+ wild->any = 1;
+ wild->processContents = XML_SCHEMAS_ANY_LAX;
+ particle->children = (xmlSchemaTreeItemPtr) wild;
/*
* Create the attribute wildcard.
*/
}
memset(wild, 0, sizeof(xmlSchemaWildcard));
wild->any = 1;
- wild->processContents = XML_SCHEMAS_ANY_LAX;
+ wild->processContents = XML_SCHEMAS_ANY_LAX;
xmlSchemaTypeAnyTypeDef->attributeWildcard = wild;
}
- xmlSchemaTypeAnySimpleTypeDef = xmlSchemaInitBasicType("anySimpleType",
+ xmlSchemaTypeAnySimpleTypeDef = xmlSchemaInitBasicType("anySimpleType",
XML_SCHEMAS_ANYSIMPLETYPE,
xmlSchemaTypeAnyTypeDef);
/*
xmlSchemaTypeAnySimpleTypeDef);
xmlSchemaTypeNotationDef = xmlSchemaInitBasicType("NOTATION",
XML_SCHEMAS_NOTATION,
- xmlSchemaTypeAnySimpleTypeDef);
+ xmlSchemaTypeAnySimpleTypeDef);
xmlSchemaTypeQNameDef = xmlSchemaInitBasicType("QName",
XML_SCHEMAS_QNAME,
xmlSchemaTypeAnySimpleTypeDef);
xmlSchemaTypeNCNameDef);
xmlSchemaTypeIdrefDef = xmlSchemaInitBasicType("IDREF",
XML_SCHEMAS_IDREF,
- xmlSchemaTypeNCNameDef);
+ xmlSchemaTypeNCNameDef);
xmlSchemaTypeEntityDef = xmlSchemaInitBasicType("ENTITY",
XML_SCHEMAS_ENTITY,
xmlSchemaTypeNCNameDef);
*
* Cleanup the default XML Schemas type library
*/
-void
+void
xmlSchemaCleanupTypes(void) {
if (xmlSchemaTypesInitialized == 0)
return;
/* Content type. */
particle = (xmlSchemaParticlePtr) xmlSchemaTypeAnyTypeDef->subtypes;
/* Wildcard. */
- xmlSchemaFreeWildcard((xmlSchemaWildcardPtr)
+ xmlSchemaFreeWildcard((xmlSchemaWildcardPtr)
particle->children->children->children);
xmlFree((xmlSchemaParticlePtr) particle->children->children);
/* Sequence model group. */
xmlFree((xmlSchemaModelGroupPtr) particle->children);
xmlFree((xmlSchemaParticlePtr) particle);
- xmlSchemaTypeAnyTypeDef->subtypes = NULL;
+ xmlSchemaTypeAnyTypeDef->subtypes = NULL;
}
xmlHashFree(xmlSchemaTypesBank, (xmlHashDeallocator) xmlSchemaFreeType);
xmlSchemaTypesInitialized = 0;
(facetType == XML_SCHEMA_FACET_WHITESPACE))
return (1);
else
- return (0);
+ return (0);
case XML_SCHEMAS_STRING:
case XML_SCHEMAS_NOTATION:
case XML_SCHEMAS_QNAME:
- case XML_SCHEMAS_ANYURI:
- case XML_SCHEMAS_BASE64BINARY:
+ case XML_SCHEMAS_ANYURI:
+ case XML_SCHEMAS_BASE64BINARY:
case XML_SCHEMAS_HEXBINARY:
if ((facetType == XML_SCHEMA_FACET_LENGTH) ||
(facetType == XML_SCHEMA_FACET_MINLENGTH) ||
(facetType == XML_SCHEMA_FACET_MINEXCLUSIVE))
return (1);
else
- return (0);
+ return (0);
case XML_SCHEMAS_TIME:
- case XML_SCHEMAS_GDAY:
+ case XML_SCHEMAS_GDAY:
case XML_SCHEMAS_GMONTH:
- case XML_SCHEMAS_GMONTHDAY:
- case XML_SCHEMAS_GYEAR:
+ case XML_SCHEMAS_GMONTHDAY:
+ case XML_SCHEMAS_GYEAR:
case XML_SCHEMAS_GYEARMONTH:
case XML_SCHEMAS_DATE:
case XML_SCHEMAS_DATETIME:
(facetType == XML_SCHEMA_FACET_MINEXCLUSIVE))
return (1);
else
- return (0);
+ return (0);
default:
break;
}
if (xmlSchemaTypesInitialized == 0)
xmlSchemaInitTypes();
switch (type) {
-
+
case XML_SCHEMAS_ANYSIMPLETYPE:
return (xmlSchemaTypeAnySimpleTypeDef);
case XML_SCHEMAS_STRING:
case XML_SCHEMAS_GMONTH:
return (xmlSchemaTypeGMonthDef);
case XML_SCHEMAS_GMONTHDAY:
- return (xmlSchemaTypeGMonthDayDef);
+ return (xmlSchemaTypeGMonthDayDef);
case XML_SCHEMAS_GYEAR:
return (xmlSchemaTypeGYearDef);
case XML_SCHEMAS_GYEARMONTH:
case XML_SCHEMAS_BASE64BINARY:
return (xmlSchemaTypeBase64BinaryDef);
case XML_SCHEMAS_ANYTYPE:
- return (xmlSchemaTypeAnyTypeDef);
+ return (xmlSchemaTypeAnyTypeDef);
default:
return (NULL);
}
*/
const xmlChar *
xmlSchemaValueGetAsString(xmlSchemaValPtr val)
-{
+{
if (val == NULL)
return (NULL);
switch (val->type) {
*/
int
xmlSchemaValueGetAsBoolean(xmlSchemaValPtr val)
-{
+{
if ((val == NULL) || (val->type != XML_SCHEMAS_BOOLEAN))
return (0);
return (val->value.b);
* @type: the value type
* @value: the value
*
- * Allocate a new simple type value. The type can be
- * of XML_SCHEMAS_STRING.
+ * Allocate a new simple type value. The type can be
+ * of XML_SCHEMAS_STRING.
* WARNING: This one is intended to be expanded for other
* string based types. We need this for anySimpleType as well.
* The given value is consumed and freed with the struct.
*
* Cleanup the default XML Schemas type library
*/
-void
+void
xmlSchemaFreeValue(xmlSchemaValPtr value) {
xmlSchemaValPtr prev;
- while (value != NULL) {
+ while (value != NULL) {
switch (value->type) {
case XML_SCHEMAS_STRING:
case XML_SCHEMAS_NORMSTRING:
case XML_SCHEMAS_IDREF:
case XML_SCHEMAS_IDREFS:
case XML_SCHEMAS_ENTITY:
- case XML_SCHEMAS_ENTITIES:
+ case XML_SCHEMAS_ENTITIES:
case XML_SCHEMAS_ANYURI:
case XML_SCHEMAS_ANYSIMPLETYPE:
if (value->value.str != NULL)
prev = value;
value = value->next;
xmlFree(prev);
- }
+ }
}
/**
if ((type == NULL) || (type->type != XML_SCHEMA_TYPE_BASIC))
return (NULL);
switch (type->builtInType) {
- case XML_SCHEMAS_NMTOKENS:
+ case XML_SCHEMAS_NMTOKENS:
return (xmlSchemaTypeNmtokenDef );
- case XML_SCHEMAS_IDREFS:
+ case XML_SCHEMAS_IDREFS:
return (xmlSchemaTypeIdrefDef);
case XML_SCHEMAS_ENTITIES:
return (xmlSchemaTypeEntityDef);
*/
static int
_xmlSchemaParseTime (xmlSchemaValDatePtr dt, const xmlChar **str) {
- const xmlChar *cur = *str;
+ const xmlChar *cur = *str;
int ret = 0;
int value = 0;
PARSE_2_DIGITS(value, cur, ret);
if (ret != 0)
- return ret;
+ return ret;
if (*cur != ':')
return 1;
if (!VALID_HOUR(value))
const xmlChar *rewnd = cur;
cur++;
- ret = _xmlSchemaParseGDay(&(dt->value.date), &cur);
+ ret = _xmlSchemaParseGDay(&(dt->value.date), &cur);
if ((ret == 0) && ((*cur == 0) || (*cur != ':'))) {
/*
}
cur++;
if (collapse)
- while IS_WSP_BLANK_CH(*cur) cur++;
+ while IS_WSP_BLANK_CH(*cur) cur++;
}
if (isneg) {
*/
xmlChar *
xmlSchemaWhiteSpaceReplace(const xmlChar *value) {
- const xmlChar *cur = value;
- xmlChar *ret = NULL, *mcur;
+ const xmlChar *cur = value;
+ xmlChar *ret = NULL, *mcur;
- if (value == NULL)
+ if (value == NULL)
return(NULL);
-
- while ((*cur != 0) &&
+
+ while ((*cur != 0) &&
(((*cur) != 0xd) && ((*cur) != 0x9) && ((*cur) != 0xa))) {
cur++;
}
if ( ((*mcur) == 0xd) || ((*mcur) == 0x9) || ((*mcur) == 0xa) )
*mcur = ' ';
mcur++;
- } while (*mcur != 0);
+ } while (*mcur != 0);
return(ret);
}
const xmlChar *tmp, *cur = *str;
int ret = 0, i = 0;
- if (!((*cur >= '0') && (*cur <= '9')))
+ if (!((*cur >= '0') && (*cur <= '9')))
return(-2);
while (*cur == '0') { /* ignore leading zeroes */
if ((flags == 0) && (value != NULL)) {
if ((type->builtInType != XML_SCHEMAS_STRING) &&
- (type->builtInType != XML_SCHEMAS_ANYTYPE) &&
+ (type->builtInType != XML_SCHEMAS_ANYTYPE) &&
(type->builtInType != XML_SCHEMAS_ANYSIMPLETYPE)) {
if (type->builtInType == XML_SCHEMAS_NORMSTRING)
norm = xmlSchemaWhiteSpaceReplace(value);
}
switch (type->builtInType) {
- case XML_SCHEMAS_UNKNOWN:
+ case XML_SCHEMAS_UNKNOWN:
goto error;
case XML_SCHEMAS_ANYTYPE:
case XML_SCHEMAS_ANYSIMPLETYPE:
*val = v;
} else {
goto error;
- }
+ }
}
goto return0;
- case XML_SCHEMAS_STRING:
+ case XML_SCHEMAS_STRING:
if (! normOnTheFly) {
const xmlChar *cur = value;
const xmlChar *cur = value;
unsigned int len, neg, integ, hasLeadingZeroes;
xmlChar cval[25];
- xmlChar *cptr = cval;
+ xmlChar *cptr = cval;
if ((cur == NULL) || (*cur == 0))
goto return1;
v = xmlSchemaNewValue(XML_SCHEMAS_DECIMAL);
if (v != NULL) {
/*
- * Now evaluate the significant digits of the number
- */
+ * Now evaluate the significant digits of the number
+ */
if (len != 0) {
-
+
if (integ != ~0u) {
/*
* Get rid of trailing zeroes in the
} else {
cur++;
}
- }
- }
+ }
+ }
if (val != NULL) {
v = xmlSchemaNewValue(XML_SCHEMAS_TOKEN);
if (v != NULL) {
goto return0;
}
case XML_SCHEMAS_LANGUAGE:
- if (normOnTheFly) {
+ if (normOnTheFly) {
norm = xmlSchemaCollapseString(value);
if (norm != NULL)
value = norm;
}
goto done;
}
- case XML_SCHEMAS_ANYURI:{
+ case XML_SCHEMAS_ANYURI:{
if (*value != 0) {
xmlURIPtr uri;
xmlChar *tmpval, *cur;
- if (normOnTheFly) {
+ if (normOnTheFly) {
norm = xmlSchemaCollapseString(value);
if (norm != NULL)
value = norm;
}
case XML_SCHEMAS_BASE64BINARY:{
/* ISSUE:
- *
+ *
* Ignore all stray characters? (yes, currently)
* Worry about long lines? (no, currently)
- *
+ *
* rfc2045.txt:
- *
+ *
* "The encoded output stream must be represented in lines of
* no more than 76 characters each. All line breaks or other
* characters not found in Table 1 must be ignored by decoding
/*
* First test: If x is -ve and not zero
*/
- if ((x->value.decimal.sign) &&
+ if ((x->value.decimal.sign) &&
((x->value.decimal.lo != 0) ||
(x->value.decimal.mi != 0) ||
(x->value.decimal.hi != 0))) {
xmlSchemaValPtr ret = xmlSchemaNewValue(v->type);
if (ret == NULL)
return NULL;
-
+
memcpy(ret, v, sizeof(xmlSchemaVal));
ret->next = NULL;
return ret;
if (val->value.str != NULL)
cur->value.str = xmlStrdup(BAD_CAST val->value.str);
break;
- case XML_SCHEMAS_QNAME:
+ case XML_SCHEMAS_QNAME:
case XML_SCHEMAS_NOTATION:
cur = xmlSchemaDupVal(val);
if (val->value.qname.name != NULL)
if (tyr == 0)
tyr--;
/*
- * Coverity detected an overrun in daysInMonth
+ * Coverity detected an overrun in daysInMonth
* of size 12 at position 12 with index variable "((r)->mon - 1)"
*/
- if (tmon < 0)
- tmon = 0;
+ if (tmon < 1)
+ tmon = 1;
if (tmon > 12)
tmon = 12;
tempdays += MAX_DAYINMONTH(tyr, tmon);
carry = -1;
- } else if (tempdays > (long) MAX_DAYINMONTH(r->year, r->mon)) {
+ } else if (VALID_YEAR(r->year) && VALID_MONTH(r->mon) &&
+ tempdays > (long) MAX_DAYINMONTH(r->year, r->mon)) {
tempdays = tempdays - MAX_DAYINMONTH(r->year, r->mon);
carry = 1;
} else
r->year++;
}
}
-
+
r->day = tempdays;
/*
* _xmlSchemaDateCastYMToDays:
* @dt: an #xmlSchemaValPtr
*
- * Convert mon and year of @dt to total number of days. Take the
+ * Convert mon and year of @dt to total number of days. Take the
* number of years since (or before) 1 AD and add the number of leap
* years. This is a function because negative
* years must be handled a little differently and there is no zero year.
ret = -1;
else if (sec > 0.0)
ret = 1;
-
+
}
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
int invert)
{
int tmp;
-
+
while ((*x != 0) && (*y != 0)) {
if (IS_WSP_REPLACE_CH(*y)) {
if (! IS_WSP_SPACE_CH(*x)) {
else
return(1);
}
- }
+ }
} else {
tmp = *x - *y;
if (tmp < 0) {
{
int tmp;
- /*
+ /*
* Skip leading blank chars of the collapsed string.
*/
while IS_WSP_BLANK_CH(*y)
{
int tmp;
- /*
+ /*
* Skip leading blank chars of the collapsed string.
*/
while IS_WSP_BLANK_CH(*y)
y++;
-
+
while ((*x != 0) && (*y != 0)) {
if IS_WSP_BLANK_CH(*y) {
if (! IS_WSP_BLANK_CH(*x)) {
}
}
x++;
- y++;
- /*
+ y++;
+ /*
* Skip contiguous blank chars of the collapsed string.
*/
while IS_WSP_BLANK_CH(*y)
return(-1);
else
return(1);
- }
+ }
if (*y != 0) {
/*
* Skip trailing blank chars of the collapsed string.
const xmlChar *y)
{
int tmp;
-
+
while ((*x != 0) && (*y != 0)) {
if IS_WSP_BLANK_CH(*y) {
if (! IS_WSP_BLANK_CH(*x)) {
if ((*x - 0x20) < 0)
- return(-1);
+ return(-1);
else
return(1);
- }
+ }
} else {
if IS_WSP_BLANK_CH(*x) {
if ((0x20 - *y) < 0)
- return(-1);
+ return(-1);
else
return(1);
}
tmp = *x - *y;
if (tmp < 0)
- return(-1);
+ return(-1);
if (tmp > 0)
- return(1);
+ return(1);
}
x++;
y++;
xmlSchemaCompareNormStrings(const xmlChar *x,
const xmlChar *y) {
int tmp;
-
+
while (IS_BLANK_CH(*x)) x++;
while (IS_BLANK_CH(*y)) y++;
while ((*x != 0) && (*y != 0)) {
(ytype == XML_SCHEMAS_GYEARMONTH))
return (xmlSchemaCompareDates(x, y));
return (-2);
- /*
+ /*
* Note that we will support comparison of string types against
* anySimpleType as well.
*/
case XML_SCHEMAS_ANYSIMPLETYPE:
case XML_SCHEMAS_STRING:
- case XML_SCHEMAS_NORMSTRING:
+ case XML_SCHEMAS_NORMSTRING:
case XML_SCHEMAS_TOKEN:
case XML_SCHEMAS_LANGUAGE:
case XML_SCHEMAS_NMTOKEN:
/*
* TODO: Compare those against QName.
*/
- if (ytype == XML_SCHEMAS_QNAME) {
+ if (ytype == XML_SCHEMAS_QNAME) {
TODO
if (y == NULL)
- return(-2);
+ return(-2);
return (-2);
}
if ((ytype == XML_SCHEMAS_ANYSIMPLETYPE) ||
/* TODO: What about x < y or x > y. */
if (xmlStrEqual(xv, yv))
return (0);
- else
+ else
return (2);
} else if (yws == XML_SCHEMA_WHITESPACE_REPLACE)
return (xmlSchemaComparePreserveReplaceStrings(xv, yv, 0));
return (xmlSchemaCompareNormStrings(xv, yv));
} else
return (-2);
-
+
}
return (-2);
}
else
return(-1);
}
- return (-2);
+ return (-2);
case XML_SCHEMAS_IDREFS:
case XML_SCHEMAS_ENTITIES:
case XML_SCHEMAS_NMTOKENS:
if (y->type == XML_SCHEMAS_STRING)
yws = XML_SCHEMA_WHITESPACE_PRESERVE;
- else if (x->type == XML_SCHEMAS_NORMSTRING)
+ else if (y->type == XML_SCHEMAS_NORMSTRING)
yws = XML_SCHEMA_WHITESPACE_REPLACE;
else
yws = XML_SCHEMA_WHITESPACE_COLLAPSE;
if (expectedLen != NULL)
*expectedLen = facet->val->value.decimal.lo;
return (XML_SCHEMAV_CVC_LENGTH_VALID);
- }
+ }
} else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) {
if (actualLen < facet->val->value.decimal.lo) {
if (expectedLen != NULL)
return (XML_SCHEMAV_CVC_MAXLENGTH_VALID);
}
} else
- /*
- * NOTE: That we can pass NULL as xmlSchemaValPtr to
+ /*
+ * NOTE: That we can pass NULL as xmlSchemaValPtr to
* xmlSchemaValidateFacet, since the remaining facet types
- * are: XML_SCHEMA_FACET_PATTERN, XML_SCHEMA_FACET_ENUMERATION.
+ * are: XML_SCHEMA_FACET_PATTERN, XML_SCHEMA_FACET_ENUMERATION.
*/
- return(xmlSchemaValidateFacet(NULL, facet, value, NULL));
+ return(xmlSchemaValidateFacet(NULL, facet, value, NULL));
return (0);
}
* @ws: the whitespace type of the value
* @length: the actual length of the value
*
- * Checka a value against a "length", "minLength" and "maxLength"
+ * Checka a value against a "length", "minLength" and "maxLength"
* facet; sets @length to the computed length of @value.
*
* Returns 0 if the value is valid, a positive error code
const xmlChar *value,
xmlSchemaValPtr val,
unsigned long *length,
- xmlSchemaWhitespaceValueType ws)
+ xmlSchemaWhitespaceValueType ws)
{
unsigned int len = 0;
(facet->type != XML_SCHEMA_FACET_MAXLENGTH) &&
(facet->type != XML_SCHEMA_FACET_MINLENGTH))
return (-1);
-
+
/*
* TODO: length, maxLength and minLength must be of type
* nonNegativeInteger only. Check if decimal is used somehow.
if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE)
len = xmlSchemaNormLen(value);
else
- /*
+ /*
* Should be OK for "preserve" as well.
*/
len = xmlUTF8Strlen(value);
case XML_SCHEMAS_NMTOKEN:
case XML_SCHEMAS_NAME:
case XML_SCHEMAS_NCNAME:
- case XML_SCHEMAS_ID:
+ case XML_SCHEMAS_ID:
/*
* FIXME: What exactly to do with anyURI?
*/
len = xmlSchemaNormLen(value);
break;
case XML_SCHEMAS_QNAME:
- case XML_SCHEMAS_NOTATION:
- /*
+ case XML_SCHEMAS_NOTATION:
+ /*
* For QName and NOTATION, those facets are
* deprecated and should be ignored.
- */
+ */
return (0);
default:
TODO
if (len > facet->val->value.decimal.lo)
return(XML_SCHEMAV_CVC_MAXLENGTH_VALID);
}
-
+
return (0);
}
* @val: the precomputed value
* @length: the actual length of the value
*
- * Checka a value against a "length", "minLength" and "maxLength"
+ * Checka a value against a "length", "minLength" and "maxLength"
* facet; sets @length to the computed length of @value.
*
* Returns 0 if the value is valid, a positive error code
* otherwise and -1 in case of an internal or API error.
*/
int
-xmlSchemaValidateLengthFacet(xmlSchemaTypePtr type,
+xmlSchemaValidateLengthFacet(xmlSchemaTypePtr type,
xmlSchemaFacetPtr facet,
const xmlChar *value,
xmlSchemaValPtr val,
- unsigned long *length)
+ unsigned long *length)
{
if (type == NULL)
return(-1);
}
/**
- * xmlSchemaValidateLengthFacetWhtsp:
+ * xmlSchemaValidateLengthFacetWhtsp:
* @facet: the facet to check
* @valType: the built-in type
* @value: the lexical repr. of the value to be validated
* @ws: the whitespace type of the value
* @length: the actual length of the value
*
- * Checka a value against a "length", "minLength" and "maxLength"
+ * Checka a value against a "length", "minLength" and "maxLength"
* facet; sets @length to the computed length of @value.
*
* Returns 0 if the value is valid, a positive error code
static int
xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet,
xmlSchemaWhitespaceValueType fws,
- xmlSchemaValType valType,
+ xmlSchemaValType valType,
const xmlChar *value,
xmlSchemaValPtr val,
xmlSchemaWhitespaceValueType ws)
switch (facet->type) {
case XML_SCHEMA_FACET_PATTERN:
- /*
+ /*
* NOTE that for patterns, the @value needs to be the normalized
* value, *not* the lexical initial value or the canonical value.
*/
else {
switch (valType) {
case XML_SCHEMAS_STRING:
- case XML_SCHEMAS_NORMSTRING:
+ case XML_SCHEMAS_NORMSTRING:
if (ws == XML_SCHEMA_WHITESPACE_UNKNOWN) {
/*
* This is to ensure API compatibility with the old
if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE)
len = xmlSchemaNormLen(value);
else
- /*
+ /*
* Should be OK for "preserve" as well.
*/
len = xmlUTF8Strlen(value);
}
break;
- case XML_SCHEMAS_IDREF:
+ case XML_SCHEMAS_IDREF:
case XML_SCHEMAS_TOKEN:
case XML_SCHEMAS_LANGUAGE:
case XML_SCHEMAS_NMTOKEN:
case XML_SCHEMAS_ID:
case XML_SCHEMAS_ANYURI:
if (value != NULL)
- len = xmlSchemaNormLen(value);
- break;
+ len = xmlSchemaNormLen(value);
+ break;
default:
TODO
- }
+ }
}
if (facet->type == XML_SCHEMA_FACET_LENGTH) {
if (len != facet->val->value.decimal.lo)
int
xmlSchemaValidateFacetWhtsp(xmlSchemaFacetPtr facet,
xmlSchemaWhitespaceValueType fws,
- xmlSchemaValType valType,
+ xmlSchemaValType valType,
const xmlChar *value,
xmlSchemaValPtr val,
xmlSchemaWhitespaceValueType ws)
/*
* Result is in work, and after_fraction points
* just past the fractional part.
- * Use scientific notation
+ * Use scientific notation
*/
integer_place = DBL_DIG + EXPONENT_DIGITS + 1;
fraction_place = DBL_DIG - 1;
snprintf(work, sizeof(work),"%*.*e",
integer_place, fraction_place, number);
- after_fraction = strchr(work + DBL_DIG, 'e');
+ after_fraction = strchr(work + DBL_DIG, 'e');
/* Remove fractional trailing zeroes */
ptr = after_fraction;
while (*(--ptr) == '0')
* @val: the precomputed value
* @retValue: the returned value
*
- * Get a the cononical lexical representation of the value.
+ * Get the canonical lexical representation of the value.
* The caller has to FREE the returned retValue.
*
* WARNING: Some value types are not supported yet, resulting
* in a @retValue of "???".
- *
+ *
* TODO: XML Schema 1.0 does not define canonical representations
* for: duration, gYearMonth, gYear, gMonthDay, gMonth, gDay,
* anyURI, QName, NOTATION. This will be fixed in XML Schema 1.1.
if (val->value.str == NULL)
*retValue = BAD_CAST xmlStrdup(BAD_CAST "");
else
- *retValue =
+ *retValue =
BAD_CAST xmlStrdup((const xmlChar *) val->value.str);
break;
case XML_SCHEMAS_NORMSTRING:
case XML_SCHEMAS_TOKEN:
case XML_SCHEMAS_LANGUAGE:
case XML_SCHEMAS_NMTOKEN:
- case XML_SCHEMAS_NAME:
+ case XML_SCHEMAS_NAME:
case XML_SCHEMAS_NCNAME:
case XML_SCHEMAS_ID:
case XML_SCHEMAS_IDREF:
case XML_SCHEMAS_ANYURI: /* Unclear */
if (val->value.str == NULL)
return (-1);
- *retValue =
+ *retValue =
BAD_CAST xmlSchemaCollapseString(BAD_CAST val->value.str);
if (*retValue == NULL)
- *retValue =
+ *retValue =
BAD_CAST xmlStrdup((const xmlChar *) val->value.str);
break;
case XML_SCHEMAS_QNAME:
/*
* TODO: Lookout for a more simple implementation.
*/
- if ((val->value.decimal.total == 1) &&
+ if ((val->value.decimal.total == 1) &&
(val->value.decimal.lo == 0)) {
*retValue = xmlStrdup(BAD_CAST "0.0");
} else {
else
snprintf(offs, bufsize - (offs - buf),
"%lu", dec.lo);
-
+
if (dec.frac != 0) {
if (dec.frac != dec.total) {
int diff = dec.total - dec.frac;
unsigned int i = 0;
/*
* Insert missing zeroes behind the decimal point.
- */
+ */
while (*(offs + i) != 0)
i++;
if (i < dec.total) {
snprintf((char *) *retValue, 6, "---%02u",
val->value.date.day);
}
- break;
+ break;
case XML_SCHEMAS_GMONTHDAY: {
/* TODO: Unclear in XML Schema 1.0 */
/* TODO: What to do with the timezone? */
/* TODO: What to do with the timezone? */
if (val->value.date.year < 0)
snprintf(buf, 35, "-%04ld-%02u",
- labs(val->value.date.year),
+ labs(val->value.date.year),
val->value.date.mon);
else
snprintf(buf, 35, "%04ld-%02u",
val->value.date.year, val->value.date.mon);
*retValue = BAD_CAST xmlStrdup(BAD_CAST buf);
}
- break;
+ break;
case XML_SCHEMAS_TIME:
{
char buf[30];
norm = xmlSchemaDateNormalize(val, 0);
if (norm == NULL)
return (-1);
- /*
- * TODO: Check if "%.14g" is portable.
+ /*
+ * TODO: Check if "%.14g" is portable.
*/
snprintf(buf, 30,
"%02u:%02u:%02.14gZ",
val->value.date.sec);
}
*retValue = BAD_CAST xmlStrdup(BAD_CAST buf);
- }
+ }
break;
case XML_SCHEMAS_DATE:
{
val->value.date.day);
}
*retValue = BAD_CAST xmlStrdup(BAD_CAST buf);
- }
+ }
break;
case XML_SCHEMAS_DATETIME:
{
*retValue = BAD_CAST xmlStrdup(BAD_CAST val->value.base64.str);
break;
case XML_SCHEMAS_FLOAT: {
- char buf[30];
- /*
+ char buf[30];
+ /*
* |m| < 16777216, -149 <= e <= 104.
* TODO: Handle, NaN, INF, -INF. The format is not
* yet conformant. The c type float does not cover
snprintf(buf, 40, "%01.14e", val->value.d);
*retValue = BAD_CAST xmlStrdup(BAD_CAST buf);
}
- break;
+ break;
default:
*retValue = BAD_CAST xmlStrdup(BAD_CAST "???");
return (1);
* @retValue: the returned value
* @ws: the whitespace type of the value
*
- * Get a the cononical representation of the value.
+ * Get the canonical representation of the value.
* The caller has to free the returned @retValue.
*
* Returns 0 if the value could be built, 1 if the value type is
break;
default:
return (xmlSchemaGetCanonValue(val, retValue));
- }
+ }
return (0);
}