RE: [xsl] How do you remove namespace?

Subject: RE: [xsl] How do you remove namespace?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 14 Aug 2006 17:37:47 +0100
You can't get rid of the namespace declaration, because without it the
<asp:xyz> and <asp:Label> elements would not be namespace-well-formed. 

Perhaps you don't really want these elements to be in the namespace
System.Web.UI.WebControls? But in that case, why would you be putting them
in that namespace?

Or perhaps you're trying to generate output that is neither well-formed XML
nor well-formed HTML? (I guess that might apply to ASP.NET pages?) That's a
tricky one: in principle you can do it by writing your own serializer, but
that might be more work than you want to attempt. The alternative is to
generate XML and then post-process it using a non-XML-aware tool such as
Perl. For example, you could generate output elements named asp.Label
instead of asp:Label.

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Arthur Maloney [mailto:ArthurM@xxxxxxxxxx] 
> Sent: 14 August 2006 16:56
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] How do you remove namespace?
> 
> Hello xsl-list,
> 
>   I'm using Xslt 2.0 to author some ASP.Net code building
> 
>   in a library xsl file I have:
> 
> <xsl:template name="masthead">
> <div id="masthead">
>      <xsl:element name="asp:xyz">
>                   <xsl:attribute name="Id" select="'lblPageTitle'"/>
>                   <xsl:attribute name="runat" select="'server'"/>
>      </xsl:element>
>      <asp:Label Id="lblPageTitle" runat="server" />
>      <asp:Label Id="lblPageCaption" runat="server" />
>      <asp:Label Id="lblMessage" runat="server" />
> </div><!-- end of masthead -->
> 
> when called  it gives
>       <div id="masthead">
>         <asp:xyz runat="server" 
> xmlns:asp="System.Web.UI.WebControls" Id="lblPageTitle"></asp:xyz>
>         <asp:Label runat="server" 
> xmlns:asp="System.Web.UI.WebControls" Id="lblPageTitle"></asp:Label>
>       ...
>       </div>
> 
> 
> I want to get rid of xmlns:asp="System.Web.UI.WebControls"
> In the stylesheet element I have:
> 
> I have xmlns:asp="System.Web.UI.WebControls
> 
> without this I get error SXXP0003 The prefix asp FOR ELEMENT 
> asp:Label is not bound
> 
> 
> --
> Best regards,
>  Arthur                          mailto:ArthurM@xxxxxxxxxx

Current Thread