Project

General

Profile

« Previous | Next » 

Revision 34

Added by Matt Jones over 24 years ago

added example files showing use of Oracle's XSQL utiltiy for metadata storage and retrieval

View differences:

xsqltest/contents.html
1
<!--
2
  * contents.html
3
  *
4
  *      Authors: Matt Jones
5
  *    Copyright: 2000 Regents of the University of California and the
6
  *               National Center for Ecological Analysis and Synthesis
7
  *  For Details: http://www.nceas.ucsb.edu/
8
  *      Created: 2000 April 5
9
  *      Version: 0.01
10
  *    File Info: '$Id$'
11
  * 
12
  * This is an HTML document for displaying examples of the use of 
13
  * Oracle XML tools
14
-->
15
<html>
16
<head>
17
<title>XSL Transformation and formatting examples</title>
18
</head>
19
<body bgcolor="white">
20
<B>XSL Transformation and formatting examples -- Oracle tools</B><P>
21
<B>Example 1</B><BR>
22
Simple database query against Oracle8i<BR>
23
<UL>
24
<LI>View <A HREF="xmltest2.xsql" TARGET="right">XSL transformed html output</A>
25
<LI>View <A HREF="xmltest2.xsql?xml-stylesheet=none" 
26
	    TARGET="right">raw xml output</A>
27
<LI>View <A HREF="xmltest2-xsql.xml" TARGET="right">XSQL source</A>
28
<LI>View <A HREF="rowcol.xsl" TARGET="right">XSL source</A>
29
</UL>
30
<P>
31
<B>Example 2</B><BR>
32
Simple eml-dataset display from Oracle8i database<BR>
33
<p><i>Note: these examples are not actually valid according to
34
eml-dataset.dtd, but they are close and I am working on it...</i></p>
35
<UL>
36
<LI>View <A HREF="dsquery.xsql" TARGET="right">Dynamic query (html output)</A>
37
<LI>View <A HREF="dsquery.xsql?xml-stylesheet=none" TARGET="right">Dynamic query (raw xml output)</A>
38
<LI>View <A HREF="dsquery-xsql.xml" TARGET="right">Dynamic query (XSQL source)</A>
39
<LI>View <A HREF="dsquery.xsl" TARGET="right">Dynamic query (XSL source)</A>
40
<LI>View <A HREF="eml-dataset2.xsql" 
41
    TARGET="right">XSL transformed html output</A>
42
<LI>View <A HREF="eml-dataset1.xsql?meta_file_id=NCEAS-1998-2244-Dist-Dataset" 
43
    TARGET="right">transformed xml output</A>
44
<LI>View <A HREF="eml-dataset1.xsql?meta_file_id=NCEAS-1998-2244-Dist-Dataset&xml-stylesheet=none" TARGET="right">raw xml output</A>
45
<LI>View <A HREF="eml-dataset1-xsql.xml" TARGET="right">XSQL source</A>
46
<LI>View <A HREF="eml-dataset.xsl" TARGET="right">XSL source (XML to XML)</A>
47
<LI>View <A HREF="eml-dataset-display.xsl" TARGET="right">XSL source (XML to HTML)</A>
48
</UL>
49
<P>
50
</body>
51
</html>
0 52

  
xsqltest/dsquery-xsql.xml
1
<?xml version = '1.0'?>
2
<!--
3
  * dsquery.xsql
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$'
12
  * 
