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="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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Re: Can one _generate_ na, Michael Kay | Thread | Re: [xsl] Re: Can one _generate_ na, Joseph Kesselman |
Re: [xsl] A very basic question., Simon Kelly | Date | RE: [xsl] substring-before<tab/>..., bryan |
Month |