xsl-list
[Top] [All Lists]

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

2006-05-12 12:24:29
Hi, 

-----Original Message-----
From: David Carlisle [mailto:davidc(_at_)nag(_dot_)co(_dot_)uk] 

[...]

Couldn't there be a rule, or at least a suggestion in XSLT 2.0 to
use
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
this 
URI is in scope for both the xsl:namespace-alias instruction and for
the 
literal result element. Conversely, the stylesheet-prefix and the
literal 
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"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";  
  xmlns:from="urn:test:from"
  xmlns:to="urn:test:to">
  <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"/>
    </from:foo>
  </xsl:template>

</xsl:stylesheet>

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"/>
</to:foo>

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"/>
</to:foo>

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"/>
</to:foo>

Regards,

Kasimier

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--