libxml2
Loading...
Searching...
No Matches
Typedefs | Functions
xmlregexp.h File Reference

Regular expressions. More...

Typedefs

typedef struct _xmlRegexp xmlRegexp
 A libxml regular expression.
 
typedef struct _xmlRegExecCtxt xmlRegExecCtxt
 A libxml progressive regular expression evaluation context.
 
typedef void(* xmlRegExecCallbacks) (xmlRegExecCtxt *exec, const xmlChar *token, void *transdata, void *inputdata)
 Callback function when doing a transition in the automata.
 

Functions

xmlRegexpxmlRegexpCompile (const xmlChar *regexp)
 Parses an XML Schemas regular expression.
 
void xmlRegFreeRegexp (xmlRegexp *regexp)
 Free a regexp.
 
int xmlRegexpExec (xmlRegexp *comp, const xmlChar *value)
 Check if the regular expression matches a string.
 
void xmlRegexpPrint (FILE *output, xmlRegexp *regexp)
 No-op since 2.14.0.
 
int xmlRegexpIsDeterminist (xmlRegexp *comp)
 Check if the regular expression is deterministic.
 
xmlRegExecCtxtxmlRegNewExecCtxt (xmlRegexp *comp, xmlRegExecCallbacks callback, void *data)
 Build a context used for progressive evaluation of a regexp.
 
void xmlRegFreeExecCtxt (xmlRegExecCtxt *exec)
 Free the structures associated to a regular expression evaluation context.
 
int xmlRegExecPushString (xmlRegExecCtxt *exec, const xmlChar *value, void *data)
 Push one input token in the execution context.
 
int xmlRegExecPushString2 (xmlRegExecCtxt *exec, const xmlChar *value, const xmlChar *value2, void *data)
 Push one input token in the execution context.
 
int xmlRegExecNextValues (xmlRegExecCtxt *exec, int *nbval, int *nbneg, xmlChar **values, int *terminal)
 Extract information from the regexp execution.
 
int xmlRegExecErrInfo (xmlRegExecCtxt *exec, const xmlChar **string, int *nbval, int *nbneg, xmlChar **values, int *terminal)
 Extract error information from the regexp execution.
 

Detailed Description

Regular expressions.

A regular expression engine used for DTD and XML Schema validation.

Author
Daniel Veillard

Typedef Documentation

◆ xmlRegExecCallbacks

typedef void(* xmlRegExecCallbacks) (xmlRegExecCtxt *exec, const xmlChar *token, void *transdata, void *inputdata)

Callback function when doing a transition in the automata.

Parameters
execthe regular expression context
tokenthe current token string
transdatatransition data
inputdatainput data

Function Documentation

◆ xmlRegExecErrInfo()

int xmlRegExecErrInfo ( xmlRegExecCtxt exec,
const xmlChar **  string,
int *  nbval,
int *  nbneg,
xmlChar **  values,
int *  terminal 
)

Extract error information from the regexp execution.

The parameter string will be updated with the value pushed and not accepted, the parameter values must point to an array of nbval string pointers on return nbval will contain the number of possible strings in that state and the values array will be updated with them. The string values returned will be freed with the exec context and don't need to be deallocated.

Deprecated:
Internal function, don't use.
Parameters
execa regexp execution context generating an error
stringreturn value for the error string
nbvalpointer to the number of accepted values IN/OUT
nbnegreturn number of negative transitions
valuespointer to the array of acceptable values
terminalreturn value if this was a terminal state
Returns
0 in case of success or -1 in case of error.

◆ xmlRegExecNextValues()

int xmlRegExecNextValues ( xmlRegExecCtxt exec,
int *  nbval,
int *  nbneg,
xmlChar **  values,
int *  terminal 
)

Extract information from the regexp execution.

The parameter values must point to an array of nbval string pointers on return nbval will contain the number of possible strings in that state and the values array will be updated with them. The string values returned will be freed with the exec context and don't need to be deallocated.

Deprecated:
Internal function, don't use.
Parameters
execa regexp execution context
nbvalpointer to the number of accepted values IN/OUT
nbnegreturn number of negative transitions
valuespointer to the array of acceptable values
terminalreturn value if this was a terminal state
Returns
0 in case of success or -1 in case of error.

◆ xmlRegExecPushString()

int xmlRegExecPushString ( xmlRegExecCtxt exec,
const xmlChar value,
void *  data 
)

Push one input token in the execution context.

Deprecated:
Internal function, don't use.
Parameters
execa regexp execution context or NULL to indicate the end
valuea string token input
datadata associated to the token to reuse in callbacks
Returns
1 if the regexp reached a final state, 0 if non-final, and a negative value in case of error.

◆ xmlRegExecPushString2()

int xmlRegExecPushString2 ( xmlRegExecCtxt exec,
const xmlChar value,
const xmlChar value2,
void *  data 
)

Push one input token in the execution context.

Deprecated:
Internal function, don't use.
Parameters
execa regexp execution context or NULL to indicate the end
valuethe first string token input
value2the second string token input
datadata associated to the token to reuse in callbacks
Returns
1 if the regexp reached a final state, 0 if non-final, and a negative value in case of error.

◆ xmlRegexpCompile()

xmlRegexp * xmlRegexpCompile ( const xmlChar regexp)

Parses an XML Schemas regular expression.

Parses a regular expression conforming to XML Schemas Part 2 Datatype Appendix F and builds an automata suitable for testing strings against that regular expression.

Parameters
regexpa regular expression string
Returns
the compiled expression or NULL in case of error

◆ xmlRegexpExec()

int xmlRegexpExec ( xmlRegexp comp,
const xmlChar content 
)

Check if the regular expression matches a string.

Parameters
compthe compiled regular expression
contentthe value to check against the regular expression
Returns
1 if it matches, 0 if not and a negative value in case of error

◆ xmlRegexpIsDeterminist()

int xmlRegexpIsDeterminist ( xmlRegexp comp)

Check if the regular expression is deterministic.

DTD and XML Schemas require a deterministic content model, so the automaton compiled from the regex must be a DFA.

The runtime of this function is quadratic in the number of outgoing edges, causing serious worst-case performance issues.

Deprecated:
: Internal function, don't use.
Parameters
compthe compiled regular expression
Returns
1 if it yes, 0 if not and a negative value in case of error

◆ xmlRegexpPrint()

void xmlRegexpPrint ( FILE *  output,
xmlRegexp regexp 
)

No-op since 2.14.0.

Deprecated:
Don't use.
Parameters
outputthe file for the output debug
regexpthe compiled regexp

◆ xmlRegFreeExecCtxt()

void xmlRegFreeExecCtxt ( xmlRegExecCtxt exec)

Free the structures associated to a regular expression evaluation context.

Deprecated:
Internal function, don't use.
Parameters
execa regular expression evaluation context

◆ xmlRegFreeRegexp()

void xmlRegFreeRegexp ( xmlRegexp regexp)

Free a regexp.

Parameters
regexpthe regexp

◆ xmlRegNewExecCtxt()

xmlRegExecCtxt * xmlRegNewExecCtxt ( xmlRegexp comp,
xmlRegExecCallbacks  callback,
void *  data 
)

Build a context used for progressive evaluation of a regexp.

Deprecated:
Internal function, don't use.
Parameters
compa precompiled regular expression
callbacka callback function used for handling progresses in the automata matching phase
datathe context data associated to the callback in this context
Returns
the new context