Re: [xsl] Using for-each w/ page-sequence results in "NC105 ID already exists in this document" error

Subject: Re: [xsl] Using for-each w/ page-sequence results in "NC105 ID already exists in this document" error
From: Tony Graham <Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 20 Sep 2007 16:48:05 +0100
On Thu, Sep 20 2007 14:56:29 +0100, Sharon_Harris@xxxxxxxxxxxxxxxxxxxx wrote:
> Before trying the for-each, I had all the page sequences contained within a
> template. I had 6 page sequences within that template that applied to 5
> different elements (cover, disclaimer, toc, introduction, lessons,
> evaluation). There are multiple instances of the Lesson element but the
> Lesson page sequence did not start over for each instance, which is why I
> tried using a for-each. I had the page sequences contained within the
> following template.
> <xsl:template match="/">
>       <fo:root>
>                   cover page sequence 1
>                   disclaimer page sequence 2
>                   toc page sequence 3
>                   introduction page sequence 4
>                   lessons page sequence 5 (contains <apply-templates
> select="//Lesson" mode="Activity"/ in the Body flow>
>                   evaluation page sequence 6
>       </fo:root>
> </xsl:template>
> Here is the code I used for the page sequences without the for-each.
> <xsl:template match="/">
>             <fo:root>
>                   <!--Start Lesson Section-->
>                   <fo:page-sequence master-reference="
> Chapter-SequenceOddEven">
>                   </fo:page-sequence>
>                   <!--End Lesson Section-->
>             </fo:root>
>       </xsl:template>
>       <!--End Evalution Section-->

1. Do any of your attribute sets include ID attributes?

2. Are lessons recursive, such that one lesson may contain another, so
   that the contained lesson is processed twice when you select

3. The advice from others for you to examine your output has been for
   you to run your input and stylesheet using an XSLT (not XSL-FO)
   processor -- e.g., xsltproc or Saxon -- and look at the XML output
   that it produces since that will include "id" attributes for the
   duplicated ID.

4. Instead of <xsl:for-each select="//Lesson">, you could do
   <xsl:apply-templates select="Lesson"> (i.e., something more specific
   than "//Lesson" because "//Lesson" looks for <Lesson> elements
   *everywhere*, including in the descendants of <Lesson>) and have a
   separate template for <Lesson>, e.g.:

      <xsl:template match="Lesson">
         <!--Start Lesson Section-->
         <fo:page-sequence master-reference="Chapter-SequenceOddEven">
         <!--End Lesson Section-->

   That probably won't solve your duplicate ID problem since it's still
   likely that something is being processed twice, but it makes your "/"
   template a bit less monolithic.


Tony Graham.

Menteith Consulting Ltd             Registered in Ireland - No. 428599
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
Menteith Consulting -- Understanding how markup works

Current Thread