[Home] [By Thread] [By Date] [Recent Entries]
At 2007-09-19 16:53 -0400, Sharon_Harris@xxxxxxxxxxxxxxxxxxxx wrote:
I am unable to generate a PDF file using a for-each loop before a page sequence if I am using IDs.I am using XSLT 1.0 and Apache FOP. There is no relationship between XSLT's for-each and XSL-FO's page-sequence. To diagnose your situation, use XSLT to create an instance of XSL-FO and then inspect XSL-FO to determine what the problem is. That will then tell you where you went wrong in your XSLT. I have a couple of page sequences defined. In 1 page sequence, I have a TOC with IDs that point to elements that are outputted in a 2nd page sequence. Those should be ref-id= attributes and not id= attributes. Check your XSL-FO instance to make sure <page-number-citation> is using ref-id=. The 2nd page sequence is for Lessons and starts with a for-each loop calling a Lesson element that will output all the lesson content within the body of the Lesson page sequence. However, I encounter the following error: "NC105 ID already exists in this document". This tells me that when you open up the generated XSL-FO file you will find id= being used more than once. I have unique ID prefixes specified in all Lesson children elements that are to be listed in the TOC so I am unsure why the IDs are repeated for each instance of the Lesson element. Note that the use of "//" is the most common way of making a very inefficient stylesheet. If you think you need "//", think again because you may not need to incur the overhead. and this outputs fine except that the page sequence instructions do not repeat for every instance of the Lesson element. For example, I specify that the 1st page of each lesson should not have a header but only the 1st instance of the Lesson element has no header displaying but all other Lesson element instances have a header on the 1st page. But I do not run into the issue that the IDs are not unique for each instance of a Lesson element. By not including a code fragment from your stylesheet, it is not possible to comment on where you might be wrong. Am I correct in thinking that in order to get the page sequence to start over for each instance of the Lesson element, that I need to have a for-each statement before the page sequence? No, that is not correct. Any XSLT instruction at all can be used to create any XSL-FO instruction at all. In fact, you don't need XSLT (I have a Python program on my web site that uses XSL-FO as a page layout language, with no XSLT involved whatsoever). In fact, a "push-oriented" stylesheet using <xsl:apply-templates/> can in many ways be more flexible and maintainable than a "pull-oriented" stylesheet using <xsl:for-each>. If so, how do I ensure the IDs are unique for every instance of the Lesson element? By inspecting the XSL-FO instance to determine where your duplicate identifiers are being specified using id=, and then finding where in your XSLT the result tree with those extraneous identifiers are being generated, then changing the XSLT accordingly. I hope this helps. . . . . . . . . . . . Ken -- Upcoming public training: UBL and code lists Oct 1/5; Madrid Spain World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Jul'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|

Cart



