Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 18th, 2005, 11:38 AM
Registered User
 
Join Date: Oct 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to bluetorch
Default scx to html, using a xsl stylesheet

I don't know what is wrong with my code. I need to transform a scx file from openoffice (spreadsheet) to a html file.

this is my original xml (simplified)

Code:
<office:body>
    <table:table table:name="kladblad1" table:style-name="ta1">
            <table:table-column table:style-name="co1" table:number-columns-repeated="5" table:default-cell-style-name="Default"/>
                    <table:table-row table:style-name="ro1">
                            <table:table-cell table:style-name="ce1">
                                        <text:p>Artist</text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="ce1">
                                        <text:p>Album</text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="ce1">
                                        <text:p>Year</text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="ce1">
                                        <text:p>Genre</text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="ce1">
                                        <text:p>Rating</text:p>
                            </table:table-cell>
                    </table:table-row>
                    <table:table-row table:style-name="ro1">
                                <table:table-cell>
                                            <text:p>Underworld</text:p>
                                </table:table-cell>
                                <table:table-cell>
                                            <text:p>Beaucoup fish</text:p>
                                </table:table-cell>
                                <table:table-cell table:value-type="float" table:value="2002">
                                            <text:p>2002</text:p>
                                </table:table-cell>
                                <table:table-cell>
                                            <text:p>Techno</text:p>
                                </table:table-cell>
                                <table:table-cell>
                                            <text:p>***</text:p>
                                </table:table-cell>
                    </table:table-row>
                    <table:table-row table:style-name="ro1">
                                <table:table-cell>
                                            <text:p>HIM</text:p>
                                </table:table-cell>
                                <table:table-cell>
                                            <text:p>Love metal</text:p>
                                </table:table-cell>
                                <table:table-cell table:value-type="float" table:value="2003">
                                            <text:p>2003</text:p>
                                </table:table-cell>
                                <table:table-cell>
                                            <text:p>Rock</text:p>
                                </table:table-cell>
                                <table:table-cell>
                                            <text:p>****</text:p>
                                </table:table-cell>
                    </table:table-row>
                    <table:table-row table:style-name="ro1">
                                <table:table-cell>
                                            <text:p>HIM</text:p>
                                </table:table-cell>
                                <table:table-cell>
                                            <text:p>Dark light</text:p>
                                </table:table-cell>
                                <table:table-cell table:value-type="float" table:value="2005">
                                            <text:p>2005</text:p>
                                </table:table-cell>
                                <table:table-cell>
                                            <text:p>Rock</text:p>
                                </table:table-cell>
                                <table:table-cell>
                                            <text:p>******</text:p>
                                </table:table-cell>
                    </table:table-row>
                    <table:table-row table:style-name="ro1">
                                <table:table-cell>
                                            <text:p>Ill Nino</text:p>
                                </table:table-cell>
                                <table:table-cell>
                                            <text:p>Unframed</text:p>
                                </table:table-cell>
                                <table:table-cell table:value-type="float" table:value="2001">
                                            <text:p>2001</text:p>
                                </table:table-cell>
                                <table:table-cell>
                                            <text:p>Heavy rock</text:p>
                                </table:table-cell>
                                <table:table-cell>
                                            <text:p>***</text:p>
                                </table:table-cell>
                    </table:table-row>
        </table:table>
        <table:table table:name="Werkblad2" table:style-name="ta1">
                <table:table-column table:style-name="co1" table:default-cell-style-name="Default"/>
                        <table:table-row table:style-name="ro1">
                                <table:table-cell/></table:table-row>
        </table:table>
        <table:table table:name="Werkblad3" table:style-name="ta1">
                <table:table-column table:style-name="co1" table:default-cell-style-name="Default"/>
                        <table:table-row table:style-name="ro1">
                                <table:table-cell/>
                        </table:table-row>
        </table:table>

        </office:body>
and this is my xsl to transform it (also not complete but only the relevant code)

Code:
<xsl:template match="office:body">
        <html>
            <head>
                <title>tester HTML transformer</title>
            </head>
            <body>
                <b>transformer scx to html</b><br/><br/>

                <xsl:for-each select="table:table">

                       <xsl:value-of select="@table:name"/>#160;style:<xsl:value-of select="@table:style-name"/><br/>

                 </xsl:for-each>

                <xsl:apply-templates select="table:table" />        

            </body>
        </html>
    </xsl:template>

    <xsl:template match="table:table">
        <table border="1" cellpadding="1" cellspacing="1">
            <tbody>
                <xsl:apply-templates select="table:table-row"/>
            </tbody>
        </table>
    </xsl:template>

    <xsl:template match="table:table-row">
            <td>
                <xsl:for-each select="table:table-cell">

                            <xsl:apply-templates select="table:table-cell"/>

                </xsl:for-each>

            </td>
    </xsl:template>


    <xsl:template match="table:table-cell">
            <tr>
                <xsl:apply-templates  select="text:p"/>
            </tr>
    </xsl:template>

    <xsl:template match="text:p">
            <xsl:value-of select="."/>
    </xsl:template>
and my html file only sums up the 3 table:tables, and gives 1 biggercell, then 2 small cells beneath it
why doesnt it output all the textdata in cells ?

here is the code of it

Code:
<html><head><meta http-equiv="Content-Type" content="; charset=UTF-8"><title>tester HTML transformer</title></head><body><b>transformer scx to html</b><br><br>kladblad1Â style:ta1<br>Werkblad2Â style:ta1<br>Werkblad3Â style:ta1<br><table border="1" cellpadding="1" cellspacing="1"><tbody><td /><td /><td /><td /><td /></tbody></table><table border="1" cellpadding="1" cellspacing="1"><tbody><td /></tbody></table><table border="1" cellpadding="1" cellspacing="1"><tbody><td /></tbody></table></body></html>





Similar Threads
Thread Thread Starter Forum Replies Last Post
xml to html with xsl boblavinsky XSLT 4 January 5th, 2007 05:30 AM
XSL table to HTML ayamas XSLT 10 September 11th, 2006 06:45 AM
Re: Dynamic html tables with xsl? purple XSLT 0 November 2nd, 2005 12:01 PM
Creating a html in an xsl document allenatmarc XSLT 2 June 16th, 2004 04:10 AM
XSL Stylesheet Problem Ben Horne XSLT 4 March 6th, 2004 05:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.