namespaces in XSLT

A

Andy Fish

Hi,

I have an xml document that defines xmlns:p="foo" and an xslt stylesheet
that defines xmlns:p="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
 
R

Richard Tobin

Andy Fish said:
I have an xml document that defines xmlns:p="foo" and an xslt stylesheet
that defines xmlns:p="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
 
T

TOUDIdel

U¿ytkownik "Andy Fish said:
Hi,

I have an xml document that defines xmlns:p="foo" and an xslt stylesheet
that defines xmlns:p="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:p="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
 
J

Joseph Kesselman

Andy said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top