[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: paras with nested block-level elements to XHTML mi

Subject: Re: paras with nested block-level elements to XHTML mix of <p>s and flattened block-level elements
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 01 Aug 2008 15:00:20 -0400
Re:  paras with nested block-level elements to XHTML mi
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 ======================================================================

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.