The rules for SequenceType matching compare the actual type of a value with an expected type. These rules are a subset of the formal rules that match a value with an expected type defined in XQuery 1.0 and XPath 2.0 Formal Semantics http://www.w3.org/TR/xpath20/#XQueryFormalSemantics, because the Formal Semantics must be able to match a value with any XML Schema type, whereas the rules below only match values against those types expressible by the SequenceType syntax.
Some of the rules for SequenceType matching require determining whether a given type name is the same as or derived from an expected type name. The given type name may be "known" (defined in the in-scope schema definitions), or "unknown" (not defined in the in-scope schema definitions). An unknown type name might be encountered, for example, if a source document has been validated using a schema that was not imported into the static context. In this case, an implementation is allowed (but is not required) to provide an implementation-dependent mechanism for determining whether the unknown type name is derived from the expected type name. For example, an implementation might maintain a data dictionary containing information about type hierarchies. consider the following XML document: <source lang="xml"><sorbo>
<is>elite</is>
<!-- life sux -->
</sorbo> then, the following are some example of SequenceType matchings:
element({*})
result:
element: sorbo
element(elite)
result:
Empty results
sorbo/comment()
result:
comment: life sux
data(/sorbo/comment())
result:
xs:string: life sux
sorbo/node()
'result: '
text:
element: is
comment: life sux
text: