Re: [xsl] Transforming XML Blockquotes - Mixed Content - XSLT 1.0 Solution

Subject: Re: [xsl] Transforming XML Blockquotes - Mixed Content - XSLT 1.0 Solution
From: "Edward Bryant" <bryant_edward@xxxxxxxxxxx>
Date: Wed, 27 Apr 2005 14:56:15 -0500
Hello again,

Reply to David Carlisle and Wendell:

To the comments that I might try to use divs instead of the standard XHTML blockquote tag (because XHTML allows nested divs), I tried it and it doesn't work. If I remember correctly nested divs technically work but in IE6 a paragraph's initial indent is re-applied to the text following a blockquote (so, the continued part of the paragraph falsely appears to be a new paragraph). Hence, while some style features, such as line-height inherit correctly to the post blockquote text, it also incorrectly inherits the paragraph's initial indent.

Reply to David Carlisle and Michael Kay:

Thanks for David's explanation of why not to use DOE, as well as the tree-based reasoning behind XSLT (I understand why this kind of thing is a problem better). On the responses to my comment that Jay's solution was "overly complex", I did not mean that the offered solution was complex in that there were too many lines of code. What I meant was that the solution ends up handling or touching on a lot of data that isn't even involved in the blockquote problem. It is complex in that it results in a lot of extra processing of data, as in the example of a 20 page document with only one blockquote in one paragraph or the processing of documents without any blockquotes, etc.

Reply to Jay Bryant:

Thanks for your patience and your posting of a 1.0 compliant version of your solution. I did, however, have a few questions:

1. I tried to decipher this XPATH expression but I can't seem to understand it, can someone help explain what this is doing

p[not(preceding-sibling::*[1]/self::p)]

2. In the below stylesheet (the second of the two you offered), how do you differentiate between the p representing the initial paragraph and the continued paragraph p tags. I need to figure out a way to output the original paragraph's "num" attribute next to the start of each real paragraph (but not repeat it for the new p tags surrounding the continued paragraph text).

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>


 <xsl:template match="x">
 <html>
 <head>
 <title>Paragraph Chunking Test</title>
 <link rel="stylesheet" type="text/css" href="style.css" />
 </head>
 <body>
   <xsl:for-each select="p[not(preceding-sibling::*[1]/self::p)]">
   <xsl:variable name="group" select="@group"/>
   <p>
     <xsl:for-each select="../p[@group=$group]">
       <xsl:apply-templates/>
     </xsl:for-each>
   </p>
   <xsl:apply-templates select="following-sibling::blockquote"/>
   </xsl:for-each>
 </body>
 </html>
 </xsl:template>

<xsl:template match="p"/>

 <xsl:template match="blockquote">
   <xsl:copy-of select="."/>
 </xsl:template>

 <xsl:template match="span">
   <xsl:copy-of select="."/>
 </xsl:template>

</xsl:stylesheet>

Current Thread