Tamino XML Server Version 9.7
 —  Advanced Concepts  —

Rapid Prototyping with XQuery 4

XQuery 4 is another alternative when building prototype web applications. In contrast to the XPath-like X-Query, XQuery allows complex output documents to be constructed within the query expression. Basically, XQuery combines the facilities of XPath and XSLT, but uses different syntax. Briefly, XQuery's advantages and disadvantages are as follows:

Advantages

Disadvantages

In the following example we show how we can produce a web page with XQuery 4. The example is a simplified version of the first example shown in the section Procedural Transformation.

default element namespace="http://www.softwareag.com/tamino/doc/examples/models/jazz/encyclopedia"

<html><head/><body>
    {for $a in input()/album
	return
    <table><tr><td>
      <table width="100%">
        <tr bgcolor="silver">
          <td>
            <h2>{string($a/title)}</h2><br/>
              { for $p in $a/publisher
                return
		 string-join(("Publisher:",string($p))," ")
	      }
            AlbumNo: {string($a/@albumNo)}
          </td>
          { for $c in $a/coverImage
            return
            <td>
              <img src="{string($a/coverImage)}" alt="{string($a/title)}"/>
            </td>
          }
       </tr>
      </table>
    </td></tr>
    <tr><td>
      <br/><h4>Tracks</h4>
      <table width="100%" >
	{ for $track in $a/track
          return
          <tr bgcolor="silver">
            <td>
              { string($track/title) }
            </td>
            <td align="Right">
              { $track/duration }
            </td>
          </tr>
        }
      </table>
    </td></tr>
  </table>
  }
</body></html>

  

Top of page