Thread: Help with style
View Single Post
 
Old November 2nd, 2006, 08:12 AM
Boomah Boomah is offline
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Michael, thanks very much for the reply.

I have updated my XSL file to:

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
    version="1.0">
    <xsl:output method="xml"/>

    <xsl:template match="*">

        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="text()">

    </xsl:template>

    <xsl:template match="/">
        <body>
            <xsl:apply-templates/>
        </body>
    </xsl:template>

    <xsl:template match="w:tbl">
        <table>
            <xsl:apply-templates/>
        </table>
    </xsl:template>

    <xsl:template match="w:tr">
        <row>
            <xsl:apply-templates/>
        </row>
    </xsl:template>

    <xsl:template match="w:tc">
        <cell>
            <xsl:value-of select="."/>
        </cell>
    </xsl:template>

</xsl:stylesheet>

as suggested and it works just like before. I do have a new problem though. Before I changed the xsl file I had added on some extra logic. It had been updated to:

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
    version="1.0">
    <xsl:output method="xml"/>

    <xsl:template match="/">
        <body>
            <xsl:for-each select="w:wordDocument/w:body//w:tbl[ (w:tr/w:tc='Profile_List') or
                                                                 (w:tr/w:tc='Table Header')]">
                <table>
                    <xsl:for-each select="w:tr">
                        <row>
                            <xsl:for-each select="w:tc">
                                <cell>
                                    <xsl:value-of select="."/>
                                </cell>
                            </xsl:for-each>
                        </row>
                    </xsl:for-each>
                </table>
            </xsl:for-each>
        </body>
    </xsl:template>

</xsl:stylesheet>

Here I filter depending on the contents of the first cell in each table because I am only interested in certain tables. This works as I expect.

The problem is I can't get it to work with the new style. If I put the condition in the place I expect, it still selects all tables:

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
    version="1.0">
    <xsl:output method="xml"/>

    <xsl:template match="*">

        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="text()">

    </xsl:template>

    <xsl:template match="/">
        <body>
            <xsl:apply-templates/>
        </body>
    </xsl:template>

    <xsl:template match="w:tbl[(w:tr/w:tc='Table Header') or (w:tr/w:tc='Table Header')]">
        <table>
            <xsl:apply-templates/>
        </table>
    </xsl:template>

    <xsl:template match="w:tr">
        <row>
            <xsl:apply-templates/>
        </row>
    </xsl:template>

    <xsl:template match="w:tc">
        <cell>
            <xsl:value-of select="."/>
        </cell>
    </xsl:template>

</xsl:stylesheet>

I know I'm doing something a bit silly, I just don't know what! :o)

Any ideas?

Cheers, Boomah.