Namespace Support

Tamino supports XML Namespaces as defined in the W3C Recommendation Namespaces in XML (http://www.w3.org/TR/REC-xml-names/). Tamino schemas may define a target namespace, may import sub-schemas from other namespaces, and may contain wildcards with content from foreign namespaces. In section Introduction to XML Schema::Namespaces and wildcards we discuss how namespaces are used with XML Schema; the support in Tamino does not differ from this.


Qualified Queries

The question, however, is: How do we qualify element and attribute names within queries? How do we set up namespace bindings in a query (or in an update or insert operation)? The answer depends on the query language used:

  • X-Query (XQL) does not allow bindings to be defined between namespace prefixes and namespace identifiers. If we need to qualify names within a query, we must use the bindings that were set up in the schema of the document type. We just prefix names with the same prefixes that were defined in the schema.

    Specific aspects of namespace handling with X-Query are discussed in the section _XQL, _DELETE of the Tamino document Namespace Handling for Specific X-Machine Requests, for example how Tamino treats X-Query queries on schemas that have a default namespace but no prefix for it.

    Given the schema in section From Model to Schema::Multi-Namespace Schema Composition, a query for jazz musicians who play the saxophone would look like this:

    e:jazzMusician[e:plays/i:saxophone]
  • Tamino XQuery 4 allows (and requires) namespace bindings to be defined within the queries, and thus allows prefixes to be used that differ from those defined in the schema. We define these bindings in the query prologue using the expressions default element namespace={namespace-identifier} or declare namespace {namespace-prefix}={namespace-identifier}. In XQuery 4, the above query for jazz musicians who play the saxophone would look like this:

    declare namespace ency="http://www.softwareag.com/tamino/doc/examples/models/jazz/encyclopedia"
    declare namespace instrument="http://www.softwareag.com/tamino/doc/examples/models/instruments"
    
    let $j := input()/ency:jazzMusician
       where ($j/ency:plays/instrument:saxophone)
         return $j