Project

General

Profile

metacat / xsqltest / dsquery.xsl @ 42

1
<?xml version="1.0"?>
2
<!--
3
  * dsquery.xsl
4
  *
5
  *      Authors: Matt Jones
6
  *    Copyright: 2000 Regents of the University of California and the 
7
  *               National Center for Ecological Analysis and Synthesis
8
  *  For Details: http://www.nceas.ucsb.edu/
9
  *      Created: 2000 April 5
10
  *      Version: 0.01
11
  *    File Info: '$Id: dsquery.xsl 42 2000-04-14 03:37:19Z jones $'
12
  *
13
  * This is an XSLT (http://www.w3.org/TR/xslt) stylesheet designed to
14
  * convert an XML file listing datasets returned from a database query
15
  * into an HTML format suitable for rendering with modern web browsers.
16
-->
17
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
18

    
19
  <xsl:output method="html"/>
20

    
21
  <xsl:template match="/">
22
     <html>
23
       <head>
24
         <title><xsl:value-of select="//head/title"/></title>
25
	 <link rel="stylesheet" type="text/css" href="./rowcol.css" />
26
       </head>
27
       <body class="emlbody"> 
28
         <xsl:apply-templates/>      
29
       </body>
30
     </html>
31
  </xsl:template>
32

    
33
  <xsl:template match="form">
34
    <form>
35
       <xsl:attribute name="method">
36
         <xsl:value-of select="method"/>
37
       </xsl:attribute>
38
       <xsl:attribute name="action">
39
         <xsl:value-of select="action"/>
40
       </xsl:attribute>
41
       <xsl:apply-templates/>
42
    </form>
43
  </xsl:template>
44

    
45
  <xsl:template match="method">
46
  </xsl:template>
47

    
48
  <xsl:template match="action">
49
  </xsl:template>
50

    
51
  <xsl:template match="textfield">
52
    <input type="text">
53
      <xsl:attribute name="name"><xsl:value-of select="name"/></xsl:attribute>
54
      <xsl:attribute name="value"><xsl:value-of select="val"/></xsl:attribute>
55
    </input>
56
  </xsl:template>
57

    
58
  <xsl:template match="input">
59
    <xsl:copy-of select="."/>
60
  </xsl:template>
61

    
62
  <xsl:template match="section">
63
    <h2><xsl:value-of select="."/></h2>
64
  </xsl:template>
65

    
66
  <xsl:template match="//head/title"/>
67

    
68
  <xsl:template match="meta_file_id">
69
    <a>
70
    <xsl:attribute name="href">/xmltodb/xsqltest/eml-dataset2.xsql?meta_file_id=<xsl:value-of select="."/></xsl:attribute>
71
    <xsl:value-of select="."/>
72
    </a>
73
  </xsl:template>
74

    
75
  <xsl:template match="originators">
76
    <xsl:for-each select="originators_row">
77
      <xsl:value-of select="salutation"/> 
78
      <xsl:text> </xsl:text>
79
      <xsl:value-of select="given_name"/> 
80
      <xsl:text> </xsl:text>
81
      <xsl:value-of select="surname"/>
82
      <xsl:if test="not(position()=last())">, </xsl:if> 
83
    </xsl:for-each>
84
  </xsl:template>
85

    
86
    <xsl:template match="rowset">
87
      <center>
88
      <table border="0" cellpadding="4">
89
      <xsl:choose>
90
        <xsl:when test="row">
91
	  <xsl:for-each select="row[1]">
92
	    <tr>
93
	      <xsl:for-each select="*[not(starts-with(name(.),'H_'))]">
94
		<th align="left">
95
		  <xsl:attribute name="class">
96
		    <xsl:choose>
97
		      <xsl:when test="position() mod 2 = 1">colodd</xsl:when>
98
		      <xsl:when test="position() mod 2 = 0">coleven</xsl:when>
99
		    </xsl:choose>
100
		  </xsl:attribute>
101
		  <xsl:value-of select="name(.)"/>
102
		</th>
103
	      </xsl:for-each>
104
	    </tr>
105
	  </xsl:for-each>
106
	  <xsl:apply-templates/>
107
        </xsl:when>
108
        <xsl:otherwise>
109
          <tr><td>No Matches</td></tr> 
110
        </xsl:otherwise>
111
      </xsl:choose>
112
      </table>
113
      </center>
114
    </xsl:template>
115

    
116
    <xsl:template match="row">
117
        <tr>
118
          <xsl:attribute name="class">
119
            <xsl:choose>
120
              <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
121
              <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
122
            </xsl:choose>
123
          </xsl:attribute>
124
          <xsl:attribute name="valign">
125
            top
126
          </xsl:attribute>
127

    
128
          <xsl:for-each select="*[not(starts-with(name(.),'H_'))]">
129
            <td>
130
	      <xsl:attribute name="class">
131
		<xsl:choose>
132
		  <xsl:when test="position() mod 2 = 1">colodd</xsl:when>
133
		  <xsl:when test="position() mod 2 = 0">coleven</xsl:when>
134
		</xsl:choose>
135
	      </xsl:attribute>
136
              <xsl:apply-templates select='.'/>
137
            </td>
138
          </xsl:for-each>
139
        </tr>
140
  </xsl:template>
141

    
142
</xsl:stylesheet>