RE: [xsl] Namespace-alias using #default with no default namespace in scope

Subject: RE: [xsl] Namespace-alias using #default with no default namespace in scope
From: "Buchcik, Kasimier" <k.buchcik@xxxxxxxxxxxx>
Date: Fri, 12 May 2006 21:24:07 +0200

> -----Original Message-----
> From: David Carlisle [mailto:davidc@xxxxxxxxx]


> > Couldn't there be a rule, or at least a suggestion in XSLT 2.0 to
> > either the literal namespace prefix or the target namespace prefix?
> xslt2 is a more explict here. the rules imply (and the following note
> makes explict) that the stylesheet-prefix is not used in the result.
> These rules achieve the effect that the element generated from the
> literal result element will have an in-scope namespace
> node that binds the result-prefix to the target namespace URI,
> provided that the namespace declaration associating this prefix with
> URI is in scope for both the xsl:namespace-alias instruction and for
> literal result element. Conversely, the stylesheet-prefix and the
> namespace URI will not normally appear in the result tree.

I'm currently implementing the case, where the relevant ns-declaration
is not in scope for the literal result element.

Scenario (Note that there's a xmlns:help-to="urn:test:to"
ns-declaration on element "foo", which could be used to avoid
of generation of a new prefix):

<xsl:stylesheet version="1.0"
  <xsl:output indent="yes"/>

  <xsl:namespace-alias stylesheet-prefix="from" result-prefix="to"/>

  <xsl:template match="/">
    <!-- Could the ns-decl. xmlns:help-to="urn:test:to" be used
      for the literal result element "bar" ?
    <from:foo xmlns:help-to="urn:test:to">
      <from:bar xmlns:to="urn:test:occupied"/>


Result of Saxon 8.1.1:

<?xml version='1.0' ?>
<to:foo xmlns:to="urn:test:to" xmlns:help-to="urn:test:to">
  <to_0:bar xmlns:to="urn:test:zoo" xmlns:to_0="urn:test:to"/>

Result of MSXML .NET:

<?xml version='1.0' encoding='utf-8' ?>
<to:foo xmlns:to="urn:test:to" xmlns:help-to="urn:test:to">
  <xp_0:bar xmlns:xp_0="urn:test:to" xmlns:to="urn:test:zoo"/>

I wonder if it would be still in sync with the spec, if the
mechanism would use the ns-decl xmlns:help-to="urn:test:to" for
the resulting element "bar". The prefix does change anyway, so,
for me, it seems reasonable to avoid the generated
prefix and reuse what's already in the result tree.

The result I have in mind:

<to:foo xmlns:to="urn:test:to" xmlns:help-to="urn:test:to">
  <help-to:bar xmlns:to="urn:test:zoo"/>



Current Thread