mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2026-01-07 21:58:22 +03:00
fixed bug #86753 on multiple identical attributes being generated, oops
* libxslt/transform.c: fixed bug #86753 on multiple identical attributes being generated, oops ... * tests/docs/Makefile.am tests/docs/bug-89.xml tests/general/Makefile.am tests/general/bug-89.*: added an example in the regression tests for this case Daniel
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
Fri Jul 5 22:27:47 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* libxslt/transform.c: fixed bug #86753 on multiple identical
|
||||
attributes being generated, oops ...
|
||||
* tests/docs/Makefile.am tests/docs/bug-89.xml
|
||||
tests/general/Makefile.am tests/general/bug-89.*: added an
|
||||
example in the regression tests for this case
|
||||
|
||||
Fri Jul 5 18:28:08 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* libxslt/preproc.c libxslt/transform.c: fixed bug #87279
|
||||
|
||||
@@ -2010,6 +2010,7 @@ xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
||||
#endif
|
||||
if (ctxt->insert->type == XML_ELEMENT_NODE) {
|
||||
xmlAttrPtr attr = (xmlAttrPtr) node, ret = NULL, cur;
|
||||
|
||||
if (attr->ns != NULL) {
|
||||
if (!xmlStrEqual(attr->ns->href, XSLT_NAMESPACE)) {
|
||||
ret = xmlCopyProp(ctxt->insert, attr);
|
||||
@@ -2022,8 +2023,29 @@ xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
||||
if (ret != NULL) {
|
||||
cur = ctxt->insert->properties;
|
||||
if (cur != NULL) {
|
||||
while (cur->next != NULL)
|
||||
/*
|
||||
* Avoid duplicates and insert at the end
|
||||
* of the attribute list
|
||||
*/
|
||||
while (cur->next != NULL) {
|
||||
if ((xmlStrEqual(cur->name, ret->name)) &&
|
||||
(((cur->ns == NULL) && (ret->ns == NULL)) ||
|
||||
((cur->ns != NULL) && (ret->ns != NULL) &&
|
||||
(xmlStrEqual(cur->ns->href,
|
||||
ret->ns->href))))) {
|
||||
xmlFreeProp(ret);
|
||||
return;
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
if ((xmlStrEqual(cur->name, ret->name)) &&
|
||||
(((cur->ns == NULL) && (ret->ns == NULL)) ||
|
||||
((cur->ns != NULL) && (ret->ns != NULL) &&
|
||||
(xmlStrEqual(cur->ns->href,
|
||||
ret->ns->href))))) {
|
||||
xmlFreeProp(ret);
|
||||
return;
|
||||
}
|
||||
cur->next = ret;
|
||||
ret->prev = cur;
|
||||
} else
|
||||
|
||||
@@ -88,6 +88,7 @@ EXTRA_DIST = \
|
||||
bug-86.xml \
|
||||
bug-87.xml \
|
||||
bug-88.xml \
|
||||
bug-89.xml \
|
||||
character.xml \
|
||||
array.xml \
|
||||
items.xml
|
||||
|
||||
13
tests/docs/bug-89.xml
Normal file
13
tests/docs/bug-89.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<todo>
|
||||
<domain id="id2588147" add="task" del="domain">
|
||||
<name id="id2588150" replace="PCDATA">job</name>
|
||||
<task id="id2588154" replace="PCDATA" add="task">to this</task>
|
||||
<task id="id2589156" replace="PCDATA" add="task">undefined</task>
|
||||
</domain>
|
||||
<domain id="id2588996" add="task" del="domain">
|
||||
<name id="id2588515" replace="PCDATA">courses</name>
|
||||
<task id="id2588931" replace="PCDATA" add="task">undefined</task>
|
||||
</domain>
|
||||
</todo>
|
||||
|
||||
@@ -91,6 +91,7 @@ EXTRA_DIST = \
|
||||
bug-86.out bug-86.xsl \
|
||||
bug-87.out bug-87.xsl \
|
||||
bug-88.out bug-88.xsl \
|
||||
bug-89.out bug-89.xsl \
|
||||
character.out character.xsl \
|
||||
character2.out character2.xsl \
|
||||
itemschoose.out itemschoose.xsl \
|
||||
|
||||
12
tests/general/bug-89.out
Normal file
12
tests/general/bug-89.out
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<todo>
|
||||
<domain add="task" del="domain" id="id2588147">
|
||||
<name replace="PCDATA" id="id2588150">job</name>
|
||||
<task replace="PCDATA" add="task" id="id2588154">to this</task>
|
||||
<task replace="PCDATA" add="task" id="id2589156">undefined</task>
|
||||
</domain>
|
||||
<domain add="task" del="domain" id="id2588996">
|
||||
<name replace="PCDATA" id="id2588515">courses</name>
|
||||
<task replace="PCDATA" add="task" id="id2588931">undefined</task>
|
||||
</domain>
|
||||
</todo>
|
||||
102
tests/general/bug-89.xsl
Normal file
102
tests/general/bug-89.xsl
Normal file
@@ -0,0 +1,102 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:output encoding="ISO-8859-1" method="xml"/>
|
||||
|
||||
<xsl:variable name="targetId"></xsl:variable>
|
||||
<xsl:variable name="action"></xsl:variable>
|
||||
<xsl:template match="/">
|
||||
<xsl:apply-templates select="*|@*"/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="toto">
|
||||
<toto/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="add">
|
||||
<xsl:param name="type"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$type = 'toto'">
|
||||
<xsl:call-template name="toto"/>
|
||||
</xsl:when>
|
||||
</xsl:choose> </xsl:template> <xsl:template name="copy">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
<xsl:template name="del">
|
||||
<!-- effacer ! -->
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="*[attribute::id and @id=$targetId]">
|
||||
<!-- attribute::type pour <20>viter de confondre l'absence d'attibute et
|
||||
la valeur nulle -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="$action='del'">
|
||||
<xsl:call-template name="del"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$action='add'">
|
||||
<xsl:call-template name="copy"/>
|
||||
<xsl:call-template name="add">
|
||||
<xsl:with-param name="type">toto</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$action='repl'">
|
||||
<xsl:when test="$action='del'">
|
||||
<xsl:call-template name="del"/>
|
||||
</xsl:when> <xsl:call-template name="add">
|
||||
<xsl:with-param name="type">toto</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:when> </xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- liste des elements qui peuvent <20>tre <20>dit<69>s, donc attribut id -->
|
||||
|
||||
<xsl:template match="domain">
|
||||
<xsl:copy>
|
||||
<xsl:if test="not(@id)">
|
||||
<xsl:attribute name="id"><xsl:value-of
|
||||
select="generate-id()"/></xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:attribute name="add">task</xsl:attribute>
|
||||
<xsl:attribute name="del">domain</xsl:attribute>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="name">
|
||||
<xsl:copy>
|
||||
<xsl:if test="not(@id)">
|
||||
<xsl:attribute name="id"><xsl:value-of
|
||||
select="generate-id()"/></xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:attribute name="replace">PCDATA</xsl:attribute>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="task">
|
||||
<xsl:copy>
|
||||
<xsl:if test="not(@id)">
|
||||
<xsl:attribute name="id"><xsl:value-of
|
||||
select="generate-id()"/></xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:attribute name="replace">PCDATA</xsl:attribute>
|
||||
<xsl:attribute name="add">task</xsl:attribute> <xsl:apply-templates select="node()|@*"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<xsl:template match="*">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
<xsl:template match="@*">
|
||||
<xsl:copy/>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
Reference in New Issue
Block a user