13
  * This is an XSQL (http://technet.oracle.com/tech/xml) document designed
14
  * to query a relational database and return the result as a well-formed
15
  * XML document. The query is a general search for datasets that match
16
  * search criteria from a metadata catalog containing documents that are 
17
  * valid with respect to the eml-dataset.dtd module of the Ecological 
18
  * Metadata Language (EML)
19
-->
20
<html connection="demo" xmlns:xsql="urn:oracle-xsql">
21
<head><title>Query Demo</title></head>
22
<body>
23
<section>Query form</section>
24
<form>
25
  <method>POST</method>
26
  <action>/xsqltest/dsquery.xsql</action>
27
  <textfield>
28
    <name>search_string</name>
29
    <xsql:query tag-case="lower" 
30
                rowset-element="" row-element="" id-attribute="">
31
       select '{@search_string}' AS val FROM DUAL
32
    </xsql:query>
33
  </textfield>
34
  <input type="submit" name="Run query"/>
35
</form>
36
<section>Results</section>
37
<xsql:query tag-case="lower">
38

  
39
  SELECT meta_file_id,dataset_id,title, 
40
         CURSOR (SELECT salutation,given_name,surname
41
                   FROM party_individual pi
42
                  WHERE pi.party_individual_id IN
43
                        (SELECT party_individual_id FROM party p
44
                          WHERE p.meta_file_id = ds.meta_file_id)) as originators 
45
    FROM eml_dataset ds
46
   WHERE UPPER(meta_file_id) LIKE UPPER('%{@search_string}%')
47
      OR UPPER(dataset_id)  LIKE UPPER('%{@search_string}%')
48
      OR UPPER(title)  LIKE UPPER('%{@search_string}%')
49
      OR UPPER(abstract) LIKE UPPER('%{@search_string}%')
50
</xsql:query>
51
</body>
52
</html>
0 53

  
xsqltest/dsquery.xsl
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$'
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="eml-dataset"> 
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">/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>
0 143

  
xsqltest/dsquery.xsql
1
<?xml version = '1.0'?>
2
<!--
3
  * dsquery.xsql
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$'
12
  * 
13
  * This is an XSQL (http://technet.oracle.com/tech/xml) document designed
14
  * to query a relational database and return the result as a well-formed
15
  * XML document. The query is a general search for datasets that match
16
  * search criteria from a metadata catalog containing documents that are 
17
  * valid with respect to the eml-dataset.dtd module of the Ecological 
18
  * Metadata Language (EML)
19
-->
20
<?xml-stylesheet type="text/xsl" href="dsquery.xsl"?>
21
<html connection="demo" xmlns:xsql="urn:oracle-xsql">
22
<head><title>Query Demo</title></head>
23
<body>
24
<section>Query form</section>
25
<form>
26
  <method>POST</method>
27
  <action>/xsqltest/dsquery.xsql</action>
28
  <textfield>
29
    <name>search_string</name>
30
    <xsql:query tag-case="lower" 
31
                rowset-element="" row-element="" id-attribute="">
32
       select '{@search_string}' AS val FROM DUAL
33
    </xsql:query>
34
  </textfield>
35
  <input type="submit" name="Run query"/>
36
</form>
37
<section>Results</section>
38
<xsql:query tag-case="lower">
39

  
40
  SELECT meta_file_id,dataset_id,title, 
41
         CURSOR (SELECT salutation,given_name,surname
42
                   FROM party_individual pi
43
                  WHERE pi.party_individual_id IN
44
                        (SELECT party_individual_id FROM party p
45
                          WHERE p.meta_file_id = ds.meta_file_id)) as originators 
46
    FROM eml_dataset ds
47
   WHERE UPPER(meta_file_id) LIKE UPPER('%{@search_string}%')
48
      OR UPPER(dataset_id)  LIKE UPPER('%{@search_string}%')
49
      OR UPPER(title)  LIKE UPPER('%{@search_string}%')
50
      OR UPPER(abstract) LIKE UPPER('%{@search_string}%')
51
</xsql:query>
52
</body>
53
</html>
0 54

  
xsqltest/eml-dataset.xsl
1
<?xml version="1.0"?>
2
<!--
3
  * eml-dataset.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$'
12
  * 
13
  * This is an XSLT (http://www.w3.org/TR/xslt) stylesheet designed to
14
  * convert an XML file that is the result of a SQL query using Oracle's
15
  * XSQL tool to another XML file that is valid with respect to the 
16
  * eml-dataset.dtd module of Ecological Metadata Language (EML)
17
-->
18
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
19

  
20
  <xsl:template match="/">
21
    <?xml-stylesheet type="text/xsl" href="eml-dataset-display.xsl"?>
22
    <eml-dataset>
23
      <xsl:apply-templates/>      
24
    </eml-dataset>
25
  </xsl:template>
26

  
27
  <xsl:template match="originator">
28
    <originator>
29
      <xsl:choose>
30
      <xsl:when test="party_org">
31
          <party><party_org><xsl:value-of select="."/></party_org></party>
32
      </xsl:when>
33
        <xsl:otherwise>
34
          <party>
35
            <party_individual>
36
              <xsl:for-each select="salutation|given_name|surname|jobtitle">
37
                 <xsl:copy-of select="."/>
38
              </xsl:for-each>
39
            </party_individual>
40
          </party>
41
        </xsl:otherwise>
42
      </xsl:choose>
43
      <meta_address>
44
        <xsl:for-each select="address|city|admin_area|postal_code|country|resource_url|email|work_phone|home_phone|fax|tdd_phone">
45
           <xsl:copy-of select="."/>
46
        </xsl:for-each>
47
      </meta_address>
48
    </originator> 
49
  </xsl:template>
50

  
51
  <xsl:template match="meta_file_id|dataset_id|title|abstract|keyword_info">
52
    <xsl:copy-of select="."/>
53
  </xsl:template>
54

  
55
</xsl:stylesheet>
0 56

  
xsqltest/eml-dataset1-xsql.xml
1
<?xml version="1.0"?>
2
<!--
3
  * eml-dataset1.xsql
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$'
12
  * 
13
  * This is an XSQL (http://technet.oracle.com/tech/xml) document designed
14
  * to query a relational database and return the result as a well-formed
15
  * XML document that contains the information necessary to transform the
16
  * document into the eml-dataset.dtd module of the Ecological Metadata
17
  * Language (EML)
18
-->
19
<eml-dataset connection="demo" xmlns:xsql="urn:oracle-xsql">
20

  
21
<xsql:query tag-case="lower" 
22
            rowset-element="" 
23
            row-element="" 
24
            id-attribute="">
25

  
26
  SELECT meta_file_id,dataset_id,title FROM eml_dataset
27
   WHERE meta_file_id = '{@meta_file_id}'
28

  
29
</xsql:query>
30

  
31
<xsql:query tag-case="lower" 
32
            row-element="originator" 
33
            rowset-element="" 
34
            id-attribute="">
35

  
36
  SELECT p.party_org, pi.salutation, pi.given_name, pi.surname, pi.jobtitle, 
37
         ma.address, ma.city, ma.admin_area, ma.postal_code, ma.country,
38
         ma.resource_url, ma.email, ma.work_phone, ma.home_phone, ma.fax,
39
         ma.tdd_phone 
40
    FROM party p, party_individual pi, meta_address ma
41
   WHERE p.party_individual_id = pi.party_individual_id
42
     AND p.meta_address_id = ma.meta_address_id
43
     AND p.meta_file_id = '{@meta_file_id}'
44

  
45
</xsql:query>
46

  
47
<xsql:query tag-case="lower" 
48
            rowset-element="" 
49
            row-element="" 
50
            id-attribute="">
51

  
52
  SELECT abstract FROM eml_dataset
53
   WHERE meta_file_id = '{@meta_file_id}'
54

  
55
</xsql:query>
56

  
57
<xsql:query tag-case="lower" 
58
            row-element="keyword_info" 
59
            rowset-element="" 
60
            id-attribute="">
61

  
62
  SELECT keyword, keyword_type, keyword_thesaurus
63
    FROM keyword_info
64
   WHERE meta_file_id = '{@meta_file_id}'
65

  
66
</xsql:query>
67

  
68
</eml-dataset>
0 69

  
xsqltest/xmltest2-xsql.xml
1
<?xml version="1.0"?>
2
<!--
3
  * xmltest2.xsql
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$'
12
  * 
13
  * This is an XSQL (http://technet.oracle.com/tech/xml) document designed
14
  * to query a relational database and return the result as a well-formed
15
  * XML document.
16
-->
17
<page connection="demo" xmlns:xsql="urn:oracle-xsql">
18
<xsql:query>
19

  
20
  SELECT * FROM xmltest ORDER BY docid
21

  
22
</xsql:query>
23
</page>
0 24

  
xsqltest/eml-dataset1.xsql
1
<?xml version="1.0"?>
2
<!--
3
  * eml-dataset1.xsql
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$'
12
  * 
13
  * This is an XSQL (http://technet.oracle.com/tech/xml) document designed
14
  * to query a relational database and return the result as a well-formed
15
  * XML document that contains the information necessary to transform the
16
  * document into the eml-dataset.dtd module of the Ecological Metadata
17
  * Language (EML)
18
-->
19
<?xml-stylesheet type="text/xsl" href="eml-dataset.xsl"?>
20
<eml-dataset connection="demo" xmlns:xsql="urn:oracle-xsql">
21

  
22
<xsql:query tag-case="lower" 
23
            rowset-element="" 
24
            row-element="" 
25
            id-attribute="">
26

  
27
  SELECT meta_file_id,dataset_id,title FROM eml_dataset
28
   WHERE meta_file_id = '{@meta_file_id}'
29

  
30
</xsql:query>
31

  
32
<xsql:query tag-case="lower" 
33
            row-element="originator" 
34
            rowset-element="" 
35
            id-attribute="">
36

  
37
  SELECT p.party_org, pi.salutation, pi.given_name, pi.surname, pi.jobtitle, 
38
         ma.address, ma.city, ma.admin_area, ma.postal_code, ma.country,
39
         ma.resource_url, ma.email, ma.work_phone, ma.home_phone, ma.fax,
40
         ma.tdd_phone 
41
    FROM party p, party_individual pi, meta_address ma
42
   WHERE p.party_individual_id = pi.party_individual_id
43
     AND p.meta_address_id = ma.meta_address_id
44
     AND p.meta_file_id = '{@meta_file_id}'
45

  
46
</xsql:query>
47

  
48
<xsql:query tag-case="lower" 
49
            rowset-element="" 
50
            row-element="" 
51
            id-attribute="">
52

  
53
  SELECT abstract FROM eml_dataset
54
   WHERE meta_file_id = '{@meta_file_id}'
55

  
56
</xsql:query>
57

  
58
<xsql:query tag-case="lower" 
59
            row-element="keyword_info" 
60
            rowset-element="" 
61
            id-attribute="">
62

  
63
  SELECT keyword, keyword_type, keyword_thesaurus
64
    FROM keyword_info
65
   WHERE meta_file_id = '{@meta_file_id}'
66

  
67
</xsql:query>
68

  
69
</eml-dataset>
0 70

  
xsqltest/eml-dataset-display.xsl
1
<?xml version="1.0"?>
2
<!--
3
  * eml-dataset-display.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$'
12
  *
13
  * This is an XSLT (http://www.w3.org/TR/xslt) stylesheet designed to
14
  * convert an XML file that is valid with respect to the eml-dataset.dtd
15
  * module of the Ecological Metadata Language (EML) into an HTML format 
16
  * suitable for rendering with modern web browsers.
17
-->
18
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
19

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

  
22
  <xsl:template match="/">
23
    <html>
24
      <head>
25
	<link rel="stylesheet" type="text/css" href="./rowcol.css" />
26
      </head>
27
      <body class="eml-dataset">
28
	<center>
29
          <h1>Data set description</h1>
30
          <h3>Ecological Metadata Language</h3>
31
        </center>
32
        <xsl:apply-templates/>      
33

  
34
        <table width="100%">
35
        <tr><td class="rowodd">
36
        <b><xsl:text>Keywords:</xsl:text></b>
37
        </td></tr>
38
        <tr><td>
39
          <ul>
40
            <xsl:for-each select="//keyword_info/keyword">
41
              <li><xsl:value-of select="."/></li>
42
            </xsl:for-each>
43
          </ul>
44
        </td></tr>
45
        </table>
46
         
47

  
48
        <table width="100%">
49
        <tr><td class="rowodd">
50
        <b><xsl:text>Related Metadata and Data Files:</xsl:text></b>
51
        </td></tr>
52
        <tr><td>
53
        <ul>
54
          <xsl:for-each select="//relations">
55
            <li>
56
             <xsl:value-of select="@object"/>
57
             <xsl:text> </xsl:text>
58
             <xsl:value-of select="@relation"/>
59
             <xsl:text> </xsl:text>
60
             <xsl:value-of select="@target"/>
61
            </li>
62
          </xsl:for-each>
63
        </ul>
64
        </td></tr>
65
        </table>
66

  
67
      </body>
68
    </html>
69
  </xsl:template>
70

  
71
  <xsl:template match="meta_file_id">
72
    <table width="100%">
73
    <tr>
74
    <td class="rowodd"><b><xsl:text>Metadata File ID:</xsl:text></b></td>
75
    <td><xsl:value-of select="."/></td>
76
    </tr>
77
      <xsl:for-each select="//dataset_id|//title">
78
        <tr>
79
        <xsl:if test="name(.)='dataset_id'">
80
          <td class="rowodd"><b><xsl:text>Data set ID:</xsl:text></b></td>
81
        </xsl:if>
82
        <xsl:if test="name(.)='title'">
83
          <td class="rowodd"><b><xsl:text>Title:</xsl:text></b></td>
84
        </xsl:if>
85
        <td><xsl:value-of select="."/></td>
86
        </tr>
87
      </xsl:for-each>
88
    </table>
89

  
90
  </xsl:template>
91

  
92
  <xsl:template match="dataset_id"/>
93
  <xsl:template match="title"/>
94

  
95
  <xsl:template match="originator[1]">
96
      <table width="100%">
97
      <tr><td class="rowodd">
98
      <b><xsl:text>Data Set Owner(s):</xsl:text></b>
99
      </td></tr>
100
      </table>
101
  </xsl:template>
102

  
103
  <xsl:template match="party_org">
104
    <br><b><xsl:value-of select="."/></b></br>
105
  </xsl:template>
106

  
107
  <xsl:template match="party_individual">
108
    <br>
109
    <b>
110
       <xsl:value-of select="./salutation"/>
111
       <xsl:text> </xsl:text>
112
       <xsl:value-of select="./given_name"/>
113
       <xsl:text> </xsl:text>
114
       <xsl:value-of select="./surname"/>
115
    </b></br>
116
    <br><xsl:value-of select="./title"/></br>
117
  </xsl:template>
118

  
119
  <xsl:template match="meta_address">
120
    <table>
121
    <xsl:for-each select="./address">
122
      <tr>
123
      <td><xsl:value-of select="."/></td>
124
      </tr>
125
    </xsl:for-each>
126
    <tr>
127
    <td><xsl:value-of select="./city"/>
128
        <xsl:text>, </xsl:text>
129
        <xsl:value-of select="./admin_area"/>
130
        <xsl:text> </xsl:text>
131
        <xsl:value-of select="./postal_code"/>
132
    </td>
133
    </tr>
134
    <xsl:if test="./work_phone">
135
      <tr><td><xsl:text>Work: </xsl:text><xsl:value-of select="./work_phone"/>
136
       </td></tr>
137
    </xsl:if>
138
    <xsl:if test="./home_phone">
139
      <tr><td><xsl:text>Home: </xsl:text><xsl:value-of select="./home_phone"/>
140
       </td></tr>
141
    </xsl:if>
142
    <xsl:if test="./fax">
143
      <tr><td><xsl:text>Fax: </xsl:text><xsl:value-of select="./fax"/></td></tr>
144
    </xsl:if>
145
    <xsl:if test="./email">
146
      <tr><td><xsl:value-of select="./email"/></td></tr>
147
    </xsl:if>
148
    <xsl:if test="./resource_url">
149
      <tr><td><xsl:value-of select="./resource_url"/></td></tr>
150
    </xsl:if>
151
    </table>
152
  </xsl:template>
153

  
154
  <xsl:template match="abstract">
155
    <table width="100%">
156
    <tr>
157
    <td class="rowodd"><b><xsl:text>Abstract:</xsl:text></b></td>
158
    </tr>
159
    <tr>
160
    <td><xsl:value-of select="."/></td>
161
    </tr></table>
162
  </xsl:template>
163

  
164
  <xsl:template match="keyword_info"/>
165
  <xsl:template match="relations"/>
166

  
167
</xsl:stylesheet>
0 168

  
xsqltest/eml-dataset2.xsql
1
<?xml version="1.0"?>
2
<!--
3
  * eml-dataset2.xsql
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$'
12
  * 
13
  * This is an XSQL (http://technet.oracle.com/tech/xml) document designed
14
  * to cause an XSLT (http://www.w3.org/TR/xslt) stylesheet transformation
15
  * of the results of another XSLT query
16
-->
17
<?xml-stylesheet type="text/xsl" href="eml-dataset-display.xsl"?>
18
<xsql:include-xsql 
19
      href="eml-dataset1.xsql?meta_file_id=NCEAS-1998-2244-Dist-Dataset" 
20
      xmlns:xsql="urn:oracle-xsql"/>
0 21

  
xsqltest/xmltest2.xsql
1
<?xml version="1.0"?>
2
<!--
3
  * xmltest2.xsql
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$'
12
  * 
13
  * This is an XSQL (http://technet.oracle.com/tech/xml) document designed
14
  * to query a relational database and return the result as a well-formed
15
  * XML document.
16
-->
17
<?xml-stylesheet type="text/xsl" href="rowcol.xsl"?>
18
<page connection="demo" xmlns:xsql="urn:oracle-xsql">
19
<xsql:query>
20

  
21
  SELECT * FROM xmltest ORDER BY docid
22

  
23
</xsql:query>
24
</page>
0 25

  
xsqltest/index.html
1
<!--
2
  * index.html
3
  *
4
  *      Authors: Matt Jones
5
  *    Copyright: 2000 Regents of the University of California and the
6
  *               National Center for Ecological Analysis and Synthesis
7
  *  For Details: http://www.nceas.ucsb.edu/
8
  *      Created: 2000 April 5
9
  *      Version: 0.01
10
  *    File Info: '$Id$'
11
  * 
12
  * This is an HTML document for displaying examples of the use of 
13
  * Oracle XML tools
14
-->
15
  <HTML>
16
  <HEAD>
17
  <TITLE>XSL Transformation examples</TITLE>
18
  </HEAD> 
19
  <FRAMESET ROWS="*" FRAMEBORDER=0 BORDER=0>
20

  
21
    <FRAMESET COLS="250,*"  FRAMEBORDER=0 BORDER=0>
22
    
23
    <FRAME SRC="contents.html" BORDER=0 NAME="left">
24

  
25
    <FRAME SRC="xmltest2.xsql" BORDER=0 NAME="right">
26

  
27
    </FRAMESET>
28
  </FRAMESET>
0 29

  
xsqltest/rowcol.xsl
1
<?xml version="1.0"?>
2
<!--
3
  * rowcol.xsl
4
  *
5
  * This is an XSLT (http://www.w3.org/TR/xslt) stylesheet designed to
6
  * convert an XML file that is the result of a SQL query using Oracle's
7
  * XSQL tool to HTML format using a generic tabular display. Cascading
8
  * Style Sheets (CSS) are used to create some styling effects.
9
-->
10
<!--
11
| $Author$
12
| $Date$
13
| $Source$
14
| $Revision$
15
+-->
16
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
17

  
18

  
19
  <xsl:template match="/">
20
    <html>
21
      <head>
22
	<link rel="stylesheet" type="text/css" href="./rowcol.css" />
23
      </head>
24
      <body class="page">
25
	<center><h1>XSL Transformed View</h1></center>
26
        <xsl:apply-templates/>      
27
      </body>
28
    </html>
29
  </xsl:template>
30

  
31
    <xsl:template match="ROWSET">
32
      <center>
33
      <table border="0" cellpadding="4">
34
      <xsl:choose>
35
        <xsl:when test="ROW">
36
	  <xsl:for-each select="ROW[1]">
37
	    <tr>
38
	      <xsl:for-each select="*[not(starts-with(name(.),'H_'))]">
39
		<th align="left">
40
		  <xsl:attribute name="class">
41
		    <xsl:choose>
42
		      <xsl:when test="position() mod 2 = 1">colodd</xsl:when>
43
		      <xsl:when test="position() mod 2 = 0">coleven</xsl:when>
44
		    </xsl:choose>
45
		  </xsl:attribute>
46
		  <xsl:value-of select="name(.)"/>
47
		</th>
48
	      </xsl:for-each>
49
	    </tr>
50
	  </xsl:for-each>
51
	  <xsl:apply-templates/>
52
        </xsl:when>
53
        <xsl:otherwise>
54
          <tr><td>No Matches</td></tr> 
55
        </xsl:otherwise>
56
      </xsl:choose>
57
      </table>
58
      </center>
59
    </xsl:template>
60

  
61
    <xsl:template match="ROW">
62
        <tr>
63
          <xsl:attribute name="class">
64
            <xsl:choose>
65
              <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
66
              <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
67
            </xsl:choose>
68
          </xsl:attribute>
69
          <xsl:for-each select="*[not(starts-with(name(.),'H_'))]">
70
            <td>
71
	      <xsl:attribute name="class">
72
		<xsl:choose>
73
		  <xsl:when test="position() mod 2 = 1">colodd</xsl:when>
74
		  <xsl:when test="position() mod 2 = 0">coleven</xsl:when>
75
		</xsl:choose>
76
	      </xsl:attribute>
77
              <xsl:apply-templates select='.'/>
78
            </td>
79
          </xsl:for-each>
80
        </tr>
81
  </xsl:template>
82

  
83
</xsl:stylesheet>
0 84

  
xsqltest/rowcol.css
1
 .page    {font-family: Tahoma, sans-serif; background-color:white}
2
 .eml-dataset    {font-family: Tahoma, sans-serif; background-color:white}
3
 .rowodd  {background-color: #DDDDDD; color: black; vertical-align: top}
4
 .roweven {background-color: #F8F8F8; color: black; vertical-align: top}
5
 .coleven {}
6
 .colodd  {}
7
 .shaded  {background-color: #DDDDDD; color: black}
0 8

  
xsqltest/xmltest.sql
1
/**
2
 *        Name: xmltest.sql
3
 *     Purpose: create a table for storing test data in oracle
4
 * Institution: National Center for Ecological Analysis and Synthesis
5
 *   Copyright: 2000
6
 *     Authors: Matt Jones
7
 *
8
 *     Version: '$Id$'
9
 */
10

  
11
CREATE TABLE xmltest (
12
	docid		NUMBER(10) PRIMARY KEY,
13
	lastname	VARCHAR2(25),
14
	firstname	VARCHAR2(25)
15
);
0 16

  
lib/style/eml-dataset-display.xsl
1
<?xml version="1.0"?>
2
<!--
3
  * eml-dataset-display.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$'
12
  *
13
  * This is an XSLT (http://www.w3.org/TR/xslt) stylesheet designed to
14
  * convert an XML file that is valid with respect to the eml-dataset.dtd
15
  * module of the Ecological Metadata Language (EML) into an HTML format 
16
  * suitable for rendering with modern web browsers.
17
-->
18
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
19

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

  
22
  <xsl:template match="/">
23
    <html>
24
      <head>
25
	<link rel="stylesheet" type="text/css" href="./rowcol.css" />
26
      </head>
27
      <body class="eml-dataset">
28
	<center>
29
          <h1>Data set description</h1>
30
          <h3>Ecological Metadata Language</h3>
31
        </center>
32
        <xsl:apply-templates/>      
33

  
34
        <table width="100%">
35
        <tr><td class="rowodd">
36
        <b><xsl:text>Keywords:</xsl:text></b>
37
        </td></tr>
38
        <tr><td>
39
          <ul>
40
            <xsl:for-each select="//keyword_info/keyword">
41
              <li><xsl:value-of select="."/></li>
42
            </xsl:for-each>
43
          </ul>
44
        </td></tr>
45
        </table>
46
         
47

  
48
        <table width="100%">
49
        <tr><td class="rowodd">
50
        <b><xsl:text>Related Metadata and Data Files:</xsl:text></b>
51
        </td></tr>
52
        <tr><td>
53
        <ul>
54
          <xsl:for-each select="//relations">
55
            <li>
56
             <xsl:value-of select="@object"/>
57
             <xsl:text> </xsl:text>
58
             <xsl:value-of select="@relation"/>
59
             <xsl:text> </xsl:text>
60
             <xsl:value-of select="@target"/>
61
            </li>
62
          </xsl:for-each>
63
        </ul>
64
        </td></tr>
65
        </table>
66

  
67
      </body>
68
    </html>
69
  </xsl:template>
70

  
71
  <xsl:template match="meta_file_id">
72
    <table width="100%">
73
    <tr>
74
    <td class="rowodd"><b><xsl:text>Metadata File ID:</xsl:text></b></td>
75
    <td><xsl:value-of select="."/></td>
76
    </tr>
77
      <xsl:for-each select="//dataset_id|//title">
78
        <tr>
79
        <xsl:if test="name(.)='dataset_id'">
80
          <td class="rowodd"><b><xsl:text>Data set ID:</xsl:text></b></td>
81
        </xsl:if>
82
        <xsl:if test="name(.)='title'">
83
          <td class="rowodd"><b><xsl:text>Title:</xsl:text></b></td>
84
        </xsl:if>
85
        <td><xsl:value-of select="."/></td>
86
        </tr>
87
      </xsl:for-each>
88
    </table>
89

  
90
  </xsl:template>
91

  
92
  <xsl:template match="dataset_id"/>
93
  <xsl:template match="title"/>
94

  
95
  <xsl:template match="originator[1]">
96
      <table width="100%">
97
      <tr><td class="rowodd">
98
      <b><xsl:text>Data Set Owner(s):</xsl:text></b>
99
      </td></tr>
100
      </table>
101
  </xsl:template>
102

  
103
  <xsl:template match="party_org">
104
    <br><b><xsl:value-of select="."/></b></br>
105
  </xsl:template>
106

  
107
  <xsl:template match="party_individual">
108
    <br>
109
    <b>
110
       <xsl:value-of select="./salutation"/>
111
       <xsl:text> </xsl:text>
112
       <xsl:value-of select="./given_name"/>
113
       <xsl:text> </xsl:text>
114
       <xsl:value-of select="./surname"/>
115
    </b></br>
116
    <br><xsl:value-of select="./title"/></br>
117
  </xsl:template>
118

  
119
  <xsl:template match="meta_address">
120
    <table>
121
    <xsl:for-each select="./address">
122
      <tr>
123
      <td><xsl:value-of select="."/></td>
124
      </tr>
125
    </xsl:for-each>
126
    <tr>
127
    <td><xsl:value-of select="./city"/>
128
        <xsl:text>, </xsl:text>
129
        <xsl:value-of select="./admin_area"/>
130
        <xsl:text> </xsl:text>
131
        <xsl:value-of select="./postal_code"/>
132
    </td>
133
    </tr>
134
    <xsl:if test="./work_phone">
135
      <tr><td><xsl:text>Work: </xsl:text><xsl:value-of select="./work_phone"/>
136
       </td></tr>
137
    </xsl:if>
138
    <xsl:if test="./home_phone">
139
      <tr><td><xsl:text>Home: </xsl:text><xsl:value-of select="./home_phone"/>
140
       </td></tr>
141
    </xsl:if>
142
    <xsl:if test="./fax">
143
      <tr><td><xsl:text>Fax: </xsl:text><xsl:value-of select="./fax"/></td></tr>
144
    </xsl:if>
145
    <xsl:if test="./email">
146
      <tr><td><xsl:value-of select="./email"/></td></tr>
147
    </xsl:if>
148
    <xsl:if test="./resource_url">
149
      <tr><td><xsl:value-of select="./resource_url"/></td></tr>
150
    </xsl:if>
151
    </table>
152
  </xsl:template>
153

  
154
  <xsl:template match="abstract">
155
    <table width="100%">
156
    <tr>
157
    <td class="rowodd"><b><xsl:text>Abstract:</xsl:text></b></td>
158
    </tr>
159
    <tr>
160
    <td><xsl:value-of select="."/></td>
161
    </tr></table>
162
  </xsl:template>
163

  
164
  <xsl:template match="keyword_info"/>
165
  <xsl:template match="relations"/>
166

  
167
</xsl:stylesheet>
0 168

  

Also available in: Unified diff