|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: cleaning up ill-structured html
I can do step 1, but step 2 gives me trouble. To formalise: how do I convert a structure structure like I wouldn't say it's simple. The best that I can come up with is this (note: untested), perhaps there is a more elegant solution: <xsl:template match="break"> <!-- locate the positions of all following breaks, appending a comma after each --> <xsl:variable name="following-breaks"> <xsl:for-each select="following-sibling::*"> <xsl:if test="self::break"><xsl:value-of select="position()"/>,</xsl:if> </xsl:for-each> </xsl:variable> <!-- extract the position of the first break following sibling --> <xsl:variable name="first-break" select="number(substring-before ($following-breaks, ','))"/> <!-- don't do any copies if the next break occurs immediately after us --> <xsl:if test="$first-break > 1"> <p> <!-- copy all elements in between us --> <xsl:copy-of select="following-sibling::*[position() < $first-break]"/> </p> </xsl:if> </xsl:template> Niko Matsakis -- DataPower technology http://www.datapower.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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








