My question is why in the second case described in this section (when
the namespace-context attribute is absent), the binding for the
default-namespace is derived in a different way, than in the first
case?
To make it consistent with "static" XPath expressions embedded in the
stylesheet.
For example
<xsl:evaluate xpath="'doc/section/para[' || $predicate || ']'"/>
handles the default namespace in the same way as
<xsl:sequence select="doc/section/para"/>
What will happen if the namespace-context attribute is *present* and
it selects the <xsl:evaluate> instruction? Will then the rule for
deriving the default-namespace binding of the first sub-bullet be
used, or will the rule of the 2nd sub-bullet be used? As per the
current text it seems that the rule in the first sub-bullet must be
used. But this is exactly the same node as in the 2nd sub-bullet and
despite this identity, different rules for the default namespace
binding must be used. Was this really intended?
Actually, a stylesheet cannot select its own instructions. It can only select a
copy, by having a stylesheet that reads itself as a source document. When
stylesheets are read as source documents, they are never treated specially,
they always follow the same rules as other source documents - for example they
follow the rules for whitespace stripping in source documents, not the rules
for whitespace stripping in stylesheets. The direct answer to your question is
that stylesheets reading their own source code is not something we considered
as an important use case.
The typical use case for taking the namespace context from a node is where the
XPath expression itself is embedded in a source document (in a
spreadsheet-formula-like way), for example
<interest-rates>
<base-rate>0.02</base-rate>
<savings-rate>../base-rate + 0.03</savings-rate>
</interest-rates>
This might be executed by
<xsl:variable name="savings-rate">
<xsl:variable name="source" select="doc('interest-rates')//savings-rate">
<xsl:evaluate xpath="." namespace-context="."/>
</xsl:variable>
It seems appropriate here to take the default namespace for elements and types
from the XML default namespace.
Michael Kay
Saxonica
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--