|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Transforming XML Blockquotes - Mixed Content
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 > 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
________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








