[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT 3.0: Questions about the Statically-known na

Subject: Re: XSLT 3.0: Questions about the Statically-known namespaces and default element/ type namespace for the evaluation context of the target expression of <xsl:evaluate>
From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 13 Feb 2015 15:06:04 -0000
 Re: XSLT 3.0: Questions about the Statically-known  na
Thank you Dr. Kay for the explanation.

This provided answers to most questions I have, however there is still
this question:

> What default namespace binding will be used in the second case (when
> the namespace-context attribute is absent), if there is no
> [xsl:]xpath-default-namespace attribute specified anywhere in the
> stylesheet? The specification doesn't define this at all.

So, there is no [xsl:]xpath-default-namespace attribute anywhere in
the stylesheet.

There are two sub-cases here:

  1. The <xsl:evaluate> element has no default-namespace binding.

  2. The <xsl:evaluate> element has  a default-namespace binding

I believe that in case 2, the default-namespace binding of the
<xsl:evaluate> instruction should become the the default-namespace
binding in the evaluation context (the alternative is to ignore this
and nave no default-namespace binding for the evaluation case -- as
obviously should be done in case 1.)

Is this conclusion right, or not? This isn't postulated specifically
in the specification.

Cheers,
Dimitre Novatchev



On Fri, Feb 13, 2015 at 3:44 AM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>>
>> 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.