xsl-list
[Top] [All Lists]

RE: Converting WordML to a XHTML list

2004-08-27 14:43:47
Worked a charm, Thx heaps mate!

Linc 

-----Original Message-----
From: cking [mailto:cking(_at_)telenet(_dot_)be] 
Sent: Thursday, 26 August 2004 6:03 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Converting WordML to a XHTML list

Hi Lincoln,

Here's a possible solution, using recursion: 

<xsl:template match="w:p">
    <xsl:choose>
        <xsl:when test="w:pPr/w:listPr">
            <xsl:if test="not(preceding-sibling::w:p[1]/w:pPr/w:listPr)">
                <xsl:apply-templates select="w:r/w:t" mode="list-begin"/>
            </xsl:if>
        </xsl:when>
        <xsl:when test="w:pPr/w:pStyle/@w:val='Heading5'">
            <h2><xsl:value-of select="w:r/w:t"/></h2>
        </xsl:when>
        ....
        <xsl:otherwise>
            <p><xsl:value-of select="w:r/w:t"/></p>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template match="w:t" mode="list-begin">
    <ol>
        <xsl:apply-templates select="." mode="list-item-recursive"/>
    </ol>
</xsl:template>

<xsl:template match="w:t" mode="list-item-recursive">
    <li><xsl:value-of select="."/></li>
    <xsl:variable name="next" select="../../following-sibling::w:p[1]"/>
    <xsl:if test="$next/w:pPr/w:listPr">
        <xsl:apply-templates select="$next/w:r/w:t"
mode="list-item-recursive"/>
    </xsl:if>
</xsl:template>

I hope this can clear up the mud? :)
Anton Triest

Wednesday, August 25, 2004 3:41 PM, Lincoln Mitchell wrote:

I can see where you are going but a list of items maybe in other 
locations in the wordml so "//w:t[../../w:pPr/w:listPr]" will match them
too.

However as list items will be in one block, maybe we create a rule 
like
this:
1. For 1st "w:p/w:pPr/w:listPr" create "<OL>" and "<li>...</li>"
2. While "following-sibling" = "w:p/w:pPr/w:listPr" do "<li>...</li>"
3. </OL>

Clear as mud?


If no resolve this time round I will send complete xsl and xml.

Linc


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--