As you discovered, when an element has a id generated for it, it is always the same id. That's an important feature that allows tables of contents to work, since the same element must be processed in two modes and the link must match.

I see you tried to use xsl:copy-of, but I'm not clear on how you are using it. The problem with xsl:copy-of is that it copies everything, including the id attribute. Instead, you could try using something more like an identity template with a twist, the twist being to omit any id attributes. Something like this:

<xsl:template match="*" mode="copy.mode">
 <xsl:copy>
   <xsl:copy-of select="@*[local-name() != 'id']">
   <xsl:apply-templates mode="copy.mode"/>
 </xsl:copy>
</xsl:template>

This should filter out the id attributes on the copy.

Bob Stayton
Sagehill Enterprises
[email protected]


----- Original Message ----- From: "Brad Smith" <[email protected]>
To: <[email protected]>
Sent: Thursday, April 15, 2010 1:47 PM
Subject: [docbook] How can I render an element twice without duplicating the ID?


Hello all,

I am working on stylesheets for a book that will have Q/As and
task-descriptions in it. I want to display the <qandaentry>s without
<answer>s, and the task <step>s without <example>s by default, then
reprint each element in its entirety (ie with answers and examples) in
an appendix at the end.

The approach I'm taking is to override the templates for qandaentry
and step so that they omit the "answer" elements by default, then
create mode="answers-section" templates for them that do include the
answers, and call those at the end of the book template.

The problem I am encountering is that the default fo output
stylesheets, upon which I'm basing mine, add id elements to nearly
everything, it seems, and generate-id() always seems to generate the
same value when run against the same element, even if it's being run a
second time. I've even tried using <xsl:copy-of> to avoid duplicating
IDs, and so far no luck (though I might just not be using it right
yet), and since fop dies if there are two elements with the same ID,
building a pdf fails.

So, I my questions are:
1) Is this a sane way to go about what I want to accomplish?
2a) If so, how can I avoid getting duplicate IDs?
2b) If not, suggestions?

Thanks!
--Brad

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]






---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to