Subject: Re: [xsl] Bookmarks in xsl From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 05 Sep 2012 11:33:51 -0400 |
Thanks for your response Ken.
> The first bookmark of the entire set or the first bookmark of the chapter? - I meant the first bookmark of the chapter.
And when I said 'under' I meant nested bookmarks.
The problem I am having is that since the element 'task' can repeat for a chapter, I am unable to generate the bookmark internal destination ids to be unique. Since FOP does not support XSLT 1.0 ( and I restricted to this product), I am not able to use the xslt 2.0 for-each-group to be able to group the tasks. I have to use keys to group them. Is there any other better way of doing this?
~/t/ftemp $ cat kusa.xml <?xml version="1.0" encoding="UTF-8"?> <tasks>
<task chap="8" key="a123" seq="1" pg = "1"> <!-- some more content here--> </task>
<task chap="8" key="y837458" seq="2" pg = "2"> <!-- some more content here--> </task> <task chap="9" key="3jkhkj" seq="1" pg = "1"> <!-- some more content here--> </task> <task chap="9" key="t8798" seq="2" pg = "2"> <!-- some more content here--> </task> </tasks> ~/t/ftemp $ xslt kusa.xml kusa.xsl <?xml version="1.0" encoding="utf-8"?> <bookmark-tree xmlns="http://www.w3.org/1999/XSL/Format"> <bookmark internal-destination="d0e3"> <bookmark-title>8</bookmark-title> <bookmark internal-destination="d0e8"> <bookmark-title>8-2</bookmark-title> </bookmark> </bookmark> <bookmark internal-destination="d0e13"> <bookmark-title>9</bookmark-title> <bookmark internal-destination="d0e18"> <bookmark-title>9-2</bookmark-title> </bookmark> </bookmark> </bookmark-tree>~/t/ftemp $ ~/t/ftemp $ cat kusa.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/XSL/Format" version="1.0">
<xsl:template match="tasks"> <bookmark-tree> <xsl:for-each select="task[generate-id(.)= generate-id(key('tasks',@chap)[1])]"> <bookmark internal-destination="{generate-id(.)}"> <bookmark-title> <xsl:value-of select="@chap"/> </bookmark-title> <xsl:for-each select="key('tasks',@chap)[position()>1]"> <bookmark internal-destination="{generate-id(.)}"> <bookmark-title> <xsl:value-of select="concat(@chap,'-',@seq)"/> </bookmark-title> </bookmark> </xsl:for-each> </bookmark> </xsl:for-each> </bookmark-tree> </xsl:template>
</xsl:stylesheet>~/t/ftemp $ ~/t/ftemp $
-- Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012 Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Bookmarks in xsl, a kusa | Thread | Re: [xsl] Bookmarks in xsl, Markus Abt |
Re: [xsl] Bookmarks in xsl, a kusa | Date | Re: [xsl] Bookmarks in xsl, Markus Abt |
Month |