namespaces in XSLT

Discussion in 'XML' started by Andy Fish, Feb 29, 2008.

  1. Andy Fish

    Andy Fish Guest

    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
     
    Andy Fish, Feb 29, 2008
    #1
    1. Advertising

  2. In article <20Sxj.60272$>,
    Andy Fish <> wrote:

    >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
    --
    :wq
     
    Richard Tobin, Feb 29, 2008
    #2
    1. Advertising

  3. Andy Fish

    TOUDIdel Guest

    U¿ytkownik "Andy Fish" <> napisa³ w wiadomo¶ci
    news:20Sxj.60272$...
    > 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
    --
    td
     
    TOUDIdel, Feb 29, 2008
    #3
  4. 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
     
    Joseph Kesselman, Feb 29, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stylus Studio
    Replies:
    0
    Views:
    714
    Stylus Studio
    Aug 3, 2004
  2. Colin Fox

    XML & XSLT namespaces

    Colin Fox, Jan 11, 2004, in forum: XML
    Replies:
    2
    Views:
    454
    Colin Fox
    Jan 11, 2004
  3. daz_oldham
    Replies:
    2
    Views:
    639
    daz_oldham
    May 23, 2006
  4. Thomas Wittek

    XSLT: Normalizing namespaces

    Thomas Wittek, Aug 30, 2007, in forum: XML
    Replies:
    5
    Views:
    1,205
    Martin Honnen
    Aug 31, 2007
  5. S2

    xslt and namespaces

    S2, Nov 5, 2010, in forum: XML
    Replies:
    2
    Views:
    1,469
Loading...

Share This Page