|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Unwanted xmlns attribute appearing
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
|
Back To School Sale!Save 30% off all Stylus Studio 2008 Products when you purchase from our Online Shop. Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






