xsl-list
[Top] [All Lists]

Re: [xsl] question about XSLT namespace

2018-06-15 01:54:14
This was discussed at great length when namespaces were introduced.
Although some vocabularies chose to change the namespace at version
changes it's a really bad idea. If you change the namespace then you
change the name of every construct in the language, that isn't a new
version it is a new, incompatible, language.

It is unfortunate that there is a date in the namespace but that was
forced by W3C policy at the time (which was later changed) but early
ones, eg mathml 1998, xslt and xhtml 1999, are stuck with the original
dates which means that this question comes up from time to time.

David




On 15 June 2018 at 07:32, Imsieke, Gerrit, le-tex
gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>
wrote:
There have been strong arguments against this, see for example
https://markmail.org/message/dmkpf3cvwpnzkdy2

Suppose I have defined a template rule in an XSLT 2 stylesheet (a XSLT
software library if you will), and I’ve been importing this stylesheet from
other stylesheets for some time.

Suppose there are different namespace URIs for XSLT 2 and 3, with prefixes
xsl2 and xsl3.

The importing stylesheet did something along the lines

<xsl2:template match="foo">
  <xsl2:choose>
    <xsl2:when test="@bar = 'baz'">
      …
    </xsl2:when>
    <xsl2:otherwise>
      <xsl2:next-match/>
    </xsl2:otherwise>
  </xsl2:choose>
</xsl2:template>

delegating to a template rule of the imported stylesheet for the otherwise
branch.

Then the need arises to do trigonometric computations in the imported
library. Therefore I switch it to XSLT 3.0 and change the namespace prefix
to xsl3 accordingly. Do I need to change all XSLT 2 stylesheets that import
it so that their rules are in the xsl3 namespace?

Either the XSLT processor must raise an error if an xsl3 stylesheet is
imported from an XSLT 2 stylesheet, or it needs to extend its template
matching rules that templates in any of the namespaces that pertain to the
prefixes xsl, xsl2, and xsl3 will be treated as being equivalent.

Then someone might ask on xsl list (or on xsl3 list?) whether it wouldn’t
simplify things if the different versions of the language were denoted by a
version attribute but otherwise the namespace was the same.

There is great value in being able to seamlessly combine code that is
written in different versions of the language, provided that the processor
supports all of them.

If that’s an issue, if your XSLT 2 stylesheet should still run (without the
new feature that depends on trigonometry) on processors that don’t support
XSLT 3, you can maintain a fallback version of the library and do something
like this:

<xsl:import href="mylib_xslt3.xsl"
use-when="xs:decimal(system-property('xsl:version')) ge 3.0"/>
<xsl:import href="mylib.xsl"
use-when="xs:decimal(system-property('xsl:version')) lt 3.0"/>

Both libraries will probably import a third stylesheet into which you put
the common functionality.

How would you do this importing in the alternative universe with different
namespaces and no 'xsl:version' system property?

<xsl2:import href="mylib.xsl"/>
<xsl3:import href="mylib_xslt3.xsl"/>

An XSLT 2 processor might be required to ignore any xsl3:import, but an XSLT
3 processor will import both and overwrite all the rules, functions,
variables, keys, etc. of mylib.xsl with those found in mylib_xslt3.xsl, by
means of their higher import precedence. This is inefficient. You will get a
warning that the common library stylesheet is imported more than once.

This is just one aspect. I’m sure you’ll find other replies in the archives,
and, as Geert just pointed out and I’m proving right now, you’ll get more
replies like this.

Gerrit

On 15.06.2018 07:30, Mukul Gandhi gandhi(_dot_)mukul(_at_)gmail(_dot_)com 
wrote:

Hi all,
     We all know that, the XSLT namespace is
http://www.w3.org/1999/XSL/Transform. This has remained same, for 1.0, 2.0 &
3.0 versions of the XSLT language. My feeling is, that every major XSLT
language version should have a different language namespace URI (maybe, we
could make the year different for different XSLT language versions). Keeping
the language namespace same, gives me a feeling that XSLT 3.0 specific
language elements can be used in XSLT 1.0 & 2.0 stylesheets.

I know that, specifying xsl:stylesheet version="1.0" or version="2.0" or
version="3.0" might disambiguate the XSLT language namespace concern. But it
would be great, to know the arguments in favor of keeping the XSLT namespace
same across different versions of the language.




--
Regards,
Mukul Gandhi
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <-list/225679> (by email <>)


--
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer / Managing Directors:
Gerrit Imsieke, Svea Jelonek, Thomas Schmidt

--~----------------------------------------------------------------
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
--~--

<Prev in Thread] Current Thread [Next in Thread>