diff --git a/libxslt/templates.c b/libxslt/templates.c
index 42559210..88547ed8 100644
--- a/libxslt/templates.c
+++ b/libxslt/templates.c
@@ -645,11 +645,12 @@ xmlAttrPtr
xsltAttrListTemplateProcess(xsltTransformContextPtr ctxt,
xmlNodePtr target, xmlAttrPtr attrs)
{
- xmlAttrPtr attr, copy, last;
+ xmlAttrPtr attr, copy, last = NULL;
xmlNodePtr oldInsert, text;
xmlNsPtr origNs = NULL, copyNs = NULL;
const xmlChar *value;
xmlChar *valueAVT;
+ int hasAttr = 0;
if ((ctxt == NULL) || (target == NULL) || (attrs == NULL) ||
(target->type != XML_ELEMENT_NODE))
@@ -658,16 +659,35 @@ xsltAttrListTemplateProcess(xsltTransformContextPtr ctxt,
oldInsert = ctxt->insert;
ctxt->insert = target;
+ /*
+ * Apply attribute-sets.
+ */
+ attr = attrs;
+ do {
+#ifdef XSLT_REFACTORED
+ if ((attr->psvi == xsltXSLTAttrMarker) &&
+ xmlStrEqual(attr->name, (const xmlChar *)"use-attribute-sets"))
+ {
+ xsltApplyAttributeSet(ctxt, ctxt->node, (xmlNodePtr) attr, NULL);
+ }
+#else
+ if ((attr->ns != NULL) &&
+ xmlStrEqual(attr->name, (const xmlChar *)"use-attribute-sets") &&
+ xmlStrEqual(attr->ns->href, XSLT_NAMESPACE))
+ {
+ xsltApplyAttributeSet(ctxt, ctxt->node, (xmlNodePtr) attr, NULL);
+ }
+#endif
+ attr = attr->next;
+ } while (attr != NULL);
+
+ if (target->properties != NULL) {
+ hasAttr = 1;
+ }
+
/*
* Instantiate LRE-attributes.
*/
- if (target->properties) {
- last = target->properties;
- while (last->next != NULL)
- last = last->next;
- } else {
- last = NULL;
- }
attr = attrs;
do {
/*
@@ -703,35 +723,7 @@ xsltAttrListTemplateProcess(xsltTransformContextPtr ctxt,
value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0);
/*
- * Create a new attribute.
- */
- copy = xmlNewDocProp(target->doc, attr->name, NULL);
- if (copy == NULL) {
- if (attr->ns) {
- xsltTransformError(ctxt, NULL, attr->parent,
- "Internal error: Failed to create attribute '{%s}%s'.\n",
- attr->ns->href, attr->name);
- } else {
- xsltTransformError(ctxt, NULL, attr->parent,
- "Internal error: Failed to create attribute '%s'.\n",
- attr->name);
- }
- goto error;
- }
- /*
- * Attach it to the target element.
- */
- copy->parent = target;
- if (last == NULL) {
- target->properties = copy;
- last = copy;
- } else {
- last->next = copy;
- copy->prev = last;
- last = copy;
- }
- /*
- * Set the namespace. Avoid lookups of same namespaces.
+ * Get the namespace. Avoid lookups of same namespaces.
*/
if (attr->ns != origNs) {
origNs = attr->ns;
@@ -748,7 +740,47 @@ xsltAttrListTemplateProcess(xsltTransformContextPtr ctxt,
} else
copyNs = NULL;
}
- copy->ns = copyNs;
+ /*
+ * Create a new attribute.
+ */
+ if (hasAttr) {
+ copy = xmlSetNsProp(target, copyNs, attr->name, NULL);
+ } else {
+ /*
+ * Avoid checking for duplicate attributes if there aren't
+ * any attribute sets.
+ */
+ copy = xmlNewDocProp(target->doc, attr->name, NULL);
+
+ if (copy != NULL) {
+ copy->ns = copyNs;
+
+ /*
+ * Attach it to the target element.
+ */
+ copy->parent = target;
+ if (last == NULL) {
+ target->properties = copy;
+ last = copy;
+ } else {
+ last->next = copy;
+ copy->prev = last;
+ last = copy;
+ }
+ }
+ }
+ if (copy == NULL) {
+ if (attr->ns) {
+ xsltTransformError(ctxt, NULL, attr->parent,
+ "Internal error: Failed to create attribute '{%s}%s'.\n",
+ attr->ns->href, attr->name);
+ } else {
+ xsltTransformError(ctxt, NULL, attr->parent,
+ "Internal error: Failed to create attribute '%s'.\n",
+ attr->name);
+ }
+ goto error;
+ }
/*
* Set the value.
@@ -803,30 +835,6 @@ next_attribute:
attr = attr->next;
} while (attr != NULL);
- /*
- * Apply attribute-sets.
- * The creation of such attributes will not overwrite any existing
- * attribute.
- */
- attr = attrs;
- do {
-#ifdef XSLT_REFACTORED
- if ((attr->psvi == xsltXSLTAttrMarker) &&
- xmlStrEqual(attr->name, (const xmlChar *)"use-attribute-sets"))
- {
- xsltApplyAttributeSet(ctxt, ctxt->node, (xmlNodePtr) attr, NULL);
- }
-#else
- if ((attr->ns != NULL) &&
- xmlStrEqual(attr->name, (const xmlChar *)"use-attribute-sets") &&
- xmlStrEqual(attr->ns->href, XSLT_NAMESPACE))
- {
- xsltApplyAttributeSet(ctxt, ctxt->node, (xmlNodePtr) attr, NULL);
- }
-#endif
- attr = attr->next;
- } while (attr != NULL);
-
ctxt->insert = oldInsert;
return(target->properties);
diff --git a/tests/REC/test-7.1.4.out b/tests/REC/test-7.1.4.out
index bd366cd3..367af25f 100644
--- a/tests/REC/test-7.1.4.out
+++ b/tests/REC/test-7.1.4.out
@@ -1,6 +1,6 @@
-this is the heading
+this is the heading
diff --git a/tests/docbook/result/fo/gdp-handbook.fo b/tests/docbook/result/fo/gdp-handbook.fo
index 83d7d217..2300ebff 100644
--- a/tests/docbook/result/fo/gdp-handbook.fo
+++ b/tests/docbook/result/fo/gdp-handbook.fo
@@ -92,11 +92,11 @@
The GNOME Handbook of Writing Software Documentation
- David MasonRed Hat, Inc.
+ David MasonRed Hat, Inc.
<dcm@redhat.com>
- Daniel Mueth
+ Daniel Mueth
<d-mueth@uchicago.edu>
- Alexander Kirillov
+ Alexander Kirillov
<kirillov@math.sunysb.edu>
@@ -382,7 +382,7 @@
people to make announcements and suggestions and to discuss
issues in the comments section.
-
+
Note
Note that the information in the
@@ -409,7 +409,7 @@
source nature of SGML. To contribute to the GDP you should
learn to use DocBook.
-
+
NOTE
To get started writing for the GDP you do not need to rush
@@ -490,8 +490,8 @@
DTD's. To install the GDP custom DTD with PNG image support
by hand:
-
-
+
+
•
@@ -506,7 +506,7 @@
-
+
•
@@ -517,11 +517,11 @@
distribution. (On Red Hat it is usually in
/usr/lib/sgml/CATALOG.) Add the following line to this
file:
-
+
PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.0//EN" "png-support-3.0.dtd"
If you are using the 3.1 DTD, use:
-
+
PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN" "png-support-3.1.dtd"
@@ -540,14 +540,14 @@ PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN" "png-support-3.1.dtd"
Articles:
-
+
<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant
V1.1//EN"[]>
Books:
-
+
<!DOCTYPE Book PUBLIC "-//GNOME//DTD DocBook PNG Variant
V1.1//EN"[]>
@@ -620,7 +620,7 @@ V1.1//EN"[]>
mydocument.sgml, after which you can print out or
view the resulting .ps file.
-
+
NOTE
The html files you get will not look quite the same as the
@@ -656,7 +656,7 @@ V1.1//EN"[]>
include the extension of the image file, since DocBook
Tools will automatically insert it for you. For example:
-
+
<figure>
<title>My Image</title>
@@ -700,8 +700,8 @@ V1.1//EN"[]>
The following resources on the web are useful for learning
DocBook:
-
-
+
+
•
@@ -715,7 +715,7 @@ V1.1//EN"[]>
-
+
•
@@ -728,7 +728,7 @@ V1.1//EN"[]>
-
+
•
@@ -742,7 +742,7 @@ V1.1//EN"[]>
-
+
•
@@ -766,8 +766,8 @@ V1.1//EN"[]>
The following sections of this document are designed to help
documentation authors write correct and consistent DocBook:
-
-
+
+
•
@@ -1373,8 +1373,8 @@ V1.1//EN"[]>
advised that the documentation writers conform to XML
syntax rules. Here are most important differences:
-
-
+
+
Minimization
@@ -1395,7 +1395,7 @@ V1.1//EN"[]>
-
+
Self-closing tags
@@ -1415,7 +1415,7 @@ V1.1//EN"[]>
-
+
Case sensitive tags
@@ -1487,7 +1487,7 @@ V1.1//EN"[]>
<note>, <tip>,
<warning>,
<important> respectively. For example:
-
+
<tip>
<title>TIP</title>
@@ -1521,7 +1521,7 @@ V1.1//EN"[]>
To include screenshots and other figures, use the following
tags:
-
+
<figure id="shot1">
<title>Screenshot</title>
@@ -1537,7 +1537,7 @@ V1.1//EN"[]>
Screenshot
-
+
NOTE
Notice in this example that the screenshot file name does
@@ -1557,7 +1557,7 @@ V1.1//EN"[]>
To show a file fragment--for example, program
listing--use <programlisting> tag:
-
+
<programlisting>
[Desktop Entry]
@@ -1569,7 +1569,7 @@ Type=Application
</programlisting>
which produces
-
+
[Desktop Entry]
Name=Gnumeric spreadsheet
Exec=gnumeric
@@ -1584,7 +1584,7 @@ Type=Application
To show a record of terminal session--i.e., sequence of
commands entered at the command line--use
<screen> tag:
-
+
<screen>
<prompt>bash$</prompt><userinput>make love</userinput>
@@ -1592,14 +1592,14 @@ make: *** No rule to make target `love'. Stop.
</screen>
which produces
-
+
bash$make love
make: *** No rule to make target `love'. Stop.
Note the use of tags <prompt> and
<userinput> for marking system prompt
and commands entered by user.
- NOTE
+ NOTE
Note that both <programlisting>
and <screen> preserve linebreaks,
but interpret SGML tags (unlike LaTeX
@@ -1623,8 +1623,8 @@ make: *** No rule to make target `love'. Stop.
<orderedlist>, and
<variablelist>.
-
-
+
+
<itemizedlist>
@@ -1634,7 +1634,7 @@ make: *** No rule to make target `love'. Stop.
This is the simplest unnumbered list, parallel to
<ul> in HTML. Here is an example:
-
+
<itemizedlist>
<listitem>
@@ -1663,8 +1663,8 @@ make: *** No rule to make target `love'. Stop.
and output:
-
-
+
+
•
@@ -1676,7 +1676,7 @@ make: *** No rule to make target `love'. Stop.
-
+
•
@@ -1689,7 +1689,7 @@ make: *** No rule to make target `love'. Stop.
-
+
•
@@ -1718,7 +1718,7 @@ make: *** No rule to make target `love'. Stop.
-
+
<orderedlist>
@@ -1741,7 +1741,7 @@ make: *** No rule to make target `love'. Stop.
-
+
<variablelist>
@@ -1758,7 +1758,7 @@ make: *** No rule to make target `love'. Stop.
computer to search. The lines you are reading now were
produced by <variablelist>. The
source looked liked this:
-
+
<variablelist>
<varlistentry>
@@ -1812,8 +1812,8 @@ make: *** No rule to make target `love'. Stop.
-
-
+
+
•
@@ -1824,7 +1824,7 @@ make: *** No rule to make target `love'. Stop.
-
+
•
@@ -1839,7 +1839,7 @@ make: *** No rule to make target `love'. Stop.
-
+
•
@@ -1850,7 +1850,7 @@ make: *** No rule to make target `love'. Stop.
-
+
•
@@ -1860,7 +1860,7 @@ make: *** No rule to make target `love'. Stop.
-
+
•
@@ -1871,7 +1871,7 @@ make: *** No rule to make target `love'. Stop.
-
+
•
@@ -1888,7 +1888,7 @@ make: *** No rule to make target `love'. Stop.
Main Menu->Utilities->GNOME
terminal
there is a special construction for this, too:
-
+
<menuchoice>
<guimenu>Main Menu</guimenu> <guisubmenu>Utilities</guisubmenu>
@@ -1911,7 +1911,7 @@ make: *** No rule to make target `love'. Stop.
automatically inserts the full name of the element you refer
to (section, figure, etc.), while the second just creates a
link (in HTML output). Here is an example:
-
+
An example of a <link linkend="extip">tip</link> was given in
<xref linkend="notes" />.
@@ -1925,7 +1925,7 @@ An example of a <link linkend="extip">tip</link> was given in
To produce a link to an external source, such as a
Web page or a local file, use <ulink>
tag, for example:
-
+
To find more about GNOME, please visit <ulink type="http"
url="http://www.gnome.org">GNOME Web page</ulink>
@@ -1951,8 +1951,8 @@ url="http://www.gnome.org">GNOME Web page</ulink>
Here are some tags used to describe operating system-related
things:
-
-
+
+
•
@@ -1966,7 +1966,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
-
+
•
@@ -1980,7 +1980,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
-
+
•
@@ -1994,7 +1994,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
-
+
•
@@ -2006,7 +2006,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
-
+
•
@@ -2020,7 +2020,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
-
+
•
@@ -2066,7 +2066,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
To mark up a combination of keystrokes, use the
<keycombo> wrapper:
-
+
<keycombo>
<keycap>Ctrl</keycap>
@@ -2078,7 +2078,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
Finally, if you want to show a shortcut for some menu
command, here are the appropriate tags (rather long):
-
+
<menuchoice>
<shortcut>
@@ -2101,7 +2101,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
To mark up e-mail
address, use <email>:
-
+
The easiest way to get in touch with me is by e-mail
(<email>me@mydomain.com</email>)
@@ -2131,8 +2131,8 @@ url="http://www.gnome.org">GNOME Web page</ulink>
here is partial list of most commonly used enitites:
-
-
+
+
•
@@ -2142,7 +2142,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
-
+
•
@@ -2152,7 +2152,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
-
+
•
@@ -2162,7 +2162,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
-
+
•
@@ -2172,7 +2172,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
-
+
•
@@ -2260,7 +2260,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
Application documentation should identify the version of the
application for which the documentation is written:
-
+
<sect1 id="intro">
<title>Introduction</title>
@@ -2336,7 +2336,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
PNG format only) when appropriate. They should also describe
each feature and preference option available.
-
+
Documentation Availability
Applications and applets should not rely on documentation
@@ -2352,7 +2352,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
versions 1.x and the templates in the section called “Template 2: Applet Manual For GNOME 2.x”
for GNOME versions 2.x.
-
+
Manuals For Large Applications
Manuals for very large applications, such as GNOME Workshop
@@ -2363,7 +2363,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
<sect1>).
-
+
Applet Manuals in GNOME 2.0
Note that applet manuals in GNOME 2.0 are treated in a special
@@ -2393,7 +2393,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
-
+
Developer Information
This section is for developers. Documentation authors
@@ -2406,7 +2406,7 @@ url="http://www.gnome.org">GNOME Web page</ulink>
Help menu at the top right of the
application. To do this, you must first write a
topic.dat file. The format for this file is:
-
+
One line for each 'topic'.
Two columns, as defined by perl -e 'split(/\s+/,$aline,2)'
@@ -2418,7 +2418,7 @@ Second column is the user-visible topic name.
For example, Gnumeric's
topic.dat file is:
-
+
gnumeric.html Gnumeric manual
function-reference.html Gnumeric function reference
@@ -2430,7 +2430,7 @@ function-reference.html Gnumeric function reference
from SGML into HTML with db2html) should be
placed in this directory too.
-
+
Note
If the help files are not present in the correct directory, the
@@ -2441,7 +2441,7 @@ function-reference.html Gnumeric function reference
The topic.dat file is used by the GNOME
menu building code to generate the Help
menu. When you define your menu:
-
+
GnomeUIInfo helpmenu[] = {
{GNOME_APP_UI_ITEM,
N_("About"), N_("Info about this program"),
@@ -2470,7 +2470,7 @@ GnomeUIInfo helpmenu[] = {
-
+
Developer Information
This section is for developers. Documentation authors
@@ -2494,7 +2494,7 @@ GnomeUIInfo helpmenu[] = {
To make the Help buttons call the correct document in the GNOME Help
Browser the developer should add code based on the following example:
-
+
gchar *tmp;
tmp = gnome_help_file_find_file ("module", "page.html");
if (tmp) {
@@ -2502,7 +2502,7 @@ if (tmp) {
g_free(tmp);
}
-
+
NOTE
The example above is in the C language, please refer to other
@@ -2572,7 +2572,7 @@ if (tmp) {
-
+
Developer Information
This section is for developers. Documentation authors
@@ -2588,7 +2588,7 @@ if (tmp) {
To add an applet's manual to its applet menu, use:
-
+
/* add an item to the applet menu */
applet_widget_register_callback(APPLET_WIDGET(applet), "manual",
_("Manual"), &open_manual, NULL);
@@ -2608,7 +2608,7 @@ _("Manual"), &open_manual, NULL);
You will also want to add an About menu
item to the applet's menu. This is a
stock menu item and is done:
-
+
applet_widget_register_stock_callback (APPLET_WIDGET(applet), "about",
GNOME_STOCK_MENU_ABOUT, _("About"), &my_applet_cb_about,
NULL);
@@ -2740,7 +2740,7 @@ applet_widget_register_stock_callback (APPLET_WIDGET(applet), "about",
Just as you need to juggle expert and novice readers,
you'll have to juggle a number of other extremes as you write:
- •
+ •
Documents should be complete, yet concise. You should
describe every feature, but you'll have decide how much
detail is really necessary. It's not, for example,
@@ -2750,7 +2750,7 @@ applet_widget_register_stock_callback (APPLET_WIDGET(applet), "about",
you spend fewer words on the obvious, you can spend more
time clarifying the ambiguous labels and explaining
items that are more complex.
- •
+ •
Be engaging and friendly, yet professional. Games
documents may be less formal than productivity
application documents (people don't
@@ -2759,14 +2759,14 @@ applet_widget_register_stock_callback (APPLET_WIDGET(applet), "about",
maintain a standard of style which holds the reader's
interest without resorting to jokes and untranslatable
allusions or puns.
- •
+ •
Examples, tips, notes, and screenshots are useful to
break up long stretches of text, but too many can get in
the way, and make your documents too choppy to read.
It's good to provide a screenshot of any dialog windows
a user might run into, but if a dialog box has several
tabs, it's not usually necessary to have one for each.
- •
+ •
The GDP strives to have all of its documentation conform
to certain standards of style and content, but every
document (and every writer) is different. You will need
@@ -3055,7 +3055,7 @@ applet_widget_register_stock_callback (APPLET_WIDGET(applet), "about",
manuals. You can always get the latest copy of this
template from GDP
Documentation Templates [http://developer.gnome.org/projects/gdp/templates.html].
-
+
<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
@@ -3809,7 +3809,7 @@ applet_widget_register_stock_callback (APPLET_WIDGET(applet), "about",
where
appletname is
the name of the applet.
-
+
<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
@@ -3889,7 +3889,7 @@ applet_widget_register_stock_callback (APPLET_WIDGET(applet), "about",
-
+
<!-- Template Version: 1.0.1 (do not remove this line) -->
@@ -4148,7 +4148,7 @@ applet_widget_register_stock_callback (APPLET_WIDGET(applet), "about",
the applet document.
-
+
<!DOCTYPE book PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
<!ENTITY TEMPLATE-APPLET SYSTEM "gnome-applet-template.sgml.part">
@@ -4603,7 +4603,7 @@ applet_widget_register_stock_callback (APPLET_WIDGET(applet), "about",
-
+
<!-- Please replace everywhere below GNOMEAPPLET with the name of -->
diff --git a/tests/docs/bug-217.xml b/tests/docs/bug-217.xml
new file mode 100644
index 00000000..f1999f80
--- /dev/null
+++ b/tests/docs/bug-217.xml
@@ -0,0 +1 @@
+
diff --git a/tests/general/bug-217.out b/tests/general/bug-217.out
new file mode 100644
index 00000000..7120b6a1
--- /dev/null
+++ b/tests/general/bug-217.out
@@ -0,0 +1,2 @@
+
+
diff --git a/tests/general/bug-217.xsl b/tests/general/bug-217.xsl
new file mode 100644
index 00000000..d981aa90
--- /dev/null
+++ b/tests/general/bug-217.xsl
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+ as1
+ as1
+ as1
+ as1
+
+
+
+ as2
+ as2
+ as2
+
+
+
+
+ attr
+
+
+