mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2025-11-05 12:10:38 +03:00
Fix precedence with multiple attribute sets
Move the duplicate attribute check from xsltAttributeInternal to xsltMergeAttrSets. Fixes bug 764411: https://bugzilla.gnome.org/show_bug.cgi?id=764411
This commit is contained in:
@@ -343,9 +343,14 @@ xsltMergeAttrSets(xsltAttrSetPtr set, xsltAttrSetPtr other) {
|
|||||||
cur = set->attrs;
|
cur = set->attrs;
|
||||||
add = 1;
|
add = 1;
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
/*
|
xsltStylePreCompPtr curComp = cur->attr->psvi;
|
||||||
* TODO: Compare attrs by name.
|
xsltStylePreCompPtr oldComp = old->attr->psvi;
|
||||||
*/
|
|
||||||
|
if ((curComp->name == oldComp->name) &&
|
||||||
|
(curComp->ns == oldComp->ns)) {
|
||||||
|
add = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (cur->next == NULL)
|
if (cur->next == NULL)
|
||||||
break;
|
break;
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
@@ -459,8 +464,15 @@ xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur) {
|
|||||||
xsltGenericDebug(xsltGenericDebugContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"add attribute to list %s\n", ncname);
|
"add attribute to list %s\n", ncname);
|
||||||
#endif
|
#endif
|
||||||
|
if (child->psvi == NULL) {
|
||||||
|
xsltTransformError(NULL, style, child,
|
||||||
|
"xsl:attribute-set : internal error, attribute %s not "
|
||||||
|
"compiled\n", child->name);
|
||||||
|
}
|
||||||
|
else {
|
||||||
set->attrs = xsltAddAttrElemList(set->attrs, child);
|
set->attrs = xsltAddAttrElemList(set->attrs, child);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
child = child->next;
|
child = child->next;
|
||||||
}
|
}
|
||||||
@@ -700,21 +712,19 @@ xsltResolveStylesheetAttributeSet(xsltStylesheetPtr style) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xsltAttributeInternal:
|
* xsltAttribute:
|
||||||
* @ctxt: a XSLT process context
|
* @ctxt: a XSLT process context
|
||||||
* @node: the current node in the source tree
|
* @node: the current node in the source tree
|
||||||
* @inst: the xsl:attribute element
|
* @inst: the xsl:attribute element
|
||||||
* @comp: precomputed information
|
* @comp: precomputed information
|
||||||
* @fromAttributeSet: the attribute comes from an attribute-set
|
|
||||||
*
|
*
|
||||||
* Process the xslt attribute node on the source node
|
* Process the xslt attribute node on the source node
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
xsltAttributeInternal(xsltTransformContextPtr ctxt,
|
xsltAttribute(xsltTransformContextPtr ctxt,
|
||||||
xmlNodePtr contextNode,
|
xmlNodePtr contextNode,
|
||||||
xmlNodePtr inst,
|
xmlNodePtr inst,
|
||||||
xsltStylePreCompPtr castedComp,
|
xsltStylePreCompPtr castedComp)
|
||||||
int fromAttributeSet)
|
|
||||||
{
|
{
|
||||||
#ifdef XSLT_REFACTORED
|
#ifdef XSLT_REFACTORED
|
||||||
xsltStyleItemAttributePtr comp =
|
xsltStyleItemAttributePtr comp =
|
||||||
@@ -754,7 +764,7 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt,
|
|||||||
|
|
||||||
if (comp == NULL) {
|
if (comp == NULL) {
|
||||||
xsltTransformError(ctxt, NULL, inst,
|
xsltTransformError(ctxt, NULL, inst,
|
||||||
"Internal error in xsltAttributeInternal(): "
|
"Internal error in xsltAttribute(): "
|
||||||
"The XSLT 'attribute' instruction was not compiled.\n");
|
"The XSLT 'attribute' instruction was not compiled.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -919,19 +929,6 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt,
|
|||||||
nsName = ns->href;
|
nsName = ns->href;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromAttributeSet) {
|
|
||||||
/*
|
|
||||||
* This tries to ensure that xsl:attribute(s) coming
|
|
||||||
* from an xsl:attribute-set won't override attribute of
|
|
||||||
* literal result elements or of explicit xsl:attribute(s).
|
|
||||||
* URGENT TODO: This might be buggy, since it will miss to
|
|
||||||
* overwrite two equal attributes both from attribute sets.
|
|
||||||
*/
|
|
||||||
attr = xmlHasNsProp(targetElem, name, nsName);
|
|
||||||
if (attr != NULL)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find/create a matching ns-decl in the result tree.
|
* Find/create a matching ns-decl in the result tree.
|
||||||
*/
|
*/
|
||||||
@@ -1081,21 +1078,6 @@ error:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* xsltAttribute:
|
|
||||||
* @ctxt: a XSLT process context
|
|
||||||
* @node: the node in the source tree.
|
|
||||||
* @inst: the xslt attribute node
|
|
||||||
* @comp: precomputed information
|
|
||||||
*
|
|
||||||
* Process the xslt attribute node on the source node
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|
||||||
xmlNodePtr inst, xsltStylePreCompPtr comp) {
|
|
||||||
xsltAttributeInternal(ctxt, node, inst, comp, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xsltApplyAttributeSet:
|
* xsltApplyAttributeSet:
|
||||||
* @ctxt: the XSLT stylesheet
|
* @ctxt: the XSLT stylesheet
|
||||||
@@ -1198,8 +1180,8 @@ xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
xsltAttrElemPtr cur = set->attrs;
|
xsltAttrElemPtr cur = set->attrs;
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
if (cur->attr != NULL) {
|
if (cur->attr != NULL) {
|
||||||
xsltAttributeInternal(ctxt, node, cur->attr,
|
xsltAttribute(ctxt, node, cur->attr,
|
||||||
cur->attr->psvi, 1);
|
cur->attr->psvi);
|
||||||
}
|
}
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user