[Home] [By Thread] [By Date] [Recent Entries]
Daniel,
At 02:38 PM 8/1/2008, you wrote: My question concerns X/HTML as the transformation target, where "p" is the lowest level block-level element, which admits no other block-level element(s) as content, but the source is a model (like DocBook, TEI, etc.) which allows (and has) a variety of block level content in paragraphs. It isn't a new problem -- it comes up here from time to time, but always in a different guise. Basically you have two options: * Using a splitting algorithm (easier in 2.0) to split paragraphs around content that would be invalid in the result as such, but valid as siblings, or, * Map paragraph elements to HTML div elements (maybe with @class='paragraph') instead of to p elements. Which of these is better depends on a number of factors extraneous to XSLT. If you want to know more about splitting algorithms, ask again. In XSLT 2.0, one case use xsl:for-each-group like this: <xsl:template match="p">
<xsl:for-each-group select="node()" group-adjacent="u:block-level(.)">
<xsl:choose>
<xsl:when test="current-grouping-key()">
<xsl:apply-templates select="current-group()"/>
</xsl:when>
<xsl:otherwise>
<p>
<xsl:apply-templates select="current-group()"/>
</p>
</xsl:otherwise>
</xsl:for-each-group>
</xsl:template>... where u:block-level(.) returns a Boolean true or false depending on whether its argument has to be split out. I hope that helps -- Wendell
|

Cart



