Re: [xsl] a namespace problem

Subject: Re: [xsl] a namespace problem
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 3 Apr 2002 18:24:08 +0100
Hi Bryan,

>>To get what you expect, simply choose an arbitrary namespace prefix
>>for your default namespace, and use that in expressions...
> would be counter-productive to go through the trouble of doing that
> as I'm gonna be downloading the rss periodically.
> Darn I just know it's gonna turn out having to be something with
> matching against the local-name().

I think perhaps you've misunderstood what Dion was saying. You don't
have to worry about changing the RSS documents - just declare the RSS
namespace in your stylesheet, with some prefix, and use that prefix
for matching/selecting the nodes:

<xsl:stylesheet version="1.0"

<xsl:template match="rdf:RDF">
  <xsl:apply-templates select="rss:channel" />

<xsl:template match="rss:channel">
  <h3 title="{rss:description}">
    <a href="{rss:link}"><xsl:value-of select="rss:title"/></a>



For example rss:channel matches/selects channel elements in the RSS
namespace. It doesn't matter what prefix was used in the RSS document
itself. As far as the XSLT processor is concerned, the RSS document:

<rdf:RDF xmlns:rdf="";

<channel rdf:about="";>

is more or less exactly the same as the RSS document:

<rdf:RDF xmlns:rdf="";

<rss:channel rdf:about="";>

and more or less exactly the same as the RSS document:

<wibble:RDF xmlns:wibble="";

<foo:channel wibble:about="";>

Namespace prefixes (or lack of them) in the XML document don't matter.
Namespace prefixes in the XSLT document don't matter, but if you want
to refer to an element or attribute in a namespace then you must
associate some kind of prefix with that namespace.

There's absolutely no need to use local-name() in this situation.



Jeni Tennison

 XSL-List info and archive:

Current Thread