Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - [xsl] paras with nested block-level elements to XHTML mix of s and flattened block-level elements [Thread Next] Re: [xsl] paras with nested block-level elements to XHTML mix of s and flattened block-level elementsTo: Date: 8/1/2008 7:01:00 PM 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. This doesn't appear to be a new problem... but while I've tried, I just haven't been able to track down any definitive solutions. 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 ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ====================================================================== | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
