If we think about html, I want manage 2 div for content data.1 is list data and 2 is for summary. Like this image
In xsl, This is my code
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/hotels"> <html> <body> <h2>Transform 2</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Name</th> <th>Type</th> <th>Rating</th> <th>Address</th> </tr> <xsl:apply-templates select="hotel[rating >= 4]"/> </table> </body> </html> </xsl:template> <xsl:template match="hotel"> <tr> <td><xsl:value-of select="name"/></td> <td><xsl:value-of select="type"/></td> <td><xsl:value-of select="rating"/></td> <td><xsl:value-of select="address"/></td> </tr> </xsl:template> </xsl:stylesheet> And my XML code is
<hotels> <hotel contact="(855) 23 430 732"> <name>hotel A</name> <type>hotel</type> <rating>5</rating> <address> <houseNo>73 </houseNo> <street>Preah Monivong Blvd </street> <Sangkat>Mean Chey</Sangkat > <Khan>Daun Penh</Khan> <city>Bangkok</city> </address> <room> <roomType>hotel: standard/deluxe, apartment: studio/2-bedroom/3-bedroom</roomType> <price>209</price> <description>Descriptions</description> </room> <room> <roomType>hotel: standard/deluxe, apartment: studio/2-bedroom/3-bedroom</roomType> <price>210</price> <description>Descriptions</description> </room> </hotel> <hotel> ..... </hotel> My problem: How I can write second templates for content summary data. (I stupid to make layout. )
No comments:
Post a Comment