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 sitemap Re: XSL for removing words less than 4 letters in a sitemapTo: NULL Date: 4/8/2008 10:42:00 AM On 3 abr, 16:45, Martin Honnen <mahotr...@yahoo.de> wrote: > Olagato wrote: > > Your posted version in 1.0 functionality seems to be quite difficult > > to implement because of lack of advanced functions (at least for a xsl > > newbie like me) So my only alternative would be to use a XSLT > > processor. I'll try Xalan on server:http://xalan.apache.org/ > > Any other idea using XSLT 1.0 will be appreciated. > > Xalan does not do XSLT 2.0 so if you want to use XSLT 2.0 then try Saxon > (http://saxon.sourceforge.net/) or Gestalt > (http://gestalt.sourceforge.net/) or AltovaXML > (http://www.altova.com/altovaxml.html). > > If you want to use PHP then I think PHP supports EXSLT so you could try > to usehttp://www.exslt.org/str/functions/tokenize/index.html > > -- > > Martin Honnen > http://JavaScript.FAQTs.com/ Thank you very much, Martin It's now working fine with Altova XMLSpy">XMLSpy and Saxon9 as external XSLT parser: http://216.239.59.104/search?q=3Dcache:jAvcNg5Pzz8J:www.altova.com/forum/def= ault.aspx%3Fg%3Dposts%26t%3D1000000527+Tools+Options+XSL+saxon+xmlspy&hl=3De= s&ct=3Dclnk&cd=3D6&gl=3Des&client=3Dfirefox-a There are only 2 little issues left: My XML input is: <?xml version=3D"1.0" encoding=3D"UTF-8"?> <urlset xmlns=3D"http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>http://localhost/index.php/index.php/ezwebin_site/Rutas-de- verano-en-Espa=F1a</loc> <lastmod>2008-03-13</lastmod> <changefreq>daily</changefreq> <priority>0.8</priority> </url> <url> <loc>http://localhost/index.php/index.php/ezwebin_site/Rutas/El- Camino-de-Santiago-en-el-Sobrarbe</loc> <lastmod>2008-02-12</lastmod> <changefreq>weekly</changefreq> <priority>0.7</priority> </url> </urlset> Your XSLT 2.0 is: <xsl:stylesheet xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform" xmlns:news=3D"http://www.google.com/schemas/sitemap-news/0.9" xmlns:sm=3D"http://www.sitemaps.org/schemas/sitemap/0.9" exclude-result- prefixes=3D"sm" version=3D"2.0"> <xsl:output method=3D"xml" indent=3D"yes"/> <xsl:strip-space elements=3D"*"/> <xsl:template match=3D"@* | node()"> <xsl:copy> <xsl:apply-templates select=3D"@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match=3D"sm:url"> <xsl:copy> <xsl:apply-templates select=3D"@* | node()"/> <news:news> <news:publication_date> <xsl:value-of select=3D"sm:lastmod"/> </news:publication_date> <news:keywords> <xsl:value-of select=3D"for $s in tokenize(sm:loc, '/')[position() > 5] return tokenize($s, '[\-/]')[string-length(.) > 3]" separator=3D", "/> </news:keywords> </news:news> </xsl:copy> </xsl:template> </xsl:stylesheet> The output is: <?xml version=3D"1.0" encoding=3D"UTF-8"?> <urlset xmlns=3D"http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>http://localhost/index.php/index.php/ezwebin_site/Rutas-de- verano-en-Espa=F1a</loc> <lastmod>2008-03-13</lastmod> <changefreq>daily</changefreq> <priority>0.8</priority> <news:news xmlns:news=3D"http://www.google.com/schemas/sitemap-news/ 0.9"> <news:publication_date>2008-03-13</news:publication_date> <news:keywords>ezwebin_site, Rutas, verano, Espa=F1a</news:keywords> </news:news> </url> <url> <loc>http://localhost/index.php/index.php/ezwebin_site/Rutas/El- Camino-de-Santiago-en-el-Sobrarbe</loc> <lastmod>2008-02-12</lastmod> <changefreq>weekly</changefreq> <priority>0.7</priority> <news:news xmlns:news=3D"http://www.google.com/schemas/sitemap-news/ 0.9"> <news:publication_date>2008-02-12</news:publication_date> <news:keywords>ezwebin_site, Rutas, Camino, Santiago, rt</ news:keywords> </news:news> </url> </urlset> But I need an output like defined by News Sitemap Protocol: http://www.google.com/support/webmasters/bin/answer.py?answer=3D42738 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=3D"http://www.sitemaps.org/schemas/ sitemap/0.9"> tag in the header. A good output file would be: <?xml version=3D"1.0" encoding=3D"UTF-8"?> <urlset xmlns=3D"http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news=3D"http://www.google.com/schemas/sitemap-news/0.9"> <url> <loc>http://localhost/index.php/index.php/ezwebin_site/Rutas-de- verano-en-Espa=F1a</loc> <changefreq>daily</changefreq> <priority>0.8</priority> <news:news> <news:publication_date>2008-03-13</news:publication_date> <news:keywords>ezwebin_site, Rutas, verano, Espa=F1a</news:keywords> </news:news> </url> <url> <loc>http://localhost/index.php/index.php/ezwebin_site/Rutas/El- Camino-de-Santiago-en-el-Sobrarbe</loc> <changefreq>weekly</changefreq> <priority>0.7</priority> <news:news> <news:publication_date>2008-02-12</news:publication_date> <news:keywords>ezwebin_site, Rutas, Camino, Santiago, rt</ news:keywords> </news:news> </url> </urlset> Any idea ? | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
