Tammam --
See section 7.1.3 of the XSLT Recommendation:
"XSLT processors may make use of the prefix of the QName specified in
the name attribute when selecting the prefix used for outputting the
created attribute as XML; however, they are not required to do so and,
if the prefix is xmlns, they must not do so. Thus, although it is not
an error to do:
<xsl:attribute name="xmlns:xsl"
namespace="whatever">http://www.w3.org/1999/XSL/Transform</xsl:attribute>
it will not result in a namespace declartion being output. So, you
should be able to delete the xsl:attribute element and its xsl:value-of
child and get the same results.
Xalan is automatically outputting the xmlns:xslt namespace definition
because something inside your first gen:stylesheet element needs it
while there is nothing in the second gen:stylesheet requiring the
namespace definition.
If this is not the case, we may have a bug in XalanJ. Can you supply
your entire generated XML and we can look at it starting from there.
Thanks,
Gary
[EMAIL PROTECTED] wrote:
>
> I am having trouble outputing namespace declarations in elements as
> follows:
>
> <xsl:for-each select="//tgh:item">
> <xsl:element name="gen:stylesheet">
> <xsl:attribute name="xmlns:lxslt">
> <xsl:value-of select=" 'http://xml.apache.org/xslt' "/>
> </xsl:attribute>
> :
> :
> </xsl:element>
> </xsl:for-each>
>
> I get the namespaces in the gen:stylesheet tag on the first iteration, but
> not any subsequeny one.
> In short, here's what I get:
>
> <gen:stylesheet xmlns:lxslt="http://xml.apache.org/xslt">
> :
> </gen:stylesheet>
> <gen:stylesheet>
> :
> </gen:stylesheet>
>
> But here's what I expect (notice the namespace):
>
> <gen:stylesheet xmlns:lxslt="http://xml.apache.org/xslt">
> :
> </gen:stylesheet>
> <gen:stylesheet xmlns:lxslt="http://xml.apache.org/xslt">
> :
> </gen:stylesheet>
>
> Any ideas, what am I doing wrong.
>
> Cheers,
>
> Tammam