libxml2
Loading...
Searching...
No Matches
xmlschemastypes.h File Reference

implementation of XML Schema Datatypes More...

Enumerations

enum  xmlSchemaWhitespaceValueType
 Schema whitespace value type.

Functions

int xmlSchemaInitTypes (void)
 Initialize the default XML Schemas type library.
void xmlSchemaCleanupTypes (void)
 Cleanup the default XML Schemas type library.
xmlSchemaTypexmlSchemaGetPredefinedType (const xmlChar *name, const xmlChar *ns)
 Lookup a type in the default XML Schemas type library.
int xmlSchemaValidatePredefinedType (xmlSchemaType *type, const xmlChar *value, xmlSchemaVal **val)
 Check that a value conforms to the lexical space of the predefined type.
int xmlSchemaValPredefTypeNode (xmlSchemaType *type, const xmlChar *value, xmlSchemaVal **val, xmlNode *node)
 Check that a value conforms to the lexical space of the predefined type.
int xmlSchemaValidateFacet (xmlSchemaType *base, xmlSchemaFacet *facet, const xmlChar *value, xmlSchemaVal *val)
 Check a value against a facet condition.
int xmlSchemaValidateFacetWhtsp (xmlSchemaFacet *facet, xmlSchemaWhitespaceValueType fws, xmlSchemaValType valType, const xmlChar *value, xmlSchemaVal *val, xmlSchemaWhitespaceValueType ws)
 Check a value against a facet condition.
void xmlSchemaFreeValue (xmlSchemaVal *val)
 Cleanup the default XML Schemas type library.
xmlSchemaFacetxmlSchemaNewFacet (void)
 Allocate a new Facet structure.
int xmlSchemaCheckFacet (xmlSchemaFacet *facet, xmlSchemaType *typeDecl, xmlSchemaParserCtxt *ctxt, const xmlChar *name)
 Checks and computes the values of facets.
void xmlSchemaFreeFacet (xmlSchemaFacet *facet)
 Deallocate a Schema Facet structure.
int xmlSchemaCompareValues (xmlSchemaVal *x, xmlSchemaVal *y)
 Compare 2 values.
xmlSchemaTypexmlSchemaGetBuiltInListSimpleTypeItemType (xmlSchemaType *type)
 Lookup function.
int xmlSchemaValidateListSimpleTypeFacet (xmlSchemaFacet *facet, const xmlChar *value, unsigned long actualLen, unsigned long *expectedLen)
 Checks the value of a list simple type against a facet.
xmlSchemaTypexmlSchemaGetBuiltInType (xmlSchemaValType type)
 Gives you the type struct for a built-in type by its type id.
int xmlSchemaIsBuiltInTypeFacet (xmlSchemaType *type, int facetType)
 Evaluates if a specific facet can be used in conjunction with a type.
xmlCharxmlSchemaCollapseString (const xmlChar *value)
 Removes and normalize white spaces in the string.
xmlCharxmlSchemaWhiteSpaceReplace (const xmlChar *value)
 Replaces 0xd, 0x9 and 0xa with a space.
unsigned long xmlSchemaGetFacetValueAsULong (xmlSchemaFacet *facet)
 Extract the value of a facet.
int xmlSchemaValidateLengthFacet (xmlSchemaType *type, xmlSchemaFacet *facet, const xmlChar *value, xmlSchemaVal *val, unsigned long *length)
 Checka a value against a "length", "minLength" and "maxLength" facet; sets length to the computed length of value.
int xmlSchemaValidateLengthFacetWhtsp (xmlSchemaFacet *facet, xmlSchemaValType valType, const xmlChar *value, xmlSchemaVal *val, unsigned long *length, xmlSchemaWhitespaceValueType ws)
 Checka a value against a "length", "minLength" and "maxLength" facet; sets length to the computed length of value.
int xmlSchemaValPredefTypeNodeNoNorm (xmlSchemaType *type, const xmlChar *value, xmlSchemaVal **val, xmlNode *node)
 Check that a value conforms to the lexical space of the predefined type.
int xmlSchemaGetCanonValue (xmlSchemaVal *val, const xmlChar **retValue)
 Get the canonical lexical representation of the value.
int xmlSchemaGetCanonValueWhtsp (xmlSchemaVal *val, const xmlChar **retValue, xmlSchemaWhitespaceValueType ws)
 Get the canonical representation of the value.
int xmlSchemaValueAppend (xmlSchemaVal *prev, xmlSchemaVal *cur)
 Appends a next sibling to a list of computed values.
xmlSchemaValxmlSchemaValueGetNext (xmlSchemaVal *cur)
 Accessor for the next sibling of a list of computed values.
const xmlCharxmlSchemaValueGetAsString (xmlSchemaVal *val)
 Accessor for the string value of a computed value.
int xmlSchemaValueGetAsBoolean (xmlSchemaVal *val)
 Accessor for the boolean value of a computed value.
xmlSchemaValxmlSchemaNewStringValue (xmlSchemaValType type, const xmlChar *value)
 Allocate a new simple type value.
xmlSchemaValxmlSchemaNewNOTATIONValue (const xmlChar *name, const xmlChar *ns)
 Allocate a new NOTATION value.
xmlSchemaValxmlSchemaNewQNameValue (const xmlChar *namespaceName, const xmlChar *localName)
 Allocate a new QName value.
int xmlSchemaCompareValuesWhtsp (xmlSchemaVal *x, xmlSchemaWhitespaceValueType xws, xmlSchemaVal *y, xmlSchemaWhitespaceValueType yws)
 Compare 2 values.
xmlSchemaValxmlSchemaCopyValue (xmlSchemaVal *val)
 Copies the precomputed value.
xmlSchemaValType xmlSchemaGetValType (xmlSchemaVal *val)
 Accessor for the type of a value.

Detailed Description

implementation of XML Schema Datatypes

module providing the XML Schema Datatypes implementation both definition and validity checking

Author
Daniel Veillard

Function Documentation

◆ xmlSchemaCheckFacet()

int xmlSchemaCheckFacet ( xmlSchemaFacet * facet,
xmlSchemaType * typeDecl,
xmlSchemaParserCtxt * pctxt,
const xmlChar * name )

Checks and computes the values of facets.

Parameters
facetthe facet
typeDeclthe schema type definition
pctxtthe schema parser context or NULL
namethe optional name of the type
Returns
0 if valid, a positive error code if not valid and -1 in case of an internal or API error.

◆ xmlSchemaCleanupTypes()

void xmlSchemaCleanupTypes ( void )

Cleanup the default XML Schemas type library.

Deprecated
This function will be made private. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don't have to call cleanup functions at all.

◆ xmlSchemaCollapseString()

xmlChar * xmlSchemaCollapseString ( const xmlChar * value)

Removes and normalize white spaces in the string.

Parameters
valuea value
Returns
the new string or NULL if no change was required.

◆ xmlSchemaCompareValues()

int xmlSchemaCompareValues ( xmlSchemaVal * x,
xmlSchemaVal * y )

Compare 2 values.

Parameters
xa first value
ya second value
Returns
-1 if x < y, 0 if x == y, 1 if x > y, 2 if x <> y, and -2 in case of error

◆ xmlSchemaCompareValuesWhtsp()

int xmlSchemaCompareValuesWhtsp ( xmlSchemaVal * x,
xmlSchemaWhitespaceValueType xws,
xmlSchemaVal * y,
xmlSchemaWhitespaceValueType yws )

Compare 2 values.

Parameters
xa first value
xwsthe whitespace value of x
ya second value
ywsthe whitespace value of y
Returns
-1 if x < y, 0 if x == y, 1 if x > y, 2 if x <> y, and -2 in case of error

◆ xmlSchemaCopyValue()

xmlSchemaVal * xmlSchemaCopyValue ( xmlSchemaVal * val)

Copies the precomputed value.

This duplicates any string within.

Parameters
valthe precomputed value to be copied
Returns
the copy or NULL if a copy for a data-type is not implemented.

◆ xmlSchemaFreeFacet()

void xmlSchemaFreeFacet ( xmlSchemaFacet * facet)

Deallocate a Schema Facet structure.

Parameters
faceta schema facet structure

◆ xmlSchemaFreeValue()

void xmlSchemaFreeValue ( xmlSchemaVal * value)

Cleanup the default XML Schemas type library.

Parameters
valuethe value to free

◆ xmlSchemaGetBuiltInListSimpleTypeItemType()

xmlSchemaType * xmlSchemaGetBuiltInListSimpleTypeItemType ( xmlSchemaType * type)

Lookup function.

Parameters
typethe built-in simple type.
Returns
the item type of type as defined by the built-in datatype hierarchy of XML Schema Part 2: Datatypes, or NULL in case of an error.

◆ xmlSchemaGetBuiltInType()

xmlSchemaType * xmlSchemaGetBuiltInType ( xmlSchemaValType type)

Gives you the type struct for a built-in type by its type id.

Parameters
typethe type of the built in type
Returns
the type if found, NULL otherwise.

◆ xmlSchemaGetCanonValue()

int xmlSchemaGetCanonValue ( xmlSchemaVal * val,
const xmlChar ** retValue )

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.

