Subject: Re: [xsl] Transforming XML Blockquotes - Mixed Content - XSLT 1.0 Solution From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 20 Apr 2005 22:45:19 +0100 |
> The result it seems is a "powerful" > transformation standard that cannot easily transform something as simple as > a high school term paper or a newspaper article. you are only talking about half a dozen lines of code, it's not exactly complicated, even if it isn't necessarily obvious on first contact. see for example the version I posted earlier, which may need changing to match your particular input format but is a fairly generic way of pulling block level elements out of a p Date: 14 Apr 2005 09:52:43 +0100 From: David Carlisle <davidc@xxxxxxxxx> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx In-reply-to: <425DC386.3020209@xxxxxxxxxxxxxx> (message from James Fuller on Thu, 14 Apr 2005 03:12:38 +0200) Subject: Re: [xsl] 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 ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Transforming XML Blockquo, JBryant | Thread | Re: [xsl] Transforming XML Blockquo, David Carlisle |
Re: [xsl] conditional position(), Bruce D'Arcus | Date | Re: [xsl] XSL-FO & Selecting Attrib, craig webber |
Month |