In both XSLT and XQuery, static type checking of an
expression that constructs elements and attributes with
a declared schema type will reject constructs that
create attributes such as xsi:type and
xsi:schemaLocation, complaining that these attributes
are not permitted by the schema. (In fact such
attributes are always allowed and do not need to be
declared in the schema).
Circumvention: create these attributes using dynamic
constructors that create the attribute name at run-time
(dynamic attribute constructors in XQuery, xsl:attribute
in XSLT) to prevent the static checking.