[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Unwanted xmlns attribute appearing

Subject: Re: Unwanted xmlns attribute appearing
From: Nic <nferrier@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 26 Apr 2006 20:08:10 +0100
unwanted xmlns
Karine Delvare <kdelvare@xxxxxxxxx> 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[@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

Current Thread

Back To School Sale!

Save 30% off all Stylus Studio 2008 Products when you purchase from our Online Shop.

Offer ends August 31, 2008.

Coupon Code
TRTY-C4JV-OFF

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.