Cerebrus

XSLT Templates Application

Feb 25th, 2010
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 0.84 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <x:stylesheet version="1.0" xmlns:x="http://www.w3.org/1999/XSL/Transform">
  3.   <x:output method="html" />
  4.  
  5.   <x:template match="/">
  6.     <html>
  7.       <head>
  8.         <title></title>
  9.       </head>
  10.       <body>
  11.         <table border="1">
  12.           <x:apply-templates select="persons/person" />
  13.         </table>
  14.       </body>
  15.     </html>
  16.   </x:template>
  17.  
  18.   <x:template match="person">
  19.     <x:apply-templates select="children/child" />
  20.   </x:template>
  21.  
  22.   <x:template match="child">
  23.     <tr>
  24.       <x:if test="position() = 1">
  25.         <td rowspan="2">
  26.           <x:value-of select="ancestor::person/name" />
  27.         </td>
  28.       </x:if>
  29.       <td>
  30.         <x:value-of select="name" />
  31.       </td>
  32.       <td>
  33.         <x:value-of select="age" />
  34.       </td>
  35.     </tr>
  36.   </x:template>
  37.  
  38. </x:stylesheet>
Add Comment
Please, Sign In to add comment