xsl-list
[Top] [All Lists]

Re: [xsl] Unwanted xmlns attribute appearing

2006-04-26 12:14:22
Karine Delvare <kdelvare(_at_)nerim(_dot_)net> writes:

Hello,

   I am generating RSS feeds from an HTML file. With Perl, until I
   finally realized XSLT would be a much better solution. I decided
   to create a new XML file, and to have seceral XSL stylesheets,
   one to produce the HTML file and the others to produce the RSS
   files. First question: was that stupid?

No.


   The XML file is currently looking like this: 
http://edhel.gimp.org/devnews.xml
   I managed to write the XSL to produce HTML:
   http://edhel.gimp.org/devnews.xsl produces
   http://edhel.gimp.org/devnews.html

   Now I'm struggling with the RSS1.0
   feed. http://edhel.gimp.org/devnews-rss1.xsl produces
   http://edhel.gimp.org/devnews-rss1.xml
   The <item> markup gets a xmlns="" attribute, and I don't know
   where that comes from.

It's because you're using namespaces elsewhere.

You know what though? It's better to use RSS 2.0 or ATOM because
they're simpler and better supported than RDF/RSS.

Here's the guts of an RSS 2.0 stylesheet for your data:

  <xsl:template match="item">
    <item>
      <xsl:choose>
        <xsl:when test="//a[contains(@href, 'gimp.org')]">
           <link><xsl:value-of select="//a[contains(@href, 
'gimp.org')][1]/@href"/></link>
        </xsl:when>
        <xsl:when test="//a[(_at_)href]">
           <link><xsl:value-of select="//a[1]/@href"/></link>
        </xsl:when>
      </xsl:choose>
      <channel><xsl:value-of select="@type"/></channel>
      <description><xsl:value-of select="//text()"/></description>
    </item>
  </xsl:template>

You might apply this with the xpath:

   //item

I personally think you'd do much better putting real dates in your
source file. Tag each item with a date because RSS files with real
dates in are much better for users (they can be aggregated by date and
are much better that way). This follows an old data processing rule:
never remove information until you have to.


   So, second question: what did I miss there?

I think it's just because the RDF ns is there, libxslt wants to name
the other ns as well; even though it's null it's still there.


Nic Ferrier

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>