Subject: Re: [xsl] Unwanted xmlns attribute appearing From: Nic <nferrier@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 26 Apr 2006 20:08:10 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Unwanted xmlns attribute appe, Karine Delvare | Thread | RE: [xsl] Unwanted xmlns attribute , Michael Kay |
Re: [xsl] Question about cross refe, Jay Bryant | Date | Re: [xsl] split string to whole wor, andrew welch |
Month |