[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] XSL XML Vertical Table Layout


Subject: RE: [xsl] XSL XML Vertical Table Layout
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 13 Oct 2008 23:16:10 +0100

Something like this:

<xsl:template match="text">
  <table>
    <tr>
      <td>Title:</td>
      <td><xsl:value-of select="title"/></td>
      <td rowspan="9"><img src="{book}"/></td>
    </tr> 
    <tr>
      <td>Author:</td>
      <td><xsl:value-of select="author"/></td>
    </tr> 
    <tr>
      <td>Edition:</td>
      <td><xsl:value-of select="edition"/></td>
    </tr>

etc.

Pretty straightforward really.

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: Mary Pat Rhodes [mailto:mpr@xxxxxxxxxxxx] 
> Sent: 13 October 2008 22:31
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] XSL XML Vertical Table Layout
> 
> Here is the output I would like to get in the first column, 
> headings; =20 second column, book info; third column with a 
> image (picture).
> I need it to match my html file exactly; which can be viewed at =20
> http//www.mprhodes.com/rte/textbooks.html:
> 
> Title:      Business Data Communication
> 
> Author:                William Stallings
> Edition: 5th
> Year:      2004
> ISBN:     0-12345-0
> Subject:               Communication
> Condition:           New
> Price:     $ 122.00
> 
> Title:      Computer Networking: A Top-Down Approach
> 
> Author:                James F. Kurose, Keith W. Ross
> Edition: 4th
> Year:      2005
> ISBN:     0-321-49770-8
> Subject:               Networking
> Condition:           New
> Price:     $104.67
> 
> .
> .
> .
> 
> And so on for 8 more textbooks.
> 
> Here is the xml:
> 
> <catalog>
>       <text>
>           <book>images/BusinessDataCommunications.jpg</book>
>           <title>Business Data Communications</title>
>           <author>William Stallings</author>
>           <edition>5th</edition>
>           <year>2004</year>
>           <isbn>0-13-144257-0</isbn>
>           <cover>Hardcover</cover>
>           <subject>Networks</subject>
>           <condition>New</condition>
>           <price>$ 122.00</price>
>       </text>
> 
>       <text>
>           <book>images/ComputerNetworking.jpg</book>
>           <title>Computer Networking: A Top-Down Approach</title>
>           <author>James F. Kurose, Keith W. Ross</author>
>           <edition>4th</edition>
>           <year>2005</year>
>           <isbn>0-321-49770-8</isbn>
>           <cover>Hardcover</cover>
>           <category>Networks</category>
>           <condition>New</condition>
>           <price>$104.67</price>
>       </text>
> 
>       <text>
>           <book>images/ComputerScienceIlluminated.jpg</book>
>           <title>Computer Science Illuminated</title>
>           <author>Nell Dale, John Lewis</author>
>           <edition>3rd</edition>
>           <year>2006</year>
>           <isbn>0-7637-4149-3</isbn>
>           <cover>Paperback</cover>
>           <category>Computer Science</category>
>           <condition>New</condition>
>           <price>$ 91.95</price>
>       </text>
> 
>       <text>
>           <book>images/CPlusPlus.jpg</book>
>           <title>C++ How to Program</title>
>           <author>Deitel &amp; Associates Inc.</author>
>           <edition>6th</edition>
>           <year>2007</year>
>           <isbn>0-13-615250-3</isbn>
>           <cover>Paperback</cover>
>           <category>Programming</category>
>           <condition>New</condition>
>           <price>$ 115.00</price>
>       </text>
> 
>       <text>
>           <book>images/Java.jpg</book>
>           <title>Java: An Introduction to Problem Solving and 
> =20 Programming</title>
>           <author>Walter Savitch</author>
>           <edition>4th</edition>
>           <year>2005</year>
>           <isbn>0-13-149202-0</isbn>
>           <cover>Paperback</cover>
>           <category>Programming</category>
>           <condition>New</condition>
>           <price>$ 79.69</price>
>       </text>
> 
>       <text>
>           <book>images/DatabaseSystems.jpg</book>
>           <title>Fundamentals of Database Systems</title>
>           <author>Ramez Elmasri, Shamkant B. Navathe</author>
>           <edition>5th</edition>
>           <year>2006</year>
>           <isbn>0-3213-6957-2</isbn>
>           <cover>Hardcover</cover>
>           <category>Database</category>
>           <condtion>New</condtion>
>           <price>$ 83.84</price>
>       </text>
> 
>       <text>
>           <book>images/DiscreteMathematics.jpg</book>
>           <title>Discrete Mathematics: International Edition</title>
>           <author>Richard Johnsonbaugh</author>
>           <edition>7th</edition>
>           <year>2008</year>
>           <isbn>0-13-135430-2</isbn>
>           <cover>Paperback</cover>
>           <category>Mathematics</category>
>           <condition>New</condition>
>           <price>$ 76.88</price>
>       </text>
> 
>       <text>
>           <book>images/TakingCharge.jpg</book>
>           <title>Taking Charge of Your Career Direction: 
> Career =20 Planning Guide</title>
>           <author>Robert D. Lock</author>
>           <edition>5th</edition>
>           <year>2004</year>
>           <isbn>0-5345-7426-2</isbn>
>           <cover>Paperback</cover>
>           <category>Pyscology</category>
>           <condition>New</condition>
>           <price>$ 53.64</price>
>       </text>
> 
>       <text>
>           <book>images/MSAccess2007.jpg</book>
>           <title>Microsoft Office Access 2007 Forms, Reports, 
> and =20 Queries</title>
>           <author>Paul McFedrie</author>
>           <edition>2nd</edition>
>           <year>2007</year>
>           <isbn>0-7897-3669-1</isbn>
>           <cover>Paperback</cover>
>           <category>Technology</category>
>           <condition>New</condition>
>           <price>$ 39.99</price>
>       </text>
> 
>       <text>
>           <book>images/Excel2007.jpg</book>
>           <title>Formulas and Functions with Microsoft Office 
> Excel 2007</tit=
> le>
>           <author>Paul McFedries</author>
>           <edition>1st</edition>
>           <year>2007</year>
>           <isbn>0-7897-3668-3</isbn>
>           <cover>Paperback</cover>
>           <category>Technology</category>
>           <condition>New</condition>
>           <price>$ 39.99</price>
>       </text>
> </catalog>[/code]
> 
> And here is the xsl
> [code] <TR>
>                           <TH>Book</TH>
>                           <TD>Title:</TD>
>                           <TD>Author:</TD>
>                           <TD>Publisher:</TD>
>                           <TD>ISBN:</TD>
>                           <TD>Year:</TD>
>                           <TD>Cover:</TD>
>                           <TD>Subject:</TD>
>                           <TD>Price:</TD>
>                       </TR>
> 
> 
> 
>                           <xsl:for-each select=3D"catalog/text">
>                               <TR>
>                                   <TD>
>                                       <img>
>                                           <xsl:attribute name 
> =3D "src">
>                                               <xsl:value-of 
> select=3D"book"/>
>                                           </xsl:attribute>
>                                       </img>
> 
>                                   </TD>
> 
> 
>                                   <TD Align=3D"Center"  
> Valign=3D"Middle" =20 width=3D"250" height=3D"25">
>                                       <xsl:value-of select=3D"title"/>
>                                   </TD>
> 
>                                   <TD Align=3D"left" 
> Valign=3D"Middle"  
> height= =3D"60">
> 
>                                       <xsl:value-of 
> select=3D"author"/>
>                                   </TD>
> 
>                                   <TD Align=3D"Center" 
> Valign=3D"Middle">
>                                       <xsl:value-of 
> select=3D"edition"/>
>                                   </TD>
> 
>                                   <TD Align=3D"Center" 
> Valign=3D"Middle">
>                                       <xsl:value-of select=3D"year"/>
>                                   </TD>
> 
>                                   <TD Align=3D"Center" 
> Valign=3D"Middle">
>                                       <xsl:value-of select=3D"isbn"/>
>                                   </TD>
> 
>                                   <TD Align=3D"Center" 
> Valign=3D"Middle">
>                                       <xsl:value-of select=3D"cover"/>
>                                   </TD>
> 
>                                   <TD Align=3D"Center" 
> Valign=3D"Middle">
>                                       <xsl:value-of 
> select=3D"subject"/>
>                                   </TD>
> 
>                                   <TD Align=3D"Center" 
> Valign=3D"Middle">
>                                       <xsl:value-of 
> select=3D"condition"/>
>                                   </TD>
> 
>                                   <TD Align=3D"Center" 
> Valign=3D"Middle">
>                                       <xsl:value-of select=3D"price"/>
>                                   </TD>
>                               </TR>
>                           </xsl:for-each>
>                          </tr>
>                          </table>
>           </body>
> 
>            </xsl:template>
>       </xsl:stylesheet>
> 
> 
> I do not how to get the layout to output, can you help?
> Thanks,
> Mary Pat


Current Thread
Keywords
xsl