xsl-list
[Top] [All Lists]

Indifferenct behavoiur For XSL transform

2002-11-25 05:18:59
Hi All,
           I have indifferent behaviur for my Xml when I apply my xsl Xml
format is as below .
When I try to print Title Tag under <Body><RowSet><Title>......
My value for Title gets printed under TD tag of html and also outside of my
TD tag of html table.I think if you will run this xml and xsl together and
view the output you will come to know whats the problem.I hope anybody can
help me to solve the problem .
thanks ,
Hiren Shah

XML File CompetitorReport.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 U (http://www.xmlspy.com) by Hiren Shah (USI) -->
<?xml-stylesheet type="text/xsl" href="CompetitorReport.xsl"?>
<Report>
        <Header>
                <Row>
                        <Column type="reportheader">Competitor
Report</Column>
                        <Column/>
                </Row>
        </Header>
        <Body>
                <RowSet>
                        <Title>Corporate Info</Title>
                        <RowSetBody>
                                <RowSetHeader>
                                        <Column type="tableheader">Company
Financials</Column>
                                        <Column
type="tableheader">Competitor1</Column>
                                        
                                </RowSetHeader>
                                <Row>
                                        <Column type="rowheader">Gross
Profit</Column>
                                        <Column type="data">9 Million
USD</Column>
                                        
                                </Row>
                                <Row>
                                        <Column type="rowheader">Net
Profit</Column>
                                        <Column type="data">9 Million USD
</Column>
                                </Row>
                        </RowSetBody>
                </RowSet>
        </Body>
        <Footer>
                <Row>
                        <Column type="footer">Page X of Y</Column>
                        <Column>Copy right</Column>
                </Row>
        </Footer>
</Report>


and xsl file is as given below CompetitorReport.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; >
        <xsl:template match="/">
                <html>
                <head>
                        <title></title>
                                </head>
                <body >
                        <h1 align="center">
                                <xsl:value-of
select="//Header/Row/Column[(_at_)type]"/>
                        </h1>
                        <table border="0" width="75%"  align="center" >
                        <xsl:apply-templates select="//RowSet" />
                         </table>
                         <xsl:apply-templates select="//Footer" /><br></br>
                 <hr></hr><br></br>
                 </body>
                </html>
        </xsl:template>
        <!-- 
 This template applies formatting to the "item" elements.
     All "item" elements get this formatting applied, because
     "apply-templates" is called from the root template above. 

  -->
  <xsl:template match="Footer">
                <xsl:for-each select="Row">

        <xsl:for-each select="Column">
                
        <div align="center"><xsl:value-of select="."/></div><p></p>
        
        </xsl:for-each>
        </xsl:for-each>
        </xsl:template>

        <xsl:template match="RowSet">
                <tr>
                        <th  bgcolor="red"   align="left" >
                        <xsl:attribute name="colspan" >
                        <xsl:value-of
select="count(//RowSetHeader/Column)"></xsl:value-of>
                        </xsl:attribute>
                        
                        <xsl:value-of select="Title"
disable-output-escaping="yes"></xsl:value-of></th>
                                <xsl:apply-templates select="child::*"/>
                </tr>
                                
        </xsl:template>
        
        <xsl:template match="RowBody">
        <xsl:apply-templates select="/RowSetHeader"/>
        <xsl:apply-templates select="/Row"/>
         </xsl:template>

        
        <xsl:template match="RowSetHeader">
                        <tr>
        <xsl:for-each select="Column">
        <th  bgcolor="silver"  align="left"><xsl:value-of select="."/></th>
        </xsl:for-each>
                                </tr>
    </xsl:template>
    <xsl:template match="Row">
                        <tr>
                                <xsl:for-each select="Column">
                                        <xsl:choose>
                                            <xsl:when
test="normalize-space(@type)='rowheader' ">
                                                                <th
align="left"><xsl:value-of select="."/></th>
                                                </xsl:when>
                                                <xsl:otherwise>
        
<td><xsl:value-of select="."/></td>
                                                </xsl:otherwise>
                                   </xsl:choose>
                                </xsl:for-each>
                        </tr>
                                <tr>
                                  <td><xsl:text></xsl:text></td>
                        </tr>
          </xsl:template>
 </xsl:stylesheet>


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



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