Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Error: Cannot construct namespace declaration ...

From: SlavaSedov@-----------.---------.---
To: NULL
Date: 8/3/2005 2:38:00 AM
maybe it can help

Server Error in '/publ2005' Application.
Cannot construct namespace declaration 
xmlns:='http://www.w3.org/1999/xhtml'. Prefix '' is already mapped to 
namespace ''.
Description: An unhandled exception occurred during the execution of the 
current web request. Please review the stack trace for more information about 
the error and where it originated in the code.

Exception Details: System.Xml.Xsl.XslTransformException: Cannot construct 
namespace declaration xmlns:='http://www.w3.org/1999/xhtml'. Prefix '' is 
already mapped to namespace ''.

Source Error:

Line 260:        };
Line 261:
Line 262:        xsltransform.Transform(xml, xsltargs, writer);
Line 263:    }
Line 264:    public static void WriteXML(XmlDocument xml)


Source File: c:\Inetpub\wwwroot\publ2005\mypage.cs    Line: 262

Stack Trace:

[XslTransformException: Cannot construct namespace declaration 
xmlns:='http://www.w3.org/1999/xhtml'. Prefix '' is already mapped to 
namespace ''.]
   System.Xml.Xsl.Runtime.XmlQueryOutput.WriteNamespaceDeclaration(String 
prefix, String ns) +238
   System.Xml.Xsl.CompiledQuery.Query.<xsl:template 
match="bookinfo">(XmlQueryRuntime 
{urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator 
{urn:schemas-microsoft-com:xslt-debug}current, Double 
{urn:schemas-microsoft-com:xslt-debug}position, Double 
{urn:schemas-microsoft-com:xslt-debug}last) +1080
   System.Xml.Xsl.CompiledQuery.Query.<xsl:apply-templates> 
(2)(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, 
XPathNavigator , Double , Double ) +161
   System.Xml.Xsl.CompiledQuery.Query.<xsl:apply-templates> 
(2)(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, 
XPathNavigator , Double , Double ) +494
   System.Xml.Xsl.CompiledQuery.Query.<xsl:apply-templates> 
(2)(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, 
XPathNavigator , Double , Double ) +494
   System.Xml.Xsl.CompiledQuery.Query.Root(XmlQueryRuntime 
{urn:schemas-microsoft-com:xslt-debug}runtime) +93
   System.Xml.Xsl.CompiledQuery.Query.Execute(XmlQueryRuntime 
{urn:schemas-microsoft-com:xslt-debug}runtime) +24
   System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver 
dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) +108
   System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver 
dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean 
closeWriter) +180
   System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, 
XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results) +44
   System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, 
XsltArgumentList arguments, XmlWriter results) +157
   mypage.mytransform(String url, String xslPath, XsltArgumentList xsltargs, 
XmlWriter writer) in c:\Inetpub\wwwroot\publ2005\mypage.cs:262
   mypage.fillincludes(XmlDocument xmldoc, Boolean isCrawler) in 
c:\Inetpub\wwwroot\publ2005\mypage.cs:199
   ASP.Default_aspx.__Render__control1(HtmlTextWriter __w, Control 
parameterContainer) in c:\Inetpub\wwwroot\publ2005\Default.aspx:23
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, 
ICollection children) +2044507
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Page.Render(HtmlTextWriter writer) +26
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, 
ControlAdapter adapter) +25
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter 
adapter) +119
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
   System.Web.UI.Page.ProcessRequestMain(Boolean 
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7780


Version Information: Microsoft .NET Framework Version:2.0.50215.312; ASP.NET 
Version:2.0.50215.312

also if in xslt omited "xmlns="http://www.w3.org/1999/xhtml" then all 
<xhtml:*> in output look like <xhtml:h1 xmlns="">, i guess that error related 
with this code

        XmlNamespaceManager nsm = new XmlNamespaceManager(xmldoc.NameTable);
        nsm.AddNamespace("publ", publns);
        nsm.AddNamespace("xhtml", xhtmlns);

//where xmldoc (XMLDocument) is source for this xslt and in this xml no 
default namespace declaration (i don`t think that is an error - valid xml + 
valid xslt must not produce error in result)

by the way - if i use as source non-editable XPathDocument, and in xslt 
present element <xsl:strip-space elements="*"/> then also error as result 
(not good too) because .Net code and XSLT code may be written by different 
peoples and it can be often "hard-to-be-resolved" error in application (here 
no error nor in C# nor in XSLT code) in this case will be better to lost some 
performance, then functionality

thanks for support,
Slav


"Martin Honnen" wrote:

> 
> 
> Slava Sedov wrote:
> 
> > got server error "Cannot construct namespace declaration 
> > xmlns:='http://www.w3.org/1999/xhtml'. Prefix '' is already mapped to 
> > namespace ''.
> 
> What exactly do you do when that error happens? Running an XSLT 
> transformation? With MSXML? With .NET XslTransform?
> How does the XML input look, how the stylesheet? What kind of output are 
> you trying to create?
> 
> 
> > <xsl:stylesheet xmlns:xhtml="http://www.w3.org/1999/xhtml" 
> > xmlns="http://www.w3.org/1999/xhtml" 
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> > xmlns:publ="http://publicant.ru/2005" version="1.0">
> 
> Nothing in that snippet that would cause an error.
> 
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/
> 


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent