xsltGetNamespace: : a transformation context : the input node : the namespace : the output node (or its parent)
Find a matching (prefix and ns-name) ns-declaration for the requested ->prefix and ->href in the result tree. If none is found then a new ns-declaration will be added to . 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:
Returns a namespace declaration or NULL in case of namespace fixup failures or API or internal errors.
Definition at line 634 of file namespaces.c.
Referenced by xsltApplySequenceConstructor(), xsltAttrListTemplateProcess(), xsltAttrTemplateProcess(), xsltGetPlainNamespace(), and xsltShallowCopyElem().
{
if (ns == NULL)
return(NULL);
#ifdef XSLT_REFACTORED
return(xsltGetSpecialNamespace(ctxt, cur, ns->href, ns->prefix, out));
#else
{
xsltStylesheetPtr style;
const xmlChar *URI = NULL;
if ((ctxt == NULL) || (cur == NULL) || (out == NULL))
return(NULL);
style = ctxt->style;
while (style != NULL) {
if (style->nsAliases != NULL)
URI = (const xmlChar *)
xmlHashLookup(style->nsAliases, ns->href);
if (URI != NULL)
break;
style = xsltNextImport(style);
}
if (URI == UNDEFINED_DEFAULT_NS) {
return(xsltGetSpecialNamespace(ctxt, cur, NULL, NULL, out));
#if 0
xmlNsPtr dflt;
dflt = xmlSearchNs(cur->doc, cur, NULL);
if (dflt != NULL)
URI = dflt->href;
else
return NULL;
#endif
} else if (URI == NULL)
URI = ns->href;
return(xsltGetSpecialNamespace(ctxt, cur, URI, ns->prefix, out));
}
#endif
}