summaryrefslogtreecommitdiff
path: root/tests/XSLTMark/dbsql50.xsl
blob: d6fa967b1586716dd736d33420c8e9861e8e646f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="table">
  <document>
    <!-- select * from table where id = ... -->
    <xsl:apply-templates select="row[id=3]"/>
    <xsl:apply-templates select="row[id=13]"/>
    <xsl:apply-templates select="row[id=23]"/>
    <xsl:apply-templates select="row[id=33]"/>
    <xsl:apply-templates select="row[id=43]"/>
    <!-- select * from table where id > ... and id < ... -->
    <xsl:apply-templates select="row[id&gt;4 and id&lt;8]"/>
    <xsl:apply-templates select="row[id&gt;14 and id&lt;18]"/>
    <xsl:apply-templates select="row[id&gt;24 and id&lt;28]"/>
    <xsl:apply-templates select="row[id&gt;34 and id&lt;38]"/>
    <xsl:apply-templates select="row[id&gt;44 and id&lt;48]"/>
    <!-- select * from table where firstname = 'Bob' -->
    <xsl:apply-templates select="row[firstname='Bob']"/>
    <!-- select firstname, lastname from table where id=... -->
    <xsl:for-each select="row[id mod 10 = 9]">
       <xsl:apply-templates select="firstname"/>
       <xsl:apply-templates select="lastname"/>
    </xsl:for-each>
  </document>
</xsl:template>

<xsl:template match="row">
  <xsl:apply-templates select="id"/>
  <xsl:apply-templates select="firstname"/>
  <xsl:apply-templates select="lastname"/>
  <xsl:apply-templates select="street"/>
  <xsl:apply-templates select="city"/>
  <xsl:apply-templates select="state"/>
  <xsl:apply-templates select="zip"/>
  <xsl:text>&#x0A;</xsl:text>
</xsl:template>

<xsl:template match="id|firstname|lastname|street|city|state|zip">
  <xsl:value-of select="name(.)"/>
  <xsl:text>=</xsl:text>
  <xsl:value-of select="."/>
  <xsl:text>&#x0A;</xsl:text>
</xsl:template>

</xsl:stylesheet>