Subject: Re: Grouping: XHTML inline, block and flow
From: "Raka Gator" <plogbil@xxxxxxxxx>
Date: Thu, 27 Mar 2008 16:21:49 +0100
|
Hi!
On Thu, Mar 27, 2008 at 4:13 PM, Bjorndahl, Brad
<brad.bjorndahl@xxxxxxxxxxxxxxxx> wrote:
> I can only respond to question 1. I have done something similar with DITA, which also allows a mix of inline and block type elements.
>
> First, though, I would not try to solve this problem in full generality without XSLT 2.0. I'm just not brave enough.
Yeah, I've realized that I should go with 2.0. I'm going to give it a try.
> Assuming you have resolved your problems with 2.0, this is how I handle the mix:
>
> 1) Specify your inline elements in a global variable like this:
> <xsl:variable name="inlineElts">
> <inline></inline> <!-- for text nodes -->
> <inline>b</inline>
> <inline>i</inline>
> <inline>sup</inline>
> <inline>sub</inline>
> .
> .
> .
> </xsl:variable>
>
>
> 2) In templates that process mixed content, include, at the appropriate point:
> <xsl:call-template name="processMixedContent" >
> .
> </xsl:call-template>
>
> In my case I also have
> <xsl:call-template name="processNodes-note" >
> <xsl:call-template name="processNodes-li_choice_dt" >
> and so on for special cases, but they all work in a similar way.
>
>
> 3) Add the processMixedContent template:
> <xsl:template name="processMixedContent"> . . .
>
> in which you have a statement that groups inline and block elements like this (and this is where 2.0 is important):
>
> <xsl:for-each-group select="child::node()" group-adjacent="exists(index-of($inlineElts/inline,local-name()))">
> <xsl:for-each select=".">
> <xsl:choose>
> <xsl:when test="current-grouping-key() eq true()"> <!-- Process inline elements -->
> <xsl:for-each select="current-group()" >
> .
> .
> .
> <xsl:otherwise> <!-- Process block elements -->
>
> <xsl:apply-templates select="current-group()">
Great tip! I didn't even know that you could do that with variables.
I'll read up on
2.0 grouping and try to solve the other issues and give it a try!
Thank you very much!
/Stefan
|