Re: [xsl] Schema question

Subject: Re: [xsl] Schema question
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 Jan 2018 11:09:47 -0000
If you had described it as an XPath question then it would be on-topic, and
therefore I hope Tommie won't yell at me if I answer it!

>
>       <xs:assert test="every $cont in cont:contestant[position() lt last()]
satisfies
>                       $cont/@seed lt
$cont/following-sibling::cont:contestant[1]/@seed"/>
>
>
> I wrote the assert without the namespace prefix cont: which did not work.
Any explication way I need to prefix here even though the default namespace is
the same namespace and I can reference to an element without prefixing.
>

XSD 1.1 Part 1 B'3.13.6.2 says:

	2.2.3 The default element/type namespace
<http://www.w3.org/TR/xpath20/#dt-def-elemtype-ns> is the {default namespace}
<https://www.w3.org/TR/xmlschema11-1/#x-default_namespace> of X.

B'3.13.2 defines how {default namespace} is established:

Let D be the B7actual valueB7 <https://www.w3.org/TR/xmlschema11-1/#key-vv> of
the xpathDefaultNamespace [attribute]
<http://www.w3.org/TR/xml-infoset/#infoitem.element>, if present on the host
element, otherwise that of the xpathDefaultNamespace [attribute]
<http://www.w3.org/TR/xml-infoset/#infoitem.element> of the <schema>
<https://www.w3.org/TR/xmlschema11-1/#element-schema> ancestor. Then the value
is the appropriate case among the following:
1 If D is ##defaultNamespace, then the appropriate case among the following:
1.1 If there is an entry in the [in-scope namespaces]
<http://www.w3.org/TR/xml-infoset/#infoitem.element> of the host element whose
[prefix] <http://www.w3.org/TR/xml-infoset/#infoitem.namespace> is B7absentB7
<https://www.w3.org/TR/xmlschema11-1/#key-null>, then the corresponding
[namespace name] <http://www.w3.org/TR/xml-infoset/#infoitem.namespace>;
1.2 otherwise B7absentB7 <https://www.w3.org/TR/xmlschema11-1/#key-null>;
2 If D is ##targetNamespace, then the appropriate case among the following:
2.1 If the targetNamespace [attribute]
<http://www.w3.org/TR/xml-infoset/#infoitem.element> is present on the
<schema> <https://www.w3.org/TR/xmlschema11-1/#element-schema> ancestor, then
its B7actual valueB7 <https://www.w3.org/TR/xmlschema11-1/#key-vv>;
2.2 otherwise B7absentB7 <https://www.w3.org/TR/xmlschema11-1/#key-null>;
3 If D is ##local, then B7absentB7
<https://www.w3.org/TR/xmlschema11-1/#key-null>;
4 otherwise (D is an xs:anyURI value) D.

Now, you don't have an xpathDefaultNamespace attribute on either the xs:assert
element or the xs:schema element, so I think we have to conclude that {default
namespace} is "absent", so the default element/type namespace in the XPath
static context is absent.

XPath 2.0 B'2.1.1 says (under Default element/type namespace) "The namespace
URI, if present, is used for any unprefixed QName appearing in a position
where an element or type name is expected.]"

By implication (and I agree it's not very explicit) if you don't define an
xPathDefaultNamespace then an unprefixed QName is taken as being in no
namespace.

There's certainly nothing (other than intuition, which in this case is
incorrect) to suggest that an unprefixed QName should be in the default
namespace that's in-scope for the xs:assert element.

Michael Kay
Saxonica

Current Thread