Direct constructors

In XQuery, there are two ways to generate XML content: direct constructors and computed constructors. Direct constructors look like normal XML but allow XQuery expressions to be embedded and executed inside the constructor.

For example, the following XQuery expression computes elements, comments, and attributes including a computed attribute value and a computed element value.

<zing>
<!– normal xml comment –>
<whizz bling=”true” value=”{ concat(”a”, “b”) }”>
<goat>{ 1 + 2 }</goat>
</whizz>
</zing>

This will produce the following XML output:

<zing>
<!– normal xml comment –>
<whizz bling=”true” value=”ab”>
<goat>3</goat>
</whizz>
</zing>

Dynamic values can only be computed for attribute and element content in direct constructors. Computed constructors allow you to also dynamically compute or build the actual names of the tags and all other parts of the various node types.


Alex Miller


Categories

Search

Tweets


follow puredanger at http://twitter.com

Hey I wrote some of this


Some early reviews:

  • "Great book, needs more killing and grilling." - Ted Nugent
  • "I was wrong - this is the road ahead." - Bill Gates
  • "I've replaced my roundhouse kick with this book." - Chuck Norris
  • "This book killed me." - George Carlin
  • "Totally replaced my left nut." - Lance Armstrong
  • "I don't get it." - Lindsay Lohan
  • "Is that a poop stain on the cover?" - Quentin Tarantino
  • "Paul insisted I read this." - David Letterman