xsl-list
[Top] [All Lists]

Re: WordML to XML/HTML

2005-02-05 02:19:45
Tempore 03:42:31, die 02/05/2005 AD, hinc in xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Vasu Nanjangud <vasdeep(_at_)yahoo(_dot_)com>:

I have WordML data like this...
<w:r>
   <w:rPr>
           <w:i>
         <w:u w:val="single"/>
         <w:b/>
    </w:rPr>
     <w:t>I have bold and italics and underscore
</w:t>
</w:r>
Hi,


starting from this xml:
<w:r xmlns:w="specify-the-namespace-here">
        <w:rPr>
                <w:i/>
                <w:u w:val="single"/>
                <w:b/>
        </w:rPr>
        <w:t>I have bold and italics and underscore
        </w:t>
</w:r>

You'll get this output:
<i>
        <u>
                <b>I have bold and italics and underscore
        </b>
        </u>
</i>

When you apply this stylesheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0" xmlns:w="specify-the-namespace-here">
  <xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>

<xsl:template match="w:r ">
        <xsl:apply-templates select="(w:rPr|w:t)[1]"/>
</xsl:template>

<xsl:template match="w:rPr">
        <xsl:apply-templates select="*[1]"/>
</xsl:template>

<xsl:template match="w:rPr/*">
        <xsl:element name="{local-name()}">
                <xsl:apply-templates 
select="(following-sibling::*|../../w:t)[1]"/>
        </xsl:element>
</xsl:template>

</xsl:stylesheet>


(note that you have to change the namespace first)


I hope this is useful
I don't know wordML, so I can't guarantee this solution works in all cases.



regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
Veni, vidi, wiki (http://www.wikipedia.org)

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