Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > namespaces in XSLT

Reply
Thread Tools

namespaces in XSLT

 
 
Andy Fish
Guest
Posts: n/a
 
      02-29-2008
Hi,

I have an xml document that defines xmlns="foo" and an xslt stylesheet
that defines xmlns="bar". Running the transformation using
XslCompiledDocument in .Net 2.0, I get the following error message:

Cannot construct namespace declaration xmlns='bar'. Prefix 'p' is already
mapped to namespace 'foo'.

The problem does not happen using xml spy's built-in XSLT engine.

Unfortunately both the stylesheet and document are very large and I haven't
managed to reproduce a simple example yet.. However, I thought namespace
prefixes in the XML document and the stylesheet were independent (indeed
isn't that the whole point of namespace prefixes?).

I am not in control of the prefixes used in the xml documents I am
processing, so I would like to produce a stylesheet that works regardless of
the prefixes in the document.

Is this message likely to be down to some bug in XslCompiledTransform, or
something I am doing wrong?

Andy


 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      02-29-2008
In article <20Sxj.60272$(E-Mail Removed) >,
Andy Fish <(E-Mail Removed)> wrote:

>I have an xml document that defines xmlns="foo" and an xslt stylesheet
>that defines xmlns="bar". Running the transformation using
>XslCompiledDocument in .Net 2.0, I get the following error message:
>
>Cannot construct namespace declaration xmlns='bar'. Prefix 'p' is already
>mapped to namespace 'foo'.


The fact that it says it cannot *construct* a namespace declaration
suggests that perhaps it's just having a problem serializing the
result. Obviously it shouldn't have this problem, but perhaps
you can work around it by using exclude-result-prefixes="p" to prevent
it from unnecessarily binding p to bar in the output (if it
really is unnecessary).

I don't use the software in question so I could be quite wrong about this.

-- Richard
--
:wq
 
Reply With Quote
 
 
 
 
TOUDIdel
Guest
Posts: n/a
 
      02-29-2008

Użytkownik "Andy Fish" <(E-Mail Removed)> napisał w wiadomości
news:20Sxj.60272$(E-Mail Removed). uk...
> Hi,
>
> I have an xml document that defines xmlns="foo" and an xslt stylesheet
> that defines xmlns="bar". Running the transformation using
> XslCompiledDocument in .Net 2.0, I get the following error message:
>
> Cannot construct namespace declaration xmlns='bar'. Prefix 'p' is already
> mapped to namespace 'foo'.
>
> The problem does not happen using xml spy's built-in XSLT engine.
>
> Unfortunately both the stylesheet and document are very large and I
> haven't managed to reproduce a simple example yet.. However, I thought
> namespace prefixes in the XML document and the stylesheet were independent
> (indeed isn't that the whole point of namespace prefixes?).
>
> I am not in control of the prefixes used in the xml documents I am
> processing, so I would like to produce a stylesheet that works regardless
> of the prefixes in the document.
>
> Is this message likely to be down to some bug in XslCompiledTransform, or
> something I am doing wrong?
>
> Andy


it doesn't matter what is a prefix. important thing is to which namespace it
indicates. you can have xmlns="foo" in your xml document and
xmlns:something="foo" in your xslt stylesheet and it will be correct - you
will be able access nodes correctly
--
td


 
Reply With Quote
 
Joseph Kesselman
Guest
Posts: n/a
 
      02-29-2008
Andy Fish wrote:
> Cannot construct namespace declaration xmlns='bar'. Prefix 'p' is already
> mapped to namespace 'foo'.


That error message doesn't make sense unless you are somehow trying to
set the prefix to two different namespace names on the same element.

Which shouldn't be happening.

Hard to say without seeing the failing example, but I wouldn't be
surprised if this was a Microsoft bug.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xslt and namespaces S2 XML 2 11-08-2010 08:25 AM
XSLT: Normalizing namespaces Thomas Wittek XML 5 08-31-2007 12:16 PM
(Noob) Working with namespaces in XSLT daz_oldham XML 2 05-23-2006 04:06 PM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
XML & XSLT namespaces Colin Fox XML 2 01-11-2004 05:40 PM



Advertisments