Re: [xsl] Re: Can one _generate_ namespace nodes?

Subject: Re: [xsl] Re: Can one _generate_ namespace nodes?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Mon, 24 Feb 2003 07:54:29 -0800 (PST)
--- Joseph Kesselman <keshlam@xxxxxxxxxx> wrote:
> >Can you provide a *small* example, please?
> Smallest would be a conceptual sketch rather than an example.
> Let's say we want to insert <xsl:text>foo</xsl:text> into the middle
> of 
> our output document. One approach is to code it using  a "dummy" 
> namespace, and translate that on output to the correct namespace::
>         <xsl:namespace-alias stylesheet-prefix="newxsl" 
> result-prefix="xsl"/>
>         ...
>         <newxsl:text>foo</newxsl:text>
> and have XSLT automatically translate the dummy namespace into the
> "real" 
> xsl namespace. I've tended to prefer this approach for clarity
> reasons.
> The downside of the aliasing solution is that it may produce more
> verbose 
> output. Some XSLT processors -- Xalan in particular -- keep the
> original 
> prefix and just change the namespace binding. This is actually nice
> in 
> some ways, since it means you can see which names were generated by
> the
> aliasing mechanism. But when you combine that with a serializer which
> generates namespace declarations at the point where it discovers they
> were 
> used without having been explicitly declared, that means the output 
> becomes
>         <newxsl:text 
> xmlns:newxsl="";>foo</newxsl:text>
> .... and that namespace declaration occurs on every one of these
> generated 
> <newxsl:text/> elements.

In case if we have:

<xsl:stylesheet version="1.0"
  <xsl:output omit-xml-declaration="yes" indent="yes"/>  
  <xsl:namespace-alias stylesheet-prefix="newxsl" 
  <xsl:template match="/">    
    <newxsl:stylesheet version="1.0">       

and the XSLT processor (e.g. Xalan) keeps the new prefix and only
changes its namespace-uri, then the serialiser will have to generate
the correct namespace declaration for newxsl:stylesheet. Thus the
required namespace declaration will be at the highest place possible in
the hierarchy.

The result from the above transformation must be:

<newxsl:stylesheet xmlns:newxsl=""; 

Isn't this a solution to the problem?


Dimitre Novatchev. -- the home of FXSL

Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more

 XSL-List info and archive:

Current Thread