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

Re: Transforming XML Blockquotes - Mixed Content

Subject: Re: Transforming XML Blockquotes - Mixed Content
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 14 Apr 2005 09:52:43 +0100
elemments
The mathml spec stylesheets (available in the sources zip file linked
from 
http://www.w3.org/TR/mathml2
do the following to stop p elements in the source at a range of block
level elements and split up the resulting p so the html is bvaild and
only has inline elemments.


<xsl:template match="p">
  <xsl:apply-templates select="." mode="p">
    <xsl:with-param name="x" 
         select="count(eg|glist|olist|ulist|slist|orglist|
                       table|issue|note|processing-instruction()|
                       graphic[not(@role='inline')])" />
  </xsl:apply-templates>
</xsl:template>

<xsl:template mode="p" match="p">
<xsl:param name="x"/>
  <p>
  <xsl:apply-templates 
    select="node()[not(self::eg or self::glist or self::olist or
                       self::ulist or self::slist or self::orglist or
                       self::table or self::issue or self::note or
                       self::processing-instruction() or
                       self::graphic[not(@role='inline')]) and
    count(following-sibling::*[self::eg or self::glist or self::olist or
                               self::ulist or self::slist or self::orglist or
                               self::table or self::issue or self::note or
                               self::processing-instruction() or
                               self::graphic[not(@role='inline')] ])
         = $x]" />
  </p>
  <xsl:apply-templates
       select="(eg|glist|olist|ulist|slist|orglist|
                table|issue|note|processing-instruction()|
                graphic[not(@role='inline')])
                  [position() = last() - $x + 1]"/>
  <xsl:if test="$x &gt; 0">
    <xsl:apply-templates select="." mode="p">
      <xsl:with-param name="x" select="$x - 1" />
    </xsl:apply-templates>
  </xsl:if>
</xsl:template>


The code is rather old (Older than XSLT 1.0, in fact) today I;d probably
optimise it a bit with a key but unless your paragraphs have thousands
of child elements optimisation probaby isn't really important.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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-2013 All Rights Reserved.