Subject: Re: [xsl] Enabling extension to counting of instances From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 08 Jan 2010 16:21:35 -0500 |
The plugin can't simply override the numbering logic because that would break other plugins deployed to same Toolkit instance. Rather, plugins need to be able to contribute to the numbering logic so that all chapters are counted correctly.
My design challenge then is to determine what is the best way to enable this sort of unilateral contribution to things like numbering logic. In particular, typical code using <xsl:number/> with @count and @from won't work because there's no obvious way to extend the specification of what to count and what to count from.
The only directly-provided XSLT extension mechanism I can think of is to use modes where elements contribute nodes to a sequence that is then used for either counting or doing a boolean check.
For example, to count chapter references you would have a mode "isChapterRef" and then use it like so:
<xsl:variable name="chapterRefs" as="element()*" > <xsl:apply-templates mode="isChapterRef" select="$map//*[contains(@class, ' map/topicref ')]"/> </xsl:variable/>
Where a typical isChapterRef template would be:
<xsl:template mode="isChapterRef" match="*[contains(@class, ' pubmap-d/chapterref ')]" > <xsl:sequence select="."/> </xsl:template>
So that the resulting value of $chapterRefs would be a list of elements that have declared themselves to be chapter references.
The $chapterRefs list can then be used for counting, boolean checks, etc.
My question: is there a more efficient way to provide this sort of extensible arbitrary-type-to-semantic-type mapping?
<xsl:template match="para"> <xsl:apply-templates mode="do-construct" select="."/> </xsl:template> <xsl:template match="para" mode="do-construct"> <fo:block xsl:use-attribute-sets="normal-stuff"> <xsl:apply-templates mode="do-attributes" select="."/> <xsl:apply-templates mode="do-content" select="."/> </fo:block> </xsl:template> <xsl:template match="para" mode="do-attributes"> <xsl:apply-templates select="@*"/> </xsl:template> <xsl:template match="para" mode="do-content"> <xsl:apply-templates/> </xsl:template>
<xsl:template match="para"> <xsl:apply-templates mode="do-construct" select="."/> </xsl:template> <xsl:template match="para" mode="do-construct"> <fo:block xsl:use-attribute-sets="normal-stuff"> <xsl:apply-templates mode="do-attributes" select="."/> <xsl:apply-templates mode="do-content" select="."/> </fo:block> </xsl:template> <xsl:template match="para" mode="do-content"> <xsl:apply-templates mode="do-number" select="."/> <xsl:apply-templates/> </xsl:template> <xsl:template match="para" mode="do-number"> <xsl:number/>: <xsl:text/> </xsl:template>
-- UBL and Code List training: Copenhagen, Denmark 2010-02-08/10 XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19 XSLT/XQuery/XPath training: San Carlos, California 2010-04-26/30 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Enabling extension to cou, Dimitre Novatchev | Thread | Re: [xsl] Enabling extension to cou, Eliot Kimber |
Re: [xsl] Enabling extension to cou, Eliot Kimber | Date | Re: [xsl] Enabling extension to cou, Eliot Kimber |
Month |