Parameters
valthe precomputed value
retValuethe returned value
Returns
0 if the value could be built, 1 if the value type is not supported yet and -1 in case of API errors.

◆ xmlSchemaGetCanonValueWhtsp()

int xmlSchemaGetCanonValueWhtsp ( xmlSchemaVal * val,
const xmlChar ** retValue,
xmlSchemaWhitespaceValueType ws )

Get the canonical representation of the value.

The caller has to free the returned retValue.

Parameters
valthe precomputed value
retValuethe returned value
wsthe whitespace type of the value
Returns
0 if the value could be built, 1 if the value type is not supported yet and -1 in case of API errors.

◆ xmlSchemaGetFacetValueAsULong()

unsigned long xmlSchemaGetFacetValueAsULong ( xmlSchemaFacet * facet)

Extract the value of a facet.

Parameters
facetan schemas type facet
Returns
the value as a long

◆ xmlSchemaGetPredefinedType()

xmlSchemaType * xmlSchemaGetPredefinedType ( const xmlChar * name,
const xmlChar * ns )

Lookup a type in the default XML Schemas type library.

Parameters
namethe type name
nsthe URI of the namespace usually "http://www.w3.org/2001/XMLSchema"
Returns
the type if found, NULL otherwise

◆ xmlSchemaGetValType()

xmlSchemaValType xmlSchemaGetValType ( xmlSchemaVal * val)

Accessor for the type of a value.

Parameters
vala schemas value
Returns
the xmlSchemaValType of the value

◆ xmlSchemaInitTypes()

int xmlSchemaInitTypes ( void )

Initialize the default XML Schemas type library.

Returns
0 on success, -1 on error.

◆ xmlSchemaIsBuiltInTypeFacet()

int xmlSchemaIsBuiltInTypeFacet ( xmlSchemaType * type,
int facetType )

Evaluates if a specific facet can be used in conjunction with a type.

Parameters
typethe built-in type
facetTypethe facet type
Returns
1 if the facet can be used with the given built-in type, 0 otherwise and -1 in case the type is not a built-in type.

◆ xmlSchemaNewFacet()

xmlSchemaFacet * xmlSchemaNewFacet ( void )

Allocate a new Facet structure.

Returns
the newly allocated structure or NULL in case or error

◆ xmlSchemaNewNOTATIONValue()

xmlSchemaVal * xmlSchemaNewNOTATIONValue ( const xmlChar * name,
const xmlChar * ns )

Allocate a new NOTATION value.

The given values are consumed and freed with the struct.

Parameters
namethe notation name
nsthe notation namespace name or NULL
Returns
a pointer to the new value or NULL in case of error

◆ xmlSchemaNewQNameValue()

xmlSchemaVal * xmlSchemaNewQNameValue ( const xmlChar * namespaceName,
const xmlChar * localName )

Allocate a new QName value.

The given values are consumed and freed with the struct.

Parameters
namespaceNamethe namespace name
localNamethe local name
Returns
a pointer to the new value or NULL in case of an error.

◆ xmlSchemaNewStringValue()

xmlSchemaVal * xmlSchemaNewStringValue ( xmlSchemaValType type,
const xmlChar * value )

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.

Parameters
typethe value type
valuethe value
Returns
a pointer to the new value or NULL in case of error

◆ xmlSchemaValidateFacet()

int xmlSchemaValidateFacet ( xmlSchemaType * base,
xmlSchemaFacet * facet,
const xmlChar * value,
xmlSchemaVal * val )

Check a value against a facet condition.

Parameters
basethe base type
facetthe facet to check
valuethe lexical repr of the value to validate
valthe precomputed value
Returns
0 if the element is schemas valid, a positive error code number otherwise and -1 in case of internal or API error.

◆ xmlSchemaValidateFacetWhtsp()

int xmlSchemaValidateFacetWhtsp ( xmlSchemaFacet * facet,
xmlSchemaWhitespaceValueType fws,
xmlSchemaValType valType,
const xmlChar * value,
xmlSchemaVal * val,
xmlSchemaWhitespaceValueType ws )

Check a value against a facet condition.

This takes value normalization according to the specified whitespace types into account. Note that value needs to be the normalized value if the facet is of type "pattern".

Parameters
facetthe facet to check
fwsthe whitespace type of the facet's value
valTypethe built-in type of the value
valuethe lexical (or normalized for pattern) repr of the value to validate
valthe precomputed value
wsthe whitespace type of the value
Returns
0 if the element is schemas valid, a positive error code number otherwise and -1 in case of internal or API error.

◆ xmlSchemaValidateLengthFacet()

