>      Yes, the problem is that channel, item, image, et al. are in the 
> default namespace.  Although those elements don't have 
> prefixes in the XML 

changing the default namespace always causes a bit of a headache - here the 
default namespace is changed to:

xmlns="http://purl.org/rss/1.0/"; 

then all nodes such as <channel> are in that namespace, which is not 
immediately obvious as it doesnt have a prefix so the only way to find out is 
to walk back up the tree looking for the default namespace declaration...not an 
ideal situation.

The way to complement this in the stylesheet is to declare the namespace with a 
prefix and then use the prefix in you xpaths, such as:

<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";  
  xmlns:def="http://purl.org/rss/1.0/"; 
  version="1.0">

<xsl:template match="def:channel">
  <xsl:apply-templates select="//def:whatever"/> 
  ...
</xsl:template>

cheers
andrew

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: 02 January 2003 15:42
> To: Jacob Hookom
> Cc: [EMAIL PROTECTED]
> Subject: Re: RSS Transformation-- Namespace Issue?
> 
> 
> Hi Jacob,
> 
>      Yes, the problem is that channel, item, image, et al. are in the 
> default namespace.  Although those elements don't have 
> prefixes in the XML 
> document, their namespaces still need to be taken into account in the 
> XPath expressions in the stylesheet.
> 
>      See the following FAQ for additional information: 
> http://xml.apache.org/xalan-j/faq.html#faq-N101B9
> 
> Thanks,
> 
> Henry
> ------------------------------------------------------------------
> Henry Zongaro      Xalan development
> IBM SWS Toronto Lab   Tie Line 969-6044;  Phone (905) 413-6044
> mailto:[EMAIL PROTECTED]
> 
> 
> 
> 
> "Jacob Hookom" <[EMAIL PROTECTED]>
> 12/29/2002 04:01 PM
> 
>  
>         To:     <[EMAIL PROTECTED]>
>         cc: 
>         Subject:        RSS Transformation-- Namespace Issue?
> 
>  
> 
> Hello,
>  
> I'm trying to transform the Slashdot RSS feed via an XSL File 
> posted at 
> IBM's DevZone:
>  
> http://slashdot.org/slashdot.rss
>  
> http://www-106.ibm.com/developerworks/xml/library/x-tiphdln.ht
ml?dwzone=xml
 
I'm able to pull in the feed from Slashdot easily and I'm able to grab the 
first node and output its namespace-uri as a test, but, trying to select 
any of the channels or items returns nothing:
 
[Stylesheet deleted by Henry]
 
Returns:
 
<h1>http://www.w3.org/1999/02/22-rdf-syntax-ns#</h1>
<ul></ul>
 
I'm wondering if I need to put a namespace item in my XSL sheet or 
something.
 
Any help would be greatly appreciated!
Jacob Hookom




---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002
 

Reply via email to