* *
************************************************************************/
-#ifdef XSLT_REFACTORED
+#ifdef XSLT_REFACTORED
static xsltNsAliasPtr
xsltNewNsAlias(xsltCompilerCtxtPtr cctxt)
{
cctxt->style->errors++;
return(NULL);
}
- memset(ret, 0, sizeof(xsltNsAlias));
+ memset(ret, 0, sizeof(xsltNsAlias));
/*
* TODO: Store the item at current stylesheet-level.
*/
ret->next = cctxt->nsAliases;
- cctxt->nsAliases = ret;
+ cctxt->nsAliases = ret;
return(ret);
}
xmlChar *stylePrefix = NULL;
xmlNsPtr literalNs = NULL;
xmlNsPtr targetNs = NULL;
-
-#ifdef XSLT_REFACTORED
+
+#ifdef XSLT_REFACTORED
xsltNsAliasPtr alias;
if ((style == NULL) || (node == NULL))
/*
* NOTE that the XSLT 2.0 also *does* use the NULL namespace if
* "#default" is used and there's no default namespace is scope.
- * I.e., this is *not* an error.
+ * I.e., this is *not* an error.
* Most XSLT 1.0 implementations work this way.
- * The XSLT 1.0 spec has nothing to say on the subject.
+ * The XSLT 1.0 spec has nothing to say on the subject.
*/
/*
* Attribute "stylesheet-prefix".
return;
}
if (xmlStrEqual(stylePrefix, (const xmlChar *)"#default"))
- literalNs = xmlSearchNs(node->doc, node, NULL);
+ literalNs = xmlSearchNs(node->doc, node, NULL);
else {
literalNs = xmlSearchNs(node->doc, node, stylePrefix);
if (literalNs == NULL) {
xsltTransformError(NULL, style, node,
"The attribute 'result-prefix' is missing.\n");
goto error;
- }
+ }
if (xmlStrEqual(resultPrefix, (const xmlChar *)"#default"))
targetNs = xmlSearchNs(node->doc, node, NULL);
else {
* result-prefix="foo"/>
* From no namespace to namespace.
*/
-
-
+
+
/*
* Store the ns-node in the alias-object.
*/
#else /* XSLT_REFACTORED */
const xmlChar *literalNsName;
const xmlChar *targetNsName;
-
+
if ((style == NULL) || (node == NULL))
return;
"namespace-alias: result-prefix attribute missing\n");
goto error;
}
-
+
if (xmlStrEqual(stylePrefix, (const xmlChar *)"#default")) {
literalNs = xmlSearchNs(node->doc, node, NULL);
if (literalNs == NULL) {
literalNsName = literalNs->href; /* Yes - set for nsAlias table */
} else {
literalNs = xmlSearchNs(node->doc, node, stylePrefix);
-
+
if ((literalNs == NULL) || (literalNs->href == NULL)) {
xsltTransformError(NULL, style, node,
"namespace-alias: prefix %s not bound to any namespace\n",
* Special case: if #default is used for
* the stylesheet-prefix (literal namespace) and there's no default
* namespace in scope, we'll use style->defaultAlias for this.
- */
+ */
if (literalNsName == NULL) {
if (targetNs != NULL) {
/*
* BUG TODO: Is it not sufficient to have only 1 field for
* this, since subsequently alias declarations will
- * overwrite this.
+ * overwrite this.
* Example:
* <xsl:namespace-alias result-prefix="foo"
* stylesheet-prefix="#default"/>
/*
* OPTIMIZE TODO: This all could be optimized by keeping track of
* the ns-decls currently in-scope via a specialized context.
- */
+ */
if ((nsPrefix == NULL) && ((nsName == NULL) || (nsName[0] == 0))) {
/*
* NOTE: the "undeclaration" of the default namespace was
}
ns = ns->next;
} while (ns != NULL);
- }
+ }
if ((target->parent != NULL) &&
(target->parent->type == XML_ELEMENT_NODE))
{
*/
if (target->parent->ns == NULL)
return(NULL);
-
+
ns = xmlSearchNs(target->doc, target->parent,
NULL);
/*
*/
if ((ns == NULL) || (ns->href == NULL) || (ns->href[0] == 0))
return(NULL);
-
+
/*
* Undeclare the default namespace.
*/
xmlNewNs(target, BAD_CAST "", NULL);
- /* TODO: Check result */
+ /* TODO: Check result */
return(NULL);
}
return(NULL);
* If the ns-prefix is occupied by an other ns-decl on the
* result element, then this means:
* 1) The desired prefix is shadowed
- * 2) There's no way around changing the prefix
+ * 2) There's no way around changing the prefix
*
* Try a desperate search for an in-scope ns-decl
* with a matching ns-name before we use the last option,
/*
* Fallback to changing the prefix.
- */
+ */
} else if ((target->parent != NULL) &&
(target->parent->type == XML_ELEMENT_NODE))
{
*
* Check the common case: The parent element of the current
* result element is in the same namespace (with an equal ns-prefix).
- */
+ */
if ((target->parent->ns != NULL) &&
((target->parent->ns->prefix != NULL) == (nsPrefix != NULL)))
{
ns = target->parent->ns;
-
+
if (nsPrefix == NULL) {
if (xmlStrEqual(ns->href, nsName))
return(ns);
}
/*
* Lookup the remaining in-scope namespaces.
- */
+ */
ns = xmlSearchNs(target->doc, target->parent, nsPrefix);
if (ns != NULL) {
if (xmlStrEqual(ns->href, nsName))
- return(ns);
+ return(ns);
/*
* Now check for a nasty case: We need to ensure that the new
* ns-decl won't shadow a prefix in-use by an existing attribute.
int counter = 1;
if (nsPrefix == NULL) {
- nsPrefix = "ns";
+ nsPrefix = BAD_CAST "ns";
}
do {
xmlNsPtr
xsltGetNamespace(xsltTransformContextPtr ctxt, xmlNodePtr cur, xmlNsPtr ns,
xmlNodePtr out)
-{
-
+{
+
if (ns == NULL)
return(NULL);
style = ctxt->style;
while (style != NULL) {
if (style->nsAliases != NULL)
- URI = (const xmlChar *)
+ 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
* namespace in the stylesheet then this must resolve to
* the NULL namespace.
*/
- xmlNsPtr dflt;
+ xmlNsPtr dflt;
dflt = xmlSearchNs(cur->doc, cur, NULL);
if (dflt != NULL)
URI = dflt->href;
* @ns: the namespace
* @out: the result element
*
- * Obsolete.
+ * Obsolete.
* *Not* called by any Libxslt/Libexslt function.
- * Exaclty the same as xsltGetNamespace().
+ * Exaclty the same as xsltGetNamespace().
*
* Returns a namespace declaration or NULL in case of
* namespace fixup failures or API or internal errors.
xmlNsPtr
xsltGetPlainNamespace(xsltTransformContextPtr ctxt, xmlNodePtr cur,
xmlNsPtr ns, xmlNodePtr out)
-{
+{
return(xsltGetNamespace(ctxt, cur, ns, out));
}
* 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)
xsltCopyNamespaceList(xsltTransformContextPtr ctxt, xmlNodePtr node,
xmlNsPtr cur) {
xmlNsPtr ret = NULL, tmp;
- xmlNsPtr p = NULL,q;
+ xmlNsPtr p = NULL,q;
if (cur == NULL)
return(NULL);
if (node != NULL) {
if ((node->ns != NULL) &&
(xmlStrEqual(node->ns->prefix, cur->prefix)) &&
- (xmlStrEqual(node->ns->href, cur->href))) {
+ (xmlStrEqual(node->ns->href, cur->href))) {
cur = cur->next;
continue;
}
xmlNsPtr
xsltCopyNamespace(xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED,
xmlNodePtr elem, xmlNsPtr ns)
-{
+{
if ((ns == NULL) || (ns->type != XML_NAMESPACE_DECL))
return(NULL);
/*