int xmlSchemaValidateLengthFacet ( xmlSchemaType * type,
xmlSchemaFacet * facet,
const xmlChar * value,
xmlSchemaVal * val,
unsigned long * length )

Checka a value against a "length", "minLength" and "maxLength" facet; sets length to the computed length of value.

Parameters
typethe built-in type
facetthe facet to check
valuethe lexical repr. of the value to be validated
valthe precomputed value
lengththe actual length of the value
Returns
0 if the value is valid, a positive error code otherwise and -1 in case of an internal or API error.

◆ xmlSchemaValidateLengthFacetWhtsp()

int xmlSchemaValidateLengthFacetWhtsp ( xmlSchemaFacet * facet,
xmlSchemaValType valType,
const xmlChar * value,
xmlSchemaVal * val,
unsigned long * length,
xmlSchemaWhitespaceValueType ws )

Checka a value against a "length", "minLength" and "maxLength" facet; sets length to the computed length of value.

Parameters
facetthe facet to check
valTypethe built-in type
valuethe lexical repr. of the value to be validated
valthe precomputed value
wsthe whitespace type of the value
lengththe actual length of the value
Returns
0 if the value is valid, a positive error code otherwise and -1 in case of an internal or API error.

◆ xmlSchemaValidateListSimpleTypeFacet()

int xmlSchemaValidateListSimpleTypeFacet ( xmlSchemaFacet * facet,
const xmlChar * value,
unsigned long actualLen,
unsigned long * expectedLen )

Checks the value of a list simple type against a facet.

Parameters
facetthe facet to check
valuethe lexical repr of the value to validate
actualLenthe number of list items
expectedLenthe resulting expected number of list items
Returns
0 if the value is valid, a positive error code number otherwise and -1 in case of an internal error.

◆ xmlSchemaValidatePredefinedType()

int xmlSchemaValidatePredefinedType ( xmlSchemaType * type,
const xmlChar * value,
xmlSchemaVal ** val )

Check that a value conforms to the lexical space of the predefined type.

if true a value is computed and returned in val.

Parameters
typethe predefined type
valuethe value to check
valthe return computed value
Returns
0 if this validates, a positive error code number otherwise and -1 in case of internal or API error.

◆ xmlSchemaValPredefTypeNode()

int xmlSchemaValPredefTypeNode ( xmlSchemaType * type,
const xmlChar * value,
xmlSchemaVal ** val,
xmlNode * node )

Check that a value conforms to the lexical space of the predefined type.

if true a value is computed and returned in val.

Parameters
typethe predefined type
valuethe value to check
valthe return computed value
nodethe node containing the value
Returns
0 if this validates, a positive error code number otherwise and -1 in case of internal or API error.

◆ xmlSchemaValPredefTypeNodeNoNorm()

int xmlSchemaValPredefTypeNodeNoNorm ( xmlSchemaType * type,
const xmlChar * value,
xmlSchemaVal ** val,
xmlNode * node )

Check that a value conforms to the lexical space of the predefined type.

if true a value is computed and returned in val. This one does apply any normalization to the value.

Parameters
typethe predefined type
valuethe value to check
valthe return computed value
nodethe node containing the value
Returns
0 if this validates, a positive error code number otherwise and -1 in case of internal or API error.

◆ xmlSchemaValueAppend()

int xmlSchemaValueAppend ( xmlSchemaVal * prev,
xmlSchemaVal * cur )

Appends a next sibling to a list of computed values.

Parameters
prevthe value
curthe value to be appended
Returns
0 if succeeded and -1 on API errors.

◆ xmlSchemaValueGetAsBoolean()

int xmlSchemaValueGetAsBoolean ( xmlSchemaVal * val)

Accessor for the boolean value of a computed value.

Parameters
valthe value
Returns
1 if true and 0 if false, or in case of an error. Hmm.

◆ xmlSchemaValueGetAsString()

const xmlChar * xmlSchemaValueGetAsString ( xmlSchemaVal * val)

Accessor for the string value of a computed value.

Parameters
valthe value
Returns
the string value or NULL if there was none, or on API errors.

◆ xmlSchemaValueGetNext()

xmlSchemaVal * xmlSchemaValueGetNext ( xmlSchemaVal * cur)

Accessor for the next sibling of a list of computed values.

Parameters
curthe value
Returns
the next value or NULL if there was none, or on API errors.

◆ xmlSchemaWhiteSpaceReplace()

xmlChar * xmlSchemaWhiteSpaceReplace ( const xmlChar * value)

Replaces 0xd, 0x9 and 0xa with a space.

Parameters
valuea value
Returns
the new string or NULL if no change was required.