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
xmlRegexp * | xmlRegexpCompile (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.
xmlRegExecCtxt * | xmlRegNewExecCtxt (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.

Copyright
  See Copyright for the status of this software.

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

  exec | the regular expression context
  token | the current token string
  transdata | transition data
  inputdata | input 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

  exec | a regexp execution context generating an error
  string | return value for the error string
  nbval | pointer to the number of accepted values IN/OUT
  nbneg | return number of negative transitions
  values | pointer to the array of acceptable values
  terminal | return 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

  exec | a regexp execution context
  nbval | pointer to the number of accepted values IN/OUT
  nbneg | return number of negative transitions
  values | pointer to the array of acceptable values
  terminal | return 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

  exec | a regexp execution context or NULL to indicate the end
  value | a string token input
  data | data 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

  exec | a regexp execution context or NULL to indicate the end
  value | the first string token input
  value2 | the second string token input
  data | data 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

  regexp | a 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

  comp | the compiled regular expression
  content | the 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

  comp | the 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

  output | the file for the output debug
  regexp | the compiled regexp

## ◆ xmlRegFreeExecCtxt()

void xmlRegFreeExecCtxt | ( | xmlRegExecCtxt * | exec | ) |

Free the structures associated to a regular expression evaluation context.

Deprecated:
  Internal function, don't use.

Parameters

  exec | a regular expression evaluation context

## ◆ xmlRegFreeRegexp()

void xmlRegFreeRegexp | ( | xmlRegexp * | regexp | ) |

Free a regexp.

Parameters

  regexp | the 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

  comp | a precompiled regular expression
  callback | a callback function used for handling progresses in the automata matching phase
  data | the context data associated to the callback in this context

Returns
  the new context