Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: XSL for removing words less than 4 letters in a sitemap [Thread Next] Re: XSL for removing words less than 4 letters in a sitemapTo: NULL Date: 4/10/2008 4:48:00 AM On 9 abr, 15:51, Martin Honnen <mahotr...@yahoo.de> wrote:
> Olagato wrote:
> > So there are 2 things left:
> > 1- <lastmod> tags should dissapear from <url> outputs because a
> > <news:publication_date> tag has been defined already.
> > 2- xmlns:news namespace should dissapear from <news:news> tags and it
> > should be taken to the <urlset xmlns="http://www.sitemaps.org/schemas/
> > sitemap/0.9"> tag in the header.
>
> Both are easy adaptions, you need to use a predicate
> [not(self::sm:lastmod)] and you can use xsl:namespace to make sure a
> namespace declaration is created on the root element:
>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
> xmlns:sm="http://www.sitemaps.org/schemas/sitemap/0.9"
> exclude-result-prefixes="sm"
> version="2.0">
> <xsl:output method="xml" indent="yes"/>
> <xsl:strip-space elements="*"/>
> <xsl:template match="@* | node()">
> <xsl:copy>
> <xsl:apply-templates select="@* | node()"/>
> </xsl:copy>
> </xsl:template>
> <xsl:template match="sm:urlset">
> <xsl:copy>
> <xsl:namespace name="news"
> select="'http://www.google.com/schemas/sitemap-news/0.9'"/>
> <xsl:apply-templates select="@* | node()"/>
> </xsl:copy>
> </xsl:template>
> <xsl:template match="sm:url">
> <xsl:copy>
> <xsl:apply-templates select="@* | node()[not(self::sm:lastmod)]"/>
> <news:news>
> <news:publication_date>
> <xsl:value-of select="sm:lastmod"/>
> </news:publication_date>
> <news:keywords>
> <xsl:value-of select="for $s in tokenize(sm:loc, '/')[position()
> > 5]
> return tokenize($s, '[\-/]')[string-length(.)
> > 3]" separator=", "/>
> </news:keywords>
> </news:news>
> </xsl:copy>
> </xsl:template>
> </xsl:stylesheet>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/
Solved !!! It works fine now.
I have modified line:
for $s in tokenize(sm:loc, '/')[position()> 5]
to this one:
for $s in tokenize(sm:loc, '/')[position()> 6]
in order to delete "ezwebin_site" word within <news:keywords> tag.
Thank you very much Martin, people like you make the "world wide web"
to be a better place.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
