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

Re: Re: Can one _generate_ namespace nodes?

Subject: Re: Re: Can one _generate_ namespace nodes?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Mon, 24 Feb 2003 07:54:29 -0800 (PST)
insert text namespace declaration xslt
--- 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="http://www.w3.org/1999/XSL/Transform">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"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:newxsl="http://dymmy/Transform"
 exclude-result-prefixes="xsl">  
  
  <xsl:output omit-xml-declaration="yes" indent="yes"/>  
  
  <xsl:namespace-alias stylesheet-prefix="newxsl" 
                       result-prefix="xsl"/>  
  
  <xsl:template match="/">    
    
    <newxsl:stylesheet version="1.0">       
      <newxsl:text>foo</newxsl:text>     
    </newxsl:stylesheet>  
  
  </xsl:template>
</xsl:stylesheet>

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="http://www.w3.org/1999/XSL/Transform" 
 version="1.0">
   <newxsl:text>foo</newxsl:text>
</newxsl:stylesheet>


Isn't this a solution to the problem?






=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.