Re: [xslt] Problem with creating namespace in the stylesheet



Easily I need to obtain:
<xslo:stylesheet xmlns:netopeer="http://www.liberouter.org";>
...
</xslo:stylesheet>

I can create it by (I have defined XML namespace alias as a "xslo"):
<xsl:template match="/">
	<xslo:stylesheet xmlns:netopeer="http://www.liberouter.org";>
		<!-- Process the content... -->
	</xslo:stylesheet>
</xsl:template>

This works fine, but I think that it is not good way, because
XML elements are created as a text. So I can create is as a XML
element by:
<xsl:template match="/">
	<xsl:element name="xslo:stylesheet">
		<xsl:attribute name="xmlns:netopeer">
			<xsl:text>http://www.liberouter.org</xsl:text>
		</xsl:attribute>
		<!-- Process the content... -->
	</xsl:element>
</xsl:template>

This creates <xslo:stylesheet> element ok, but it ignores the
xmlns:netopeer attribute (the attributes with the different names
are ok, only attributes with "xmlns:" prefix are ignored).


Is it possible to create as a output the XSLT stylesheet with some
namespace? (Not if namespace is defined in the processed XSLO stylesheet)

Petr Novak

On Wed, Sep 22, 2004 at 04:55:02AM -0400, Daniel Veillard wrote:
> On Wed, Sep 22, 2004 at 08:55:58AM +0200, Petr Novak wrote:
> > Hallo,
> > I am using xsltproc and I need to obtain as a result the XSLT stylesheet. But
> > I have got troubles with creating the namespace. I need the namespace with
> > prefix 'netopeer', for example: <xslo:stylesheet xmlns:netopeer="http://www.liberouter.org/ns/netopeer/1.1.7";>
> > 
> > If I write:
> > <xsl:element name="xslo:stylesheet">
> > 	<xsl:attribute name="xmlns:netopeer">
> > 		<xsl:text>http://www.liberouter.org/ns/netopeer/1.1.7</xsl:text>
> > 	</xsl:attribute>
> > 	...
> > </xsl:element>
> > ,the xsltproc creates the stylesheet element only with namesapaces whih are in
> > the processing XSLT stylesheet and my <xsl:attribute> is ignored. I cannot set
> > the "netopeer" namespace in the processing XSLT stylesheet, because it is
> > created on-the-fly (from the processed XML document).
> > 
> > If I create the output stylesheet as a text:
> > <xslo:stylesheet xmlns:netopeer="http://www.liberouter.org/ns/netopeer/1.1.7";>
> > ...
> > </xslo:stylesheet>
> > . it works, but I don't thing that it is the good solution.
> > 
> > 
> > Can you advise me, how to do it?
> 
>   I'm afraid I don't understand, stylesheets fragments just don't work
> to pass the problem you're trying to explain. 
>   Did you check http://www.w3.org/TR/xslt#element-namespace-alias ?
> 
> Daniel
> 
> -- 
> Daniel Veillard      | Red Hat Desktop team http://redhat.com/
> veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
> http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
> _______________________________________________
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> xslt gnome org
> http://mail.gnome.org/mailman/listinfo/xslt

-- 

Petr Novak, Liberouter Project (www.liberouter.org)
E-mail: novak merlot ics muni cz



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]