to the main page about the tutorial  THE XML REVOLUTION  -  TECHNOLOGIES FOR THE FUTURE WEB back up next

Element constructors

An XQuery expression may construct a new XML element:
<employee empid="12345">
  <name>John Doe</name>
  <job>XML specialist</job>
  <deptno>187</deptno>
  <salary>125000</salary>
</employee>

which just evaluates to itself.

In the XQuery syntax this is unambiguous - XQueryX must use namespaces!

More interestingly, an expression may use values bound to variables:
<employee empid="{$id}">
  <name>{$name}</name>
  {$job}
  <deptno>{$deptno}</deptno>
  <salary>{$SGMLspecialist+100000}</salary>
</employee>

Here the variables $id, $name, and $job must be bound to appropriate XML fragments or strings.

In general, {...} may contain full XQuery expressions returning sequences.

back COPYRIGHT © 2000-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH next