[xsl] Word 2003 beta XML

Subject: [xsl] Word 2003 beta XML
From: Jim_Albright@xxxxxxxxxxxx
Date: Tue, 6 May 2003 20:28:34 -0400
The following stylesheet takes the XML output of Word 2003 beta and makes 
it into a nicer, IMO, form. The formatting information is removed. 
I am looking at the possibility of using styles mapped to my DTD so people 
can create in Word but then we can work on the text in XML after initial 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:w="http://schemas.microsoft.com/office/word/2003/2/wordml";>
        <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
        <!-- w:body holds the info we want inside of w:wordDocument -->
        <xsl:template match="w:wordDocument">
                <xsl:element name="xmlDocument">
                        <xsl:apply-templates select="w:body"/>
        <!-- w:body is where all text is stored -->
        <xsl:template match="w:body">
        <!-- paragraph style in text -->
        <xsl:template match="w:p">
                <xsl:variable name="paragraphStyle" select="descendant::w:pStyle/@w:val"/>
                <xsl:element name="{$paragraphStyle}">
        <!-- region within a paragraph (character style) -->
        <!-- only treat as a character style if w:rStryle is found -->
        <xsl:template match="w:r[descendant::w:rStyle/@w:val]">
                <xsl:variable name="characterStyle">
                        <xsl:value-of select="descendant::w:rStyle/@w:val"/>
                <xsl:element name="{$characterStyle}">
        <xsl:template match="w:t">
        <!-- line break  -->
        <xsl:template match="w:br">
                <xsl:element name="lineBreak"/>

Jim Albright
704 843-0582
Wycliffe Bible Translators

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread