## xmlautomata

xmlautomata —

## Synopsis

    struct      xmlAutomata;
    typedef     xmlAutomataPtr;
    struct      xmlAutomataState;
    typedef     xmlAutomataStatePtr;
    xmlAutomataPtr xmlNewAutomata               (void);
    void        xmlFreeAutomata                 (xmlAutomataPtr am);
    xmlAutomataStatePtr xmlAutomataGetInitState (xmlAutomataPtr am);
    int         xmlAutomataSetFinalState        (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr state);
    xmlAutomataStatePtr xmlAutomataNewState     (xmlAutomataPtr am);
    xmlAutomataStatePtr xmlAutomataNewTransition
                                                (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 const xmlChar *token,
                                                 void *data);
    xmlAutomataStatePtr xmlAutomataNewTransition2
                                                (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 const xmlChar *token,
                                                 const xmlChar *token2,
                                                 void *data);
    xmlAutomataStatePtr xmlAutomataNewCountTrans
                                                (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 const xmlChar *token,
                                                 int min,
                                                 int max,
                                                 void *data);
    xmlAutomataStatePtr xmlAutomataNewOnceTrans (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 const xmlChar *token,
                                                 int min,
                                                 int max,
                                                 void *data);
    xmlAutomataStatePtr xmlAutomataNewAllTrans  (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 int lax);
    xmlAutomataStatePtr xmlAutomataNewEpsilon   (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to);
    xmlAutomataStatePtr xmlAutomataNewCountedTrans
                                                (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 int counter);
    xmlAutomataStatePtr xmlAutomataNewCounterTrans
                                                (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 int counter);
    int         xmlAutomataNewCounter           (xmlAutomataPtr am,
                                                 int min,
                                                 int max);
    xmlRegexpPtr xmlAutomataCompile             (xmlAutomataPtr am);
    int         xmlAutomataIsDeterminist        (xmlAutomataPtr am);

## Description

## Details

### struct xmlAutomata

    struct xmlAutomata;

### xmlAutomataPtr

    typedef xmlAutomata *xmlAutomataPtr;

A libxml automata description, It can be compiled into a regexp

### struct xmlAutomataState

    struct xmlAutomataState;

### xmlAutomataStatePtr

    typedef xmlAutomataState *xmlAutomataStatePtr;

A state int the automata description,

### xmlNewAutomata ()

    xmlAutomataPtr xmlNewAutomata               (void);

Create a new automata

Returns : | the new object or NULL in case of failure

### xmlFreeAutomata ()

    void        xmlFreeAutomata                 (xmlAutomataPtr am);

Free an automata

`am` : | an automata

### xmlAutomataGetInitState ()

    xmlAutomataStatePtr xmlAutomataGetInitState (xmlAutomataPtr am);

Initial state lookup

`am` : | an automata
Returns : | the initial state of the automata

### xmlAutomataSetFinalState ()

    int         xmlAutomataSetFinalState        (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr state);

Makes that state a final state

`am` : | an automata
`state` : | a state in this automata
Returns : | 0 or -1 in case of error

### xmlAutomataNewState ()

    xmlAutomataStatePtr xmlAutomataNewState     (xmlAutomataPtr am);

Create a new disconnected state in the automata

`am` : | an automata
Returns : | the new state or NULL in case of error

### xmlAutomataNewTransition ()

    xmlAutomataStatePtr xmlAutomataNewTransition
                                                (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 const xmlChar *token,
                                                 void *data);

If `to` is NULL, this create first a new target state in the automata and then adds a transition from the `from` state to the target state activated by the value of `token`

`am` : | an automata
`from` : | the starting point of the transition
`to` : | the target point of the transition or NULL
`token` : | the input string associated to that transition
`data` : | data passed to the callback function if the transition is activated
Returns : | the target state or NULL in case of error

### xmlAutomataNewTransition2 ()

    xmlAutomataStatePtr xmlAutomataNewTransition2
                                                (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 const xmlChar *token,
                                                 const xmlChar *token2,
                                                 void *data);

If `to` is NULL, this create first a new target state in the automata and then adds a transition from the `from` state to the target state activated by the value of `token`

`am` : | an automata
`from` : | the starting point of the transition
`to` : | the target point of the transition or NULL
`token` : | the first input string associated to that transition
`token2` : | the second input string associated to that transition
`data` : | data passed to the callback function if the transition is activated
Returns : | the target state or NULL in case of error

### xmlAutomataNewCountTrans ()

    xmlAutomataStatePtr xmlAutomataNewCountTrans
                                                (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 const xmlChar *token,
                                                 int min,
                                                 int max,
                                                 void *data);

If `to` is NULL, this create first a new target state in the automata and then adds a transition from the `from` state to the target state activated by a succession of input of value `token` and whose number is between `min` and `max`

`am` : | an automata
`from` : | the starting point of the transition
`to` : | the target point of the transition or NULL
`token` : | the input string associated to that transition
`min` : | the minimum successive occurences of token
`max` : | the maximum successive occurences of token
`data` : | data associated to the transition
Returns : | the target state or NULL in case of error

### xmlAutomataNewOnceTrans ()

    xmlAutomataStatePtr xmlAutomataNewOnceTrans (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 const xmlChar *token,
                                                 int min,
                                                 int max,
                                                 void *data);

If `to` is NULL, this create first a new target state in the automata and then adds a transition from the `from` state to the target state activated by a succession of input of value `token` and whose number is between `min` and `max`, moreover that transistion can only be crossed once.

`am` : | an automata
`from` : | the starting point of the transition
`to` : | the target point of the transition or NULL
`token` : | the input string associated to that transition
`min` : | the minimum successive occurences of token
`max` : | the maximum successive occurences of token
`data` : | data associated to the transition
Returns : | the target state or NULL in case of error

### xmlAutomataNewAllTrans ()

    xmlAutomataStatePtr xmlAutomataNewAllTrans  (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 int lax);

If `to` is NULL, this create first a new target state in the automata and then adds a an ALL transition from the `from` state to the target state. That transition is an epsilon transition allowed only when all transitions from the `from` node have been activated.

`am` : | an automata
`from` : | the starting point of the transition
`to` : | the target point of the transition or NULL
`lax` : | allow to transition if not all all transitions have been activated
Returns : | the target state or NULL in case of error

### xmlAutomataNewEpsilon ()

    xmlAutomataStatePtr xmlAutomataNewEpsilon   (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to);

If `to` is NULL, this create first a new target state in the automata and then adds a an epsilon transition from the `from` state to the target state

`am` : | an automata
`from` : | the starting point of the transition
`to` : | the target point of the transition or NULL
Returns : | the target state or NULL in case of error

### xmlAutomataNewCountedTrans ()

    xmlAutomataStatePtr xmlAutomataNewCountedTrans
                                                (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 int counter);

If `to` is NULL, this create first a new target state in the automata and then adds an epsilon transition from the `from` state to the target state which will increment the counter provided

`am` : | an automata
`from` : | the starting point of the transition
`to` : | the target point of the transition or NULL
`counter` : | the counter associated to that transition
Returns : | the target state or NULL in case of error

### xmlAutomataNewCounterTrans ()

    xmlAutomataStatePtr xmlAutomataNewCounterTrans
                                                (xmlAutomataPtr am,
                                                 xmlAutomataStatePtr from,
                                                 xmlAutomataStatePtr to,
                                                 int counter);

If `to` is NULL, this create first a new target state in the automata and then adds an epsilon transition from the `from` state to the target state which will be allowed only if the counter is within the right range.

`am` : | an automata
`from` : | the starting point of the transition
`to` : | the target point of the transition or NULL
`counter` : | the counter associated to that transition
Returns : | the target state or NULL in case of error

### xmlAutomataNewCounter ()

    int         xmlAutomataNewCounter           (xmlAutomataPtr am,
                                                 int min,
                                                 int max);

Create a new counter

`am` : | an automata
`min` : | the minimal value on the counter
`max` : | the maximal value on the counter
Returns : | the counter number or -1 in case of error

### xmlAutomataCompile ()

    xmlRegexpPtr xmlAutomataCompile             (xmlAutomataPtr am);

Compile the automata into a Reg Exp ready for being executed. The automata should be free after this point.

`am` : | an automata
Returns : | the compiled regexp or NULL in case of error

### xmlAutomataIsDeterminist ()

    int         xmlAutomataIsDeterminist        (xmlAutomataPtr am);

Checks if an automata is determinist.

`am` : | an automata
Returns : | 1 if true, 0 if not, and -1 in case of error