- Home
- Download
- News
- Documentation

- FAQ
- Tutorial
- API reference
- Examples

- XML Digital Signature

- Online Verifier

- XML Encryption
- XML Canonicalization
- Reporting Bugs
- Mailing list
- Related
- Authors

# nodeset

## Name

nodeset -- Nodeset object implementation.

## Synopsis

    struct              xmlSecNodeSet;
    xmlSecNodeSetPtrxmlSecNodeSetAdd                    (xmlSecNodeSetPtr nset,
                                                             xmlSecNodeSetPtr newNSet,
                                                             xmlSecNodeSetOp op);
    xmlSecNodeSetPtrxmlSecNodeSetAddList                (xmlSecNodeSetPtr nset,
                                                             xmlSecNodeSetPtr newNSet,
                                                             xmlSecNodeSetOp op);
    intxmlSecNodeSetContains               (xmlSecNodeSetPtr nset,
                                                             xmlNodePtr node,
                                                             xmlNodePtr parent);
    xmlSecNodeSetPtrxmlSecNodeSetCreate                 (xmlDocPtr doc,
                                                             xmlNodeSetPtr nodes,
                                                             xmlSecNodeSetType type);
    voidxmlSecNodeSetDebugDump              (xmlSecNodeSetPtr nset,
                                                             FILE *output);
    voidxmlSecNodeSetDestroy                (xmlSecNodeSetPtr nset);
    voidxmlSecNodeSetDocDestroy             (xmlSecNodeSetPtr nset);
    intxmlSecNodeSetDumpTextNodes          (xmlSecNodeSetPtr nset,
                                                             xmlOutputBufferPtr out);
    xmlSecNodeSetPtrxmlSecNodeSetGetChildren            (xmlDocPtr doc,
                                                             const xmlNodePtr parent,
                                                             int withComments,
                                                             int invert);
    enum                xmlSecNodeSetOp;
    enum                xmlSecNodeSetType;
    intxmlSecNodeSetWalk                   (xmlSecNodeSetPtr nset,
                                                             xmlSecNodeSetWalkCallback walkFunc,
                                                             void *data);
    int                 (*xmlSecNodeSetWalkCallback)        (xmlSecNodeSetPtr nset,
                                                             xmlNodePtr cur,
                                                             xmlNodePtr parent,
                                                             void *data);

## Description

Nodeset object implementation.

## Details

### struct xmlSecNodeSet

    struct xmlSecNodeSet {
        xmlNodeSetPtr       nodes;
        xmlDocPtr           doc;
        int                 destroyDoc;
        xmlSecNodeSetType   type;
        xmlSecNodeSetOp     op;
        xmlSecNodeSetPtr    next;
        xmlSecNodeSetPtr    prev;
        xmlSecNodeSetPtr    children;
    };

The enchanced nodes set.

xmlNodeSetPtr `nodes`; | the nodes list.
xmlDocPtr `doc`; | the parent XML document.
int `destroyDoc`; | the flag: if set to 1 then `doc` will be destroyed when node set is destroyed.
xmlSecNodeSetType `type`; | the nodes set type.
xmlSecNodeSetOp `op`; | the operation type.
xmlSecNodeSetPtr `next`; | the next nodes set.
xmlSecNodeSetPtr `prev`; | the previous nodes set.
xmlSecNodeSetPtr `children`; | the children list (valid only if type equal to xmlSecNodeSetList).

### xmlSecNodeSetAdd ()

    xmlSecNodeSetPtr    xmlSecNodeSetAdd                    (xmlSecNodeSetPtr nset,
                                                             xmlSecNodeSetPtr newNSet,
                                                             xmlSecNodeSetOp op);

Adds `newNSet` to the `nset` using operation `op`.

`nset` : | the pointer to currrent nodes set (or NULL).
`newNSet` : | the pointer to new nodes set.
`op` : | the operation type.
Returns : | the pointer to combined nodes set or NULL if an error occurs.

### xmlSecNodeSetAddList ()

    xmlSecNodeSetPtr    xmlSecNodeSetAddList                (xmlSecNodeSetPtr nset,
                                                             xmlSecNodeSetPtr newNSet,
                                                             xmlSecNodeSetOp op);

Adds `newNSet` to the `nset` as child using operation `op`.

`nset` : | the pointer to currrent nodes set (or NULL).
`newNSet` : | the pointer to new nodes set.
`op` : | the operation type.
Returns : | the pointer to combined nodes set or NULL if an error occurs.

### xmlSecNodeSetContains ()

    int                 xmlSecNodeSetContains               (xmlSecNodeSetPtr nset,
                                                             xmlNodePtr node,
                                                             xmlNodePtr parent);

Checks whether the `node` is in the nodes set or not.

`nset` : | the pointer to node set.
`node` : | the pointer to XML node to check.
`parent` : | the pointer to `node` parent node.
Returns : | 1 if the `node` is in the nodes set `nset`, 0 if it is not and a negative value if an error occurs.

### xmlSecNodeSetCreate ()

    xmlSecNodeSetPtr    xmlSecNodeSetCreate                 (xmlDocPtr doc,
                                                             xmlNodeSetPtr nodes,
                                                             xmlSecNodeSetType type);

Creates new nodes set. Caller is responsible for freeing returned object by calling xmlSecNodeSetDestroy function.

`doc` : | the pointer to parent XML document.
`nodes` : | the list of nodes.
`type` : | the nodes set type.
Returns : | pointer to newly allocated node set or NULL if an error occurs.

### xmlSecNodeSetDebugDump ()

    void                xmlSecNodeSetDebugDump              (xmlSecNodeSetPtr nset,
                                                             FILE *output);

Prints information about `nset` to the `output`.

`nset` : | the pointer to node set.
`output` : | the pointer to output FILE.

### xmlSecNodeSetDestroy ()

    void                xmlSecNodeSetDestroy                (xmlSecNodeSetPtr nset);

Destroys the nodes set created with xmlSecNodeSetCreate function.

`nset` : | the pointer to node set.

### xmlSecNodeSetDocDestroy ()

    void                xmlSecNodeSetDocDestroy             (xmlSecNodeSetPtr nset);

Instructs node set to destroy nodes parent doc when node set is destroyed.

`nset` : | the pointer to node set.

### xmlSecNodeSetDumpTextNodes ()

    int                 xmlSecNodeSetDumpTextNodes          (xmlSecNodeSetPtr nset,
                                                             xmlOutputBufferPtr out);

Dumps content of all the text nodes from `nset` to `out`.

`nset` : | the pointer to node set.
`out` : | the output buffer.
Returns : | 0 on success or a negative value otherwise.

### xmlSecNodeSetGetChildren ()

    xmlSecNodeSetPtr    xmlSecNodeSetGetChildren            (xmlDocPtr doc,
                                                             const xmlNodePtr parent,
                                                             int withComments,
                                                             int invert);

Creates a new nodes set that contains: - if `withComments` is not 0 and `invert` is 0: all nodes in the `parent` subtree; - if `withComments` is 0 and `invert` is 0: all nodes in the `parent` subtree except comment nodes; - if `withComments` is not 0 and `invert` not is 0: all nodes in the `doc` except nodes in the `parent` subtree; - if `withComments` is 0 and `invert` is 0: all nodes in the `doc` except nodes in the `parent` subtree and comment nodes.

`doc` : | the pointer to an XML document.
`parent` : | the pointer to parent XML node or NULL if we want to include all document nodes.
`withComments` : | the flag include comments or not.
`invert` : | the "invert" flag.
Returns : | pointer to the newly created xmlSecNodeSet structure or NULL if an error occurs.

### enum xmlSecNodeSetOp

    typedef enum {
        xmlSecNodeSetIntersection = 0,
        xmlSecNodeSetSubtraction,
        xmlSecNodeSetUnion
    } xmlSecNodeSetOp;

The simple nodes sets operations.

`xmlSecNodeSetIntersection` | intersection.
`xmlSecNodeSetSubtraction` | subtraction.
`xmlSecNodeSetUnion` | union.

### enum xmlSecNodeSetType

    typedef enum {
        xmlSecNodeSetNormal = 0,
        xmlSecNodeSetInvert,
        xmlSecNodeSetTree,
        xmlSecNodeSetTreeWithoutComments,
        xmlSecNodeSetTreeInvert,
        xmlSecNodeSetTreeWithoutCommentsInvert,
        xmlSecNodeSetList
    } xmlSecNodeSetType;

The basic nodes sets types.

`xmlSecNodeSetNormal` | nodes set = nodes in the list.
`xmlSecNodeSetInvert` | nodes set = all document nodes minus nodes in the list.
`xmlSecNodeSetTree` | nodes set = nodes in the list and all their subtress.
`xmlSecNodeSetTreeWithoutComments` | nodes set = nodes in the list and all their subtress but no comment nodes.
`xmlSecNodeSetTreeInvert` | nodes set = all document nodes minus nodes in the list and all their subtress.
`xmlSecNodeSetTreeWithoutCommentsInvert` | nodes set = all document nodes minus (nodes in the list and all their subtress plus all comment nodes).
`xmlSecNodeSetList` | nodes set = all nodes in the chidren list of nodes sets.

### xmlSecNodeSetWalk ()

    int                 xmlSecNodeSetWalk                   (xmlSecNodeSetPtr nset,
                                                             xmlSecNodeSetWalkCallback walkFunc,
                                                             void *data);

Calls the function `walkFunc` once per each node in the nodes set `nset`. If the `walkFunc` returns a negative value, then the walk procedure is interrupted.

`nset` : | the pointer to node set.
`walkFunc` : | the callback functions.
`data` : | the application specific data passed to the `walkFunc`.
Returns : | 0 on success or a negative value if an error occurs.

### xmlSecNodeSetWalkCallback ()

    int                 (*xmlSecNodeSetWalkCallback)        (xmlSecNodeSetPtr nset,
                                                             xmlNodePtr cur,
                                                             xmlNodePtr parent,
                                                             void *data);

The callback function called once per each node in the nodes set.

`nset` : | the pointer to xmlSecNodeSet structure.
`cur` : | the pointer current XML node.
`parent` : | the pointer to the `cur` parent node.
`data` : | the pointer to application specific data.
Returns : | 0 on success or a negative value if an error occurs an walk procedure should be interrupted.