## namespaces

namespaces - interface for the XSLT namespace handling

set of function easing the processing and generation of namespace nodes in XSLT.

Author(s): Daniel Veillard

## Synopsis

    #define UNDEFINED_DEFAULT_NS;
    void	xsltFreeNamespaceAliasHashes	(xsltStylesheetPtr style);
    xmlNsPtr	xsltCopyNamespace	(xsltTransformContextPtr ctxt,
    					 xmlNodePtr elem,
    					 xmlNsPtr ns);
    xmlNsPtr	xsltCopyNamespaceList	(xsltTransformContextPtr ctxt,
    					 xmlNodePtr node,
    					 xmlNsPtr cur);
    xmlNsPtr	xsltGetNamespace	(xsltTransformContextPtr ctxt,
    					 xmlNodePtr cur,
    					 xmlNsPtr ns,
    					 xmlNodePtr out);
    xmlNsPtr	xsltGetPlainNamespace	(xsltTransformContextPtr ctxt,
    					 xmlNodePtr cur,
    					 xmlNsPtr ns,
    					 xmlNodePtr out);
    xmlNsPtr	xsltGetSpecialNamespace	(xsltTransformContextPtr ctxt,
    					 xmlNodePtr invocNode,
    					 const xmlChar * nsName,
    					 const xmlChar * nsPrefix,
    					 xmlNodePtr target);
    void	xsltNamespaceAlias		(xsltStylesheetPtr style,
    					 xmlNodePtr node);

## Description

## Details

### Macro UNDEFINED_DEFAULT_NS

    #define UNDEFINED_DEFAULT_NS;

Special value for undefined namespace, internal

### xsltCopyNamespace ()

    xmlNsPtr	xsltCopyNamespace	(xsltTransformContextPtr ctxt,
    					 xmlNodePtr elem,
    					 xmlNsPtr ns)

Copies a namespace node (declaration). If @elem is not NULL, then the new namespace will be declared on @elem.

`ctxt`: | a transformation context
`elem`: | the target element node
`ns`: | the namespace node
`Returns`: | a new xmlNsPtr, or NULL in case of an error.

### xsltCopyNamespaceList ()

    xmlNsPtr	xsltCopyNamespaceList	(xsltTransformContextPtr ctxt,
    					 xmlNodePtr node,
    					 xmlNsPtr cur)

Do a copy of an namespace list. If @node is non-NULL the new namespaces are added automatically. This handles namespaces aliases. This function is intended only for *internal* use at transformation-time for copying ns-declarations of Literal Result Elements. Called by: xsltCopyTreeInternal() (transform.c) xsltShallowCopyElem() (transform.c) REVISIT: This function won't be used in the refactored code.

`ctxt`: | a transformation context
`node`: | the target node
`cur`: | the first namespace
`Returns`: | a new xmlNsPtr, or NULL in case of error.

### xsltFreeNamespaceAliasHashes ()

    void	xsltFreeNamespaceAliasHashes	(xsltStylesheetPtr style)

Free up the memory used by namespaces aliases

`style`: | an XSLT stylesheet

### xsltGetNamespace ()

    xmlNsPtr	xsltGetNamespace	(xsltTransformContextPtr ctxt,
    					 xmlNodePtr cur,
    					 xmlNsPtr ns,
    					 xmlNodePtr out)

Find a matching (prefix and ns-name) ns-declaration for the requested @ns->prefix and @ns->href in the result tree. If none is found then a new ns-declaration will be added to @resultElem. If, in this case, the given prefix is already in use, then a ns-declaration with a modified ns-prefix be we created. Called by: - xsltCopyPropList() (*not* anymore) - xsltShallowCopyElement() - xsltCopyTreeInternal() (*not* anymore) - xsltApplySequenceConstructor() (*not* in the refactored code), - xsltElement() (*not* anymore)

`ctxt`: | a transformation context
`cur`: | the input node
`ns`: | the namespace
`out`: | the output node (or its parent)
`Returns`: | a namespace declaration or NULL in case of namespace fixup failures or API or internal errors.

### xsltGetPlainNamespace ()

    xmlNsPtr	xsltGetPlainNamespace	(xsltTransformContextPtr ctxt,
    					 xmlNodePtr cur,
    					 xmlNsPtr ns,
    					 xmlNodePtr out)

Obsolete. *Not* called by any Libxslt/Libexslt function. Exaclty the same as xsltGetNamespace().

`ctxt`: | a transformation context
`cur`: | the input node
`ns`: | the namespace
`out`: | the result element
`Returns`: | a namespace declaration or NULL in case of namespace fixup failures or API or internal errors.

### xsltGetSpecialNamespace ()

    xmlNsPtr	xsltGetSpecialNamespace	(xsltTransformContextPtr ctxt,
    					 xmlNodePtr invocNode,
    					 const xmlChar * nsName,
    					 const xmlChar * nsPrefix,
    					 xmlNodePtr target)

Find a matching (prefix and ns-name) ns-declaration for the requested @nsName and @nsPrefix in the result tree. If none is found then a new ns-declaration will be added to @resultElem. If, in this case, the given prefix is already in use, then a ns-declaration with a modified ns-prefix be we created. Note that this function's priority is to preserve ns-prefixes; it will only change a prefix if there's a namespace clash. If both @nsName and @nsPrefix are NULL, then this will try to "undeclare" a default namespace by declaring an xmlns="".

`ctxt`: | the transformation context
`invocNode`: | the invoking node; e.g. a literal result element/attr; only used for error reports
`nsName`: | the namespace name (or NULL)
`nsPrefix`: | the suggested namespace prefix (or NULL)
`target`: | the result element on which to anchor a namespace
`Returns`: | a namespace declaration or NULL.

### xsltNamespaceAlias ()

    void	xsltNamespaceAlias		(xsltStylesheetPtr style,
    					 xmlNodePtr node)

Read the stylesheet-prefix and result-prefix attributes, register them as well as the corresponding namespace.

`style`: | the XSLT stylesheet
`node`: | the xsl:namespace-alias node