Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] paras with nested block-level elements to XHTML mix of s and flattened block-level elements

From: Wendell Piez <wapiez@---------------->
To:
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
======================================================================


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent