Re: [xsl] Converting WordML to a XHTML list

Subject: Re: [xsl] Converting WordML to a XHTML list
From: "cking" <cking@xxxxxxxxxx>
Date: Wed, 25 Aug 2004 10:05:59 +0200
Hi Lincoln,

Now I see what your problem is. 

<xsl:when test="w:pPr/w:listPr">
   <!-- match 1st w:r/w:t put in <ol> -->
   <xsl:apply-templates select="w:r/w:t"/>
   <!-- match last w:r/w:t put in </ol> -->
</xsl:when>

This will not be possible, as it would produce invalid XML.
So, you will need to use another logic...

I'm not familiar with WordML, so I have no idea how the rest of the input file
is organized. Would it be possible to send a complete input file + stylesheet?
(if the files are too large to post, you can send them to me off-list)

To take only the <w:t> elements that are related to a list item,
you could do something like this:

    ...
    <xsl:variable name="list-items" select="//w:t[../../w:pPr/w:listPr]"/>
    <xsl:if test="count($list-items) > 0">
        <ol><xsl:apply-templates select="$list-items" mode="li"/></ol>
    </xsl:if>
    ...

<xsl:template match="w:t" mode="li">
    <li><xsl:value-of select="."/></li>
</xsl:template>

Best regards,
Anton Triest


Wednesday, August 25, 2004 1:09 AM, Lincoln Mitchell wrote:
>
> Hi Anton,
> That will not work in this instance. In my xsl(cutdown version) below you
> can see I 1st match a w:p and there are multiple instances of w:t not
> related to a list item.
> 
> TIA
> Linc
> 
> ...
> <xsl:template match="w:p">
> <xsl:choose>
> <xsl:when test="w:pPr/w:pStyle/@w:val='Heading5'"> 
> <h2>
> <xsl:apply-templates
> select="w:r/w:t"/>
> </h2>
> </xsl:when>
> ...
> <xsl:when test="w:pPr/w:listPr">
> <!-- match 1st w:r/w:t put in <ol> -->
> <xsl:apply-templates
> select="w:r/w:t"/>
> <!-- match last w:r/w:t put in </ol> -->
> </xsl:when>
> <xsl:otherwise>
> <p>
> <xsl:apply-templates
> select="w:r/w:t"/>
> </p>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
> ...

Current Thread