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 April 4th, 2011, 09:07 AM
Authorized User
 
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
Default Table frame view

Hi,

In xml i have table, the table i convert to html. if frame is present in xml it show to html. if frame is not present in xml it no need to show html.

I have pasted xml coding and pdf for your reference.

Kindly give solution.

Table 1
<table>
<tgroup cols="4" rowsep="0" colsep="0">
<colspec colnum="1" colname="col1" colwidth="25*" align="left">
<colspec colnum="2" colname="col2" colwidth="20*" align="left">
<colspec colnum="3" colname="col3" colwidth="20*" align="left">
<colspec colnum="4" colname="col4" colwidth="35*" align="left">
<tbody>
<row rowsep="1">
<entry><text>City and State</text></entry>
<entry><text>Channel</text></entry>
<entry><text>Power (kW)</text></entry>
<entry><text>Antenna HAAT (m)</text></entry>
</row>
<row>
<entry><text>Augusta, Georgia</text></entry>
<entry><text>51</text></entry>
<entry><text>37</text></entry>
<entry><text>363</text></entry>
</row>
</tbody>
</tgroup>
</table>

Table 2
<table>
<tgroup cols="3" rowsep="0" colsep="0">
<colspec colnum="1" colname="col1" colwidth="50*" align="left">
<colspec colnum="2" colname="col2" colwidth="25*" align="left">
<colspec colnum="3" colname="col3" colwidth="25*" align="left">
<spanspec namest="col2" nameend="col3" spanname="sp1" align="center">
<tbody>
<row>
<entry><text></text></entry>
<entry spanname="sp1"><text>Channel No.</text></entry>
</row>
<row>
<entry><text>City and State</text></entry>
<entry><text>Present</text></entry>
<entry><text>Proposed</text></entry>
</row>
<row>
<entry><text>Augusta, Georgia</text></entry>
<entry><text>12, 30, 31, 42</text></entry>
<entry><text>12, 30, 42, 51</text></entry>
</row>
</tbody>
</tgroup>
</table>
 
Old April 4th, 2011, 09:10 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Please read this post on how to make a good XSLT post: Hints for a good XSLT post

I cannot tell from your post what you are trying to accomplish. The two bits of XML you have posted mean nothing to me, and you are not showing any output XML or attempts at creating an XSLT yourself.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old April 4th, 2011, 02:40 PM
Authorized User
 
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
Default

i pasted pdf file for your reference.

In pdf file i marked red line for tables.

http://www.4shared.com/document/obFo...outframe2.html

kindly give me solution.
 
Old April 5th, 2011, 01:32 AM
Authorized User
 
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
Default

sorry for the inconvenience. i have pasted xsl for creating my self. This xsl i use to convert the hole table frame appeared. but when i'm need table frame (based on spanname, if spanname present row frame apply entire row, if spanname present entry frame apply particular entry).

Kindly look at above attached pdf file.

XSLT Coding

<xsl:template match="tgroup">
<table cellpadding="5" cellspacing="0" width="100%">
<xsl:choose>
<xsl:when test="@frame='top'">
<xsl:attribute name="style">border-top: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:when test="@frame='bottom'">
<xsl:attribute name="style">border-bottom: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:when test="@frame='topbot'">
<xsl:attribute name="style">border-top: 2px solid #000000; border-bottom: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:when test="@frame='all'">
<xsl:attribute name="style">border: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:when test="@frame='sides'">
<xsl:attribute name="style">border-left: 2px solid #000000; border-right: 2px solid #000000;</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:apply-templates/>

</table>
</xsl:template>

<xsl:template match="thead">
<thead>
<xsl:choose>
<xsl:when test="@valign">
<xsl:attribute name="valign"><xsl:value-of select="@valign"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="valign">bottom</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</thead>
</xsl:template>

<xsl:template match="tbody">
<tbody>
<xsl:choose>
<xsl:when test="@valign">
<xsl:attribute name="valign"><xsl:value-of select="@valign"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="valign">top</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</tbody>
</xsl:template>

<xsl:template match="row">
<tr>

<xsl:choose>
<xsl:when test="@valign">
<xsl:attribute name="valign"><xsl:value-of select="@valign"/></xsl:attribute>
</xsl:when>
</xsl:choose>

<xsl:choose>
<xsl:when test="@align">
<xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="align">left</xsl:attribute>
</xsl:otherwise>
</xsl:choose>

<xsl:choose>
<xsl:when test="@frame='top'">
<xsl:attribute name="style">border-top: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:when test="@frame='bottom'">
<xsl:attribute name="style">border-bottom: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:when test="@frame='topbot'">
<xsl:attribute name="style">border-top: 2px solid #000000; border-bottom: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:when test="@frame='all'">
<xsl:attribute name="style">border: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:when test="@frame='sides'">
<xsl:attribute name="style">border-left: 2px solid #000000; border-right: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">border: 1px solid #000000; border-right: 2px solid #000000;</xsl:attribute>
</xsl:otherwise>
</xsl:choose>

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

</xsl:template>
<xsl:template match="entry">
<td>

<xsl:choose>
<xsl:when test="@valign">
<xsl:attribute name="valign"><xsl:value-of select="@valign"/></xsl:attribute>
</xsl:when>
</xsl:choose>

<xsl:choose>
<xsl:when test="@align">
<xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="align">left</xsl:attribute>
</xsl:otherwise>
</xsl:choose>

<xsl:choose>
<xsl:when test="@spanname">
<xsl:variable name="spec" select="ancestor::tgroup/spanspec[@spanname=current()/@spanname]"/>
<xsl:variable name="col1" select="ancestor::tgroup/colspec[@colname=$spec/@namest]"/>
<xsl:variable name="col2" select="ancestor::tgroup/colspec[@colname=$spec/@nameend]"/>

<xsl:attribute name="colspan">
<xsl:value-of select="$col2/@colnum - $col1/@colnum + 1"/>
</xsl:attribute>

</xsl:when>
<xsl:otherwise>
<xsl:attribute name="colspan">0</xsl:attribute>
</xsl:otherwise>
</xsl:choose>

<xsl:choose>
<xsl:when test="@frame='top'">
<xsl:attribute name="style">border-top: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:when test="@frame='bottom'">
<xsl:attribute name="style">border-bottom: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:when test="@frame='topbot'">
<xsl:attribute name="style">border-top: 2px solid #000000; border-bottom: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:when test="@frame='all'">
<xsl:attribute name="style">border: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:when test="@frame='sides'">
<xsl:attribute name="style">border-left: 2px solid #000000; border-right: 2px solid #000000;</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">border: 2px solid #000000; border-right: 2px solid #000000;</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="@morerows">
<xsl:attribute name="rowspan"><xsl:value-of select="number(@morerows)+1"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="rowspan">0</xsl:attribute>
</xsl:otherwise>
</xsl:choose>

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


Kindly give solution.





Similar Threads
Thread Thread Starter Forum Replies Last Post
parsing form data from frame to other frame audio-catalyst Classic ASP Basics 5 January 3rd, 2006 02:57 PM
view table using asp code ernafarizan Classic ASP Basics 4 March 8th, 2005 07:46 PM
Call right frame Page_Load event from left frame. ochanarachel Classic ASP Basics 0 January 28th, 2005 05:13 AM
Table View and DB Changes rander3328 SQL Server 2000 3 September 16th, 2004 11:18 AM
Table Question - Can you make a cell into a frame? freaky al Dreamweaver (all versions) 11 November 4th, 2003 01:56 PM





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