RE: [xsl] Converting WordML to a XHTML list

Subject: RE: [xsl] Converting WordML to a XHTML list
From: "Lincoln Mitchell" <lincoln@xxxxxxxxxxx>
Date: Wed, 25 Aug 2004 21:41:39 +0800
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

 

-----Original Message-----
From: cking [mailto:cking@xxxxxxxxxx] 
Sent: Wednesday, 25 August 2004 4:06 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Converting WordML to a XHTML list

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