xsl-list
[Top] [All Lists]

Re: Fwd: Re: WordML to XML

2005-02-17 10:27:09
Tempore 07:26:48, die 02/16/2005 AD, hinc in xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Vasu Nanjangud <vasdeep(_at_)yahoo(_dot_)com>:

  Please take a look at it and let me know how the
'listPr' tags be converted to give meaningful xml data
like
  <ol>
      <li>Alpha</li>
      <li>Beta</li>
      <li>Gamma</li>
  </ol>

  and other cases like a,b,c or 1,2,3,4.

Hi,

Here is a stylesheet that will do the rudimentary operations to ouput an html lists up to arbitrary level. No distinction is made between numbering forms; I don't feel like unraffling the meaning those list definition elements.;) I you want to include different numbering styles, I advise you to use 'style' attributes and let the XSLT build a css section in your html that will take care of the styling.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0"
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml";
exclude-result-prefixes="w">
   <xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>

<xsl:key name="list" match="w:listPr" use="generate-id(ancestor::w:p/preceding-sibling::w:p/w:pPr/w:listPr[number(current()/w:ilvl/@w:val) - number(w:ilvl/@w:val)=1])"/>

<xsl:template match="*[w:p/w:pPr/w:listPr]">
        <ol>
                <xsl:apply-templates 
select="w:p[w:pPr/w:listPr/w:ilvl/@w:val='0']"/>
        </ol>
</xsl:template>

<xsl:template match="w:p">
        <xsl:apply-templates select="(w:pPr|w:r)[1]"  mode="styling"/>
</xsl:template>

<xsl:template match="w:pPr"  mode="styling">
        <xsl:apply-templates select="w:listPr" mode="styling"/>
</xsl:template>

<xsl:template match="w:listPr" mode="styling">
        <li>
        <xsl:apply-templates select="../../w:r" mode="styling"/>
                <xsl:if test="key('list',generate-id())">
                        <ol>
<xsl:apply-templates select="key('list',generate-id())" mode="styling"/>
                        </ol>
                </xsl:if>
        </li>
</xsl:template>

</xsl:stylesheet>


Btw, you should not have included entire files; snippets would have been OK.

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
"Φιλήκοον ειναι μαλλον η φιλόλαλον" - Κλεόβουλος

--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>