On Thu, 2 Nov 2000 [EMAIL PROTECTED] wrote:

> Ok that works, but i have absolutely no clue why that happens. You
> introduced a new namespace (either it's rss or foo it equally works) that is
> not ever mentioned in the XML source. Why introducing a bogus namespace in
> the stylesheet works for rendering content in xml (that doesn't mention the
> namespace in question).

The problem is that in XPath, you cannot use an un-prefixed name to mean
the default namespace. If you think about this as an implementor it makes
perfect sense. Lets look at things from an expanded name point of
view. All elements with a namespace in an XML document have an expanded
name, so the following:

<root xmlns:foo="http://foo" xmlns="http://bar">
        <p>
                <foo:b>Hello World</foo:b>
        </p>
</root>

Once it has been parsed, looks like this (using James Clark's expanded
namespace notation):

<{http://bar}root>
        <{http://bar}p>
                <{http://foo}b>Hello World</{http://foo}b>
        </{http://bar}p>
</{http://bar}root>

So you can see, that even elements in the default namespace become
expanded names after parsing.

Now you also have to be able to handle elements without a namespace
(i.e. where no default xmlns="..." is defined). So XPath makes a very
clear distinction about this, which says that un-prefixed names are not in
a namespace.

So what you've got in your XML, is an item tag in the default namespace
(the RSS 0.9 namespace). Now in a completely separate document (your XSLT
stylesheet) you have to match against
'{http://my.netscape.com/rdf/simple/0.9/}item', not just 'item'. The only
way to do that is to define the namespace in your XSLT stylesheet and use
a prefix mapping to expand that name out to the fully qualified name
above.

And that, in summary, is how XPath namespaces work. Hope it helps clarify
things further for you! (I really should be writing a book about this, but
I just don't have time, so you get it all in email snippets!).

-- 
<Matt/>

    /||    ** Director and CTO **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // **     Personal Web Site: http://sergeant.org/     **
     \\//
     //\\
    //  \\


Reply via email to