XSL Problema cu for-each
Last Updated: Dec 17 2009 22:52, Started by
nimo
, Dec 17 2009 21:20
·
0
#1
Posted 17 December 2009 - 21:20
am fisierul xml
http://free-kino.com/sitemap.xml si fisierul xls http://free-kino.com/sitemap.xsl daca in xml pun <urlset xmlns="http://www.sitemaps....s/sitemap/0.9"> numi afizeaza continutul daca pun <urlset> merge <xsl:for-each select="urlset/url"> <tr> <td> <xsl:value-of select="loc"></xsl:value-of> </td> <td> <xsl:value-of select="lastmod"></xsl:value-of> </td> <td> <xsl:value-of select="changefreq"></xsl:value-of> </td> <td> <xsl:value-of select="priority"></xsl:value-of> </td> </tr> </xsl:for-each> Edited by nimo, 17 December 2009 - 21:23. |
#2
Posted 17 December 2009 - 21:51
Din cauza ca select-ul din XSL ia in considerare spatiul de nume.
Spatiul de nume implicit din XSL nu este definit astfel el va cauta "urlset/url" din spatiul de nume vid, dar ele au spatiu de nume in XML si nu va fi match, pentru el sunt ca entitati total separate. Problema ar fi ca in XSL nu poti defini acel spatiu de nume sa fie implicit, pentru ca tu vrei de fapt cel implicit sa fie HTML (chiar daca nu specifiti browserul te intelege). Solutia este sa definesti acel spatiu de nume si sa ii atribui o scurtatura (sa nu fie cel implicit), si te vei referi la orice entitate din XML prin acea scurtatura. Adaugi xmlns:sm="http://www.sitemaps....as/sitemap/0.9" la XSL si folosesti ""sm:urlset/sm:url". XSL-ul de mai jos va functiona : <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sm="http://www.sitemaps.org/schemas/sitemap/0.9"> <xsl:template match="/"> <html> <head> <style type="text/css"> body { font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana; font-size:13px; } div { background-color:#dfd; border:1px #2580B2 solid; padding:5px; margin:10px; width:790px; } table { background-color:#fff1d5; border:1px #59C5F6 solid; margin:10px; width:800px; } td { font-size:11px; } a { color:#8d0000; text-decoration:none; } a:hover { color:#00f; text-decoration:none; } .antet{ background-color:#CFEBF7; font-size:12px; font-weight:bold; } </style> </head> <body> <h2>Site map URL-uri</h2> <div> <p> Acest XML Sitemap este creat pentru a fi procesat de motoarele de căutare cum sunt: <a href="http://www.google.com">Google</a>, <a href="http://search.msn.com">MSN Search</a>, <a href="http://www.yahoo.com">YAHOO</a>. şi multe altele.<br /> Pentru mai multă informaţie puteţi accesa adresa administratorului site-ului: <a href="mailto:[email protected]">[email protected]</a><br /> sau a creatorului acestui sitemap: <a href="http://free-kino.com">www.Free-Kino.com</a> email,<a href="mailto:[email protected]">[email protected]</a> </p> </div> <table cellspacing="0" cellpadding="4"> <tr class="antet"> <td> URL </td> <td> Lastmod </td> <td> Changefreq </td> <td> Priority </td> </tr> <xsl:for-each select="sm:urlset/sm:url"> <tr> <td> <xsl:value-of select="sm:loc"></xsl:value-of> </td> <td> <xsl:value-of select="sm:lastmod"></xsl:value-of> </td> <td> <xsl:value-of select="sm:changefreq"></xsl:value-of> </td> <td> <xsl:value-of select="sm:priority"></xsl:value-of> </td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> |
Anunturi
Bun venit pe Forumul Softpedia!
▶ 